1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 23:11:16 +02:00

Add a Config class to simplify adding configuration settings

The typical use is to inherit Config and add Setting<T> members:

  class MyClass : private Config
  {
    Setting<int> foo{this, 123, "foo", "the number of foos to use"};
    Setting<std::string> bar{this, "blabla", "bar", "the name of the bar"};

    MyClass() : Config(readConfigFile("/etc/my-app.conf"))
    {
      std::cout << foo << "\n"; // will print 123 unless overriden
    }
  };

Currently, this is used by Store and its subclasses for store
parameters. You now get a warning if you specify a non-existant store
parameter in a store URI.
This commit is contained in:
Eelco Dolstra 2017-04-13 15:55:38 +02:00
parent 568a099c88
commit 2040240e23
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
16 changed files with 334 additions and 40 deletions

View file

@ -125,22 +125,22 @@ S3Helper::DownloadResult S3Helper::getObject(
struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
{
const Setting<std::string> region{this, Aws::Region::US_EAST_1, "region", {"aws-region"}};
const Setting<std::string> narinfoCompression{this, "", "narinfo-compression", "compression method for .narinfo files"};
const Setting<std::string> lsCompression{this, "", "ls-compression", "compression method for .ls files"};
const Setting<std::string> logCompression{this, "", "log-compression", "compression method for log/* files"};
std::string bucketName;
Stats stats;
S3Helper s3Helper;
std::string narinfoCompression, lsCompression, logCompression;
S3BinaryCacheStoreImpl(
const Params & params, const std::string & bucketName)
: S3BinaryCacheStore(params)
, bucketName(bucketName)
, s3Helper(get(params, "aws-region", Aws::Region::US_EAST_1))
, narinfoCompression(get(params, "narinfo-compression", ""))
, lsCompression(get(params, "ls-compression", ""))
, logCompression(get(params, "log-compression", ""))
, s3Helper(region)
{
diskCache = getNarInfoDiskCache();
}