Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
s3-binary-cache-store.hh
Go to the documentation of this file.
1#pragma once
3
5
6#include <atomic>
7
8namespace nix {
9
10struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
11{
12 std::string bucketName;
13
14 using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
15
16 S3BinaryCacheStoreConfig(std::string_view uriScheme, std::string_view bucketName, const Params & params);
17
18 const Setting<std::string> profile{
19 this,
20 "",
21 "profile",
22 R"(
23 The name of the AWS configuration profile to use. By default
24 Nix will use the `default` profile.
25 )"};
26
27protected:
28
29 constexpr static const char * defaultRegion = "us-east-1";
30
31public:
32
33 const Setting<std::string> region{
34 this,
35 defaultRegion,
36 "region",
37 R"(
38 The region of the S3 bucket. If your bucket is not in
39 `us–east-1`, you should always explicitly specify the region
40 parameter.
41 )"};
42
43 const Setting<std::string> scheme{
44 this,
45 "",
46 "scheme",
47 R"(
48 The scheme used for S3 requests, `https` (default) or `http`. This
49 option allows you to disable HTTPS for binary caches which don't
50 support it.
51
52 > **Note**
53 >
54 > HTTPS should be used if the cache might contain sensitive
55 > information.
56 )"};
57
58 const Setting<std::string> endpoint{
59 this,
60 "",
61 "endpoint",
62 R"(
63 The URL of the endpoint of an S3-compatible service such as MinIO.
64 Do not specify this setting if you're using Amazon S3.
65
66 > **Note**
67 >
68 > This endpoint must support HTTPS and will use path-based
69 > addressing instead of virtual host based addressing.
70 )"};
71
72 const Setting<std::string> narinfoCompression{
73 this, "", "narinfo-compression", "Compression method for `.narinfo` files."};
74
75 const Setting<std::string> lsCompression{this, "", "ls-compression", "Compression method for `.ls` files."};
76
77 const Setting<std::string> logCompression{
78 this,
79 "",
80 "log-compression",
81 R"(
82 Compression method for `log/*` files. It is recommended to
83 use a compression method supported by most web browsers
84 (e.g. `brotli`).
85 )"};
86
87 const Setting<bool> multipartUpload{this, false, "multipart-upload", "Whether to use multi-part uploads."};
88
89 const Setting<uint64_t> bufferSize{
90 this, 5 * 1024 * 1024, "buffer-size", "Size (in bytes) of each part in multi-part uploads."};
91
92 const std::string name() override
93 {
94 return "S3 Binary Cache Store";
95 }
96
97 static std::set<std::string> uriSchemes()
98 {
99 return {"s3"};
100 }
101
102 std::string doc() override;
103};
104
105class S3BinaryCacheStore : public virtual BinaryCacheStore
106{
107protected:
108
109 S3BinaryCacheStore(const Params & params);
110
111public:
112
113 struct Stats
114 {
115 std::atomic<uint64_t> put{0};
116 std::atomic<uint64_t> putBytes{0};
117 std::atomic<uint64_t> putTimeMs{0};
118 std::atomic<uint64_t> get{0};
119 std::atomic<uint64_t> getBytes{0};
120 std::atomic<uint64_t> getTimeMs{0};
121 std::atomic<uint64_t> head{0};
122 };
123
124 virtual const Stats & getS3Stats() = 0;
125};
126
127}
Definition config.hh:320
Definition binary-cache-store.hh:17
std::string doc() override
const std::string name() override
Definition s3-binary-cache-store.hh:92
Definition s3-binary-cache-store.hh:114