mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
refactor(libstore): expose HttpBinaryCacheStore and add S3BinaryCacheStore
Move HttpBinaryCacheStore class from .cc file to header to enable inheritance by S3BinaryCacheStore. Create S3BinaryCacheStore class that overrides upsertFile() to implement multipart upload logic.
This commit is contained in:
parent
1a9ba0d6fe
commit
476c21d5ef
4 changed files with 284 additions and 212 deletions
|
|
@ -7,6 +7,36 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
class S3BinaryCacheStore : public virtual HttpBinaryCacheStore
|
||||
{
|
||||
public:
|
||||
S3BinaryCacheStore(ref<S3BinaryCacheStoreConfig> config)
|
||||
: Store{*config}
|
||||
, BinaryCacheStore{*config}
|
||||
, HttpBinaryCacheStore{config}
|
||||
, s3Config{config}
|
||||
{
|
||||
}
|
||||
|
||||
void upsertFile(
|
||||
const std::string & path,
|
||||
std::shared_ptr<std::basic_iostream<char>> istream,
|
||||
const std::string & mimeType,
|
||||
uint64_t sizeHint) override;
|
||||
|
||||
private:
|
||||
ref<S3BinaryCacheStoreConfig> s3Config;
|
||||
};
|
||||
|
||||
void S3BinaryCacheStore::upsertFile(
|
||||
const std::string & path,
|
||||
std::shared_ptr<std::basic_iostream<char>> istream,
|
||||
const std::string & mimeType,
|
||||
uint64_t sizeHint)
|
||||
{
|
||||
HttpBinaryCacheStore::upsertFile(path, istream, mimeType, sizeHint);
|
||||
}
|
||||
|
||||
StringSet S3BinaryCacheStoreConfig::uriSchemes()
|
||||
{
|
||||
return {"s3"};
|
||||
|
|
@ -51,6 +81,13 @@ std::string S3BinaryCacheStoreConfig::doc()
|
|||
)";
|
||||
}
|
||||
|
||||
ref<Store> S3BinaryCacheStoreConfig::openStore() const
|
||||
{
|
||||
auto sharedThis = std::const_pointer_cast<S3BinaryCacheStoreConfig>(
|
||||
std::static_pointer_cast<const S3BinaryCacheStoreConfig>(shared_from_this()));
|
||||
return make_ref<S3BinaryCacheStore>(ref{sharedThis});
|
||||
}
|
||||
|
||||
static RegisterStoreImplementation<S3BinaryCacheStoreConfig> registerS3BinaryCacheStore;
|
||||
|
||||
} // namespace nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue