hydra/src/hydra-queue-runner/s3-binary-cache-store.hh

60 lines
1.2 KiB
C++
Raw Normal View History

2016-02-18 15:18:50 +00:00
#pragma once
#include "binary-cache-store.hh"
#include <atomic>
2016-02-18 15:18:50 +00:00
namespace Aws { namespace Client { class ClientConfiguration; } }
namespace Aws { namespace S3 { class S3Client; } }
namespace nix {
class S3BinaryCacheStore : public BinaryCacheStore
{
private:
std::string bucketName;
ref<Aws::Client::ClientConfiguration> config;
ref<Aws::S3::S3Client> client;
public:
2016-02-24 13:04:31 +00:00
S3BinaryCacheStore(std::shared_ptr<Store> localStore,
2016-03-04 16:51:32 +00:00
const Path & secretKeyFile, const std::string & bucketName);
2016-02-18 15:18:50 +00:00
void init() override;
struct Stats
{
std::atomic<uint64_t> put{0};
std::atomic<uint64_t> putBytes{0};
std::atomic<uint64_t> putTimeMs{0};
std::atomic<uint64_t> get{0};
std::atomic<uint64_t> getBytes{0};
std::atomic<uint64_t> getTimeMs{0};
std::atomic<uint64_t> head{0};
};
const Stats & getS3Stats();
bool isValidPath(const Path & storePath) override;
2016-02-18 15:18:50 +00:00
private:
Stats stats;
2016-02-18 15:18:50 +00:00
ref<Aws::Client::ClientConfiguration> makeConfig();
protected:
bool fileExists(const std::string & path) override;
void upsertFile(const std::string & path, const std::string & data) override;
2016-04-15 13:39:20 +00:00
std::shared_ptr<std::string> getFile(const std::string & path) override;
2016-02-18 15:18:50 +00:00
};
}