1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-20 01:09:37 +01:00

feat(libstore): add S3 storage class support

Add support for configuring S3 storage class via the storage-class
parameter for S3BinaryCacheStore. This allows users to optimize costs
by selecting appropriate storage tiers (STANDARD, GLACIER,
INTELLIGENT_TIERING, etc.) based on access patterns.

The storage class is applied via the x-amz-storage-class header for
both regular PUT uploads and multipart upload initiation.
This commit is contained in:
Bernardo Meurer Costa 2025-10-23 04:32:58 +00:00
parent a786c9eedb
commit 4e64dea21b
No known key found for this signature in database
4 changed files with 65 additions and 2 deletions

View file

@ -134,10 +134,14 @@ void S3BinaryCacheStore::upsertFile(
const std::string & path, RestartableSource & source, const std::string & mimeType, uint64_t sizeHint)
{
auto doUpload = [&](RestartableSource & src, uint64_t size, std::optional<Headers> headers) {
Headers uploadHeaders = headers.value_or(Headers());
if (auto storageClass = s3Config->storageClass.get()) {
uploadHeaders.emplace_back("x-amz-storage-class", *storageClass);
}
if (s3Config->multipartUpload && size > s3Config->multipartThreshold) {
uploadMultipart(path, src, size, mimeType, std::move(headers));
uploadMultipart(path, src, size, mimeType, std::move(uploadHeaders));
} else {
upload(path, src, size, mimeType, std::move(headers));
upload(path, src, size, mimeType, std::move(uploadHeaders));
}
};