diff options
| author | Stefan Boberg <[email protected]> | 2021-09-17 19:11:27 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-17 19:11:27 +0200 |
| commit | a47396e06a8c6ebc2a44135c47d4820e6984c225 (patch) | |
| tree | e719ed435a2de51e477822d98b0c71083edcca6a /zenserver/config.cpp | |
| parent | Implemented basics for Windows server support (not yet 100% - needs to proper... (diff) | |
| parent | Added upstream cache policy command line option (read|write,readonly,writeonl... (diff) | |
| download | zen-a47396e06a8c6ebc2a44135c47d4820e6984c225.tar.xz zen-a47396e06a8c6ebc2a44135c47d4820e6984c225.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zenserver/config.cpp')
| -rw-r--r-- | zenserver/config.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 092fc6998..164d2a792 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -55,6 +55,27 @@ PickDefaultStateDirectory() #endif +UpstreamCachePolicy +ParseUpstreamCachePolicy(std::string_view Options) +{ + if (Options == "readonly") + { + return UpstreamCachePolicy::Read; + } + else if (Options == "writeonly") + { + return UpstreamCachePolicy::Write; + } + else if (Options == "disabled") + { + return UpstreamCachePolicy::Disabled; + } + else + { + return UpstreamCachePolicy::ReadWrite; + } +} + void ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, ZenServiceConfig& ServiceConfig) { @@ -113,6 +134,14 @@ ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, Z cxxopts::value<bool>(ServiceConfig.ShouldCrash)->default_value("false"), ""); + std::string UpstreamCachePolicyOptions; + options.add_option("cache", + "", + "upstream-cache-policy", + "", + cxxopts::value<std::string>(UpstreamCachePolicyOptions)->default_value(""), + "Upstream cache policy (readwrite|readonly|writeonly|disabled)"); + options.add_option("cache", "", "upstream-jupiter-url", @@ -178,13 +207,6 @@ ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, Z options.add_option("cache", "", - "upstream-enabled", - "Whether upstream caching is disabled", - cxxopts::value<bool>(ServiceConfig.UpstreamCacheConfig.Enabled)->default_value("true"), - ""); - - options.add_option("cache", - "", "upstream-thread-count", "Number of threads used for upstream procsssing", cxxopts::value<int>(ServiceConfig.UpstreamCacheConfig.UpstreamThreadCount)->default_value("4"), @@ -200,6 +222,8 @@ ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, Z exit(0); } + + ServiceConfig.UpstreamCacheConfig.CachePolicy = ParseUpstreamCachePolicy(UpstreamCachePolicyOptions); } catch (cxxopts::OptionParseException& e) { @@ -276,7 +300,8 @@ ParseServiceConfig(const std::filesystem::path& DataRoot, ZenServiceConfig& Serv if (auto UpstreamConfig = StructuredCacheConfig->get<sol::optional<sol::table>>("upstream")) { - ServiceConfig.UpstreamCacheConfig.Enabled = UpstreamConfig->get_or("enable", ServiceConfig.UpstreamCacheConfig.Enabled); + std::string Policy = UpstreamConfig->get_or("policy", std::string()); + ServiceConfig.UpstreamCacheConfig.CachePolicy = ParseUpstreamCachePolicy(Policy); ServiceConfig.UpstreamCacheConfig.UpstreamThreadCount = UpstreamConfig->get_or("upstreamthreadcount", 4); if (auto JupiterConfig = UpstreamConfig->get<sol::optional<sol::table>>("jupiter")) |