diff options
| author | Per Larsson <[email protected]> | 2023-02-16 13:58:49 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-16 13:58:49 +0100 |
| commit | f30de2640d99451a85ff2820fdd0b0b5816d2e61 (patch) | |
| tree | 70bacc76c1eb8738e72387dfdf131230744e7ac8 /zenserver/config.cpp | |
| parent | changelog (diff) | |
| download | zen-f30de2640d99451a85ff2820fdd0b0b5816d2e61.tar.xz zen-f30de2640d99451a85ff2820fdd0b0b5816d2e61.zip | |
Experimental ObjectStore/CDN like endpoint
Diffstat (limited to 'zenserver/config.cpp')
| -rw-r--r-- | zenserver/config.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index fa4ee7f5a..cff93d67b 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -105,6 +105,34 @@ ParseUpstreamCachePolicy(std::string_view Options) } } +ZenObjectStoreConfig +ParseBucketConfigs(std::span<std::string> Buckets) +{ + using namespace std::literals; + + ZenObjectStoreConfig Cfg; + + // split bucket args in the form of "{BucketName};{LocalPath}" + for (std::string_view Bucket : Buckets) + { + ZenObjectStoreConfig::BucketConfig NewBucket; + + if (auto Idx = Bucket.find_first_of(";"); Idx != std::string_view::npos) + { + NewBucket.Name = Bucket.substr(0, Idx); + NewBucket.Directory = Bucket.substr(Idx + 1); + } + else + { + NewBucket.Name = Bucket; + } + + Cfg.Buckets.push_back(std::move(NewBucket)); + } + + return Cfg; +} + void ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptions); void @@ -492,6 +520,21 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) cxxopts::value<uint64_t>(ServerOptions.GcConfig.Cache.DiskSizeSoftLimit)->default_value("0"), ""); + options.add_option("objectstore", + "", + "objectstore-enabled", + "Whether the object store is enabled or not.", + cxxopts::value<bool>(ServerOptions.ObjectStoreEnabled)->default_value("false"), + ""); + + std::vector<std::string> BucketConfigs; + options.add_option("objectstore", + "", + "objectstore-bucket", + "Object store bucket mappings.", + cxxopts::value<std::vector<std::string>>(BucketConfigs), + ""); + try { auto result = options.parse(argc, argv); @@ -545,6 +588,8 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) {.Name = OpenIdProviderName, .Url = OpenIdProviderUrl, .ClientId = OpenIdClientId}); } + ServerOptions.ObjectStoreConfig = ParseBucketConfigs(BucketConfigs); + if (!ServerOptions.ConfigFile.empty()) { ParseConfigFile(ServerOptions.ConfigFile, ServerOptions); |