diff options
| author | Per Larsson <[email protected]> | 2022-01-26 09:00:16 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-01-26 09:00:16 +0100 |
| commit | 5291894278e160b9200b6ce261c6ab5437e45ccc (patch) | |
| tree | 3ea7c80380fe6ad6a223c903e795cc320c2a6c84 | |
| parent | Temporary fix for ZEN_ASSERT(!Options.Name.empty()) failing when running as a... (diff) | |
| download | zen-5291894278e160b9200b6ce261c6ab5437e45ccc.tar.xz zen-5291894278e160b9200b6ce261c6ab5437e45ccc.zip | |
Fixed issue with missing endpoint name when configuring upstream cache from Lua.
| -rw-r--r-- | zenserver/config.cpp | 13 | ||||
| -rw-r--r-- | zenserver/config.h | 2 | ||||
| -rw-r--r-- | zenserver/upstream/upstreamcache.cpp | 4 | ||||
| -rw-r--r-- | zenserver/zenserver.cpp | 32 |
4 files changed, 33 insertions, 18 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 3c4f6f3d8..a36ce5f33 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -337,10 +337,10 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) exit(0); } - ServerOptions.DataDir = DataDir; - ServerOptions.ContentDir = ContentDir; - ServerOptions.AbsLogFile = AbsLogFile; - ServerOptions.ConfigFile = ConfigFile; + ServerOptions.DataDir = DataDir; + ServerOptions.ContentDir = ContentDir; + ServerOptions.AbsLogFile = AbsLogFile; + ServerOptions.ConfigFile = ConfigFile; ServerOptions.UpstreamCacheConfig.CachePolicy = ParseUpstreamCachePolicy(UpstreamCachePolicyOptions); if (!ServerOptions.ConfigFile.empty()) @@ -479,6 +479,9 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio if (auto JupiterConfig = UpstreamConfig->get<sol::optional<sol::table>>("jupiter")) { UpdateStringValueFromConfig(JupiterConfig.value(), + std::string_view("name"), + ServerOptions.UpstreamCacheConfig.JupiterConfig.Name); + UpdateStringValueFromConfig(JupiterConfig.value(), std::string_view("url"), ServerOptions.UpstreamCacheConfig.JupiterConfig.Url); UpdateStringValueFromConfig(JupiterConfig.value(), @@ -507,6 +510,8 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio if (auto ZenConfig = UpstreamConfig->get<sol::optional<sol::table>>("zen")) { + ServerOptions.UpstreamCacheConfig.ZenConfig.Name = ZenConfig.value().get_or("name", std::string("Zen")); + if (auto Url = ZenConfig.value().get<sol::optional<std::string>>("url")) { ServerOptions.UpstreamCacheConfig.ZenConfig.Urls.push_back(Url.value()); diff --git a/zenserver/config.h b/zenserver/config.h index 2c31e7bd9..e38b5c704 100644 --- a/zenserver/config.h +++ b/zenserver/config.h @@ -21,6 +21,7 @@ struct ZenUpstreamJupiterConfig { + std::string Name; std::string Url; std::string OAuthProvider; std::string OAuthClientId; @@ -34,6 +35,7 @@ struct ZenUpstreamJupiterConfig struct ZenUpstreamZenConfig { + std::string Name; std::vector<std::string> Urls; std::vector<std::string> Dns; }; diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp index b0343a61b..8b02a437a 100644 --- a/zenserver/upstream/upstreamcache.cpp +++ b/zenserver/upstream/upstreamcache.cpp @@ -535,10 +535,12 @@ namespace detail { public: ZenUpstreamEndpoint(const ZenStructuredCacheClientOptions& Options) : m_Log(zen::logging::Get("upstream")) - , m_Info({.Name = std::string(Options.Name)}) , m_ConnectTimeout(Options.ConnectTimeout) , m_Timeout(Options.Timeout) { + ZEN_ASSERT(!Options.Name.empty()); + m_Info.Name = Options.Name; + for (const auto& Url : Options.Urls) { m_Endpoints.push_back({.Url = Url}); diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 27d322f01..6a42a4044 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -678,7 +678,6 @@ void ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) { using namespace std::literals; - auto ValueOrDefault = [](std::string_view Value, std::string_view Default) { return Value.empty() ? Default : Value; }; ZEN_INFO("instantiating structured cache service"); m_CacheStore = std::make_unique<ZenCacheStore>(m_CasGc, m_DataRoot / "cache"); @@ -722,8 +721,10 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) if (!ZenUrls.empty()) { + const auto ZenEndpointName = UpstreamConfig.ZenConfig.Name.empty() ? "Zen"sv : UpstreamConfig.ZenConfig.Name; + std::unique_ptr<zen::UpstreamEndpoint> ZenEndpoint = - zen::MakeZenUpstreamEndpoint({.Name = "Zen"sv, + zen::MakeZenUpstreamEndpoint({.Name = ZenEndpointName, .Urls = ZenUrls, .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds)}); @@ -737,7 +738,7 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) if (UpstreamConfig.JupiterConfig.UseProductionSettings) { Options = - zen::CloudCacheClientOptions{.Name = "Horde"sv, + zen::CloudCacheClientOptions{.Name = "Jupiter-Prod"sv, .ServiceUrl = "https://jupiter.devtools.epicgames.com"sv, .DdcNamespace = "ue.ddc"sv, .BlobStoreNamespace = "ue.ddc"sv, @@ -751,7 +752,7 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) else if (UpstreamConfig.JupiterConfig.UseDevelopmentSettings) { Options = - zen::CloudCacheClientOptions{.Name = "Horde"sv, + zen::CloudCacheClientOptions{.Name = "Jupiter-Dev"sv, .ServiceUrl = "https://jupiter.devtools-dev.epicgames.com"sv, .DdcNamespace = "ue.ddc"sv, .BlobStoreNamespace = "ue.ddc"sv, @@ -764,16 +765,21 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) } else { - Options = zen::CloudCacheClientOptions{.Name = "UninitializedName"sv}; - } + const auto JupiterEndpointName = + UpstreamConfig.JupiterConfig.Name.empty() ? "Jupiter"sv : UpstreamConfig.JupiterConfig.Name; - Options.ServiceUrl = ValueOrDefault(UpstreamConfig.JupiterConfig.Url, Options.ServiceUrl); - Options.DdcNamespace = ValueOrDefault(UpstreamConfig.JupiterConfig.DdcNamespace, Options.DdcNamespace); - Options.BlobStoreNamespace = ValueOrDefault(UpstreamConfig.JupiterConfig.Namespace, Options.BlobStoreNamespace); - Options.OAuthProvider = ValueOrDefault(UpstreamConfig.JupiterConfig.OAuthProvider, Options.OAuthProvider); - Options.OAuthClientId = ValueOrDefault(UpstreamConfig.JupiterConfig.OAuthClientId, Options.OAuthClientId); - Options.OAuthSecret = ValueOrDefault(UpstreamConfig.JupiterConfig.OAuthClientSecret, Options.OAuthSecret); - Options.UseLegacyDdc |= UpstreamConfig.JupiterConfig.UseLegacyDdc; + Options = + zen::CloudCacheClientOptions{.Name = JupiterEndpointName, + .ServiceUrl = UpstreamConfig.JupiterConfig.Url, + .DdcNamespace = UpstreamConfig.JupiterConfig.DdcNamespace, + .BlobStoreNamespace = UpstreamConfig.JupiterConfig.Namespace, + .OAuthProvider = UpstreamConfig.JupiterConfig.OAuthProvider, + .OAuthClientId = UpstreamConfig.JupiterConfig.OAuthClientId, + .OAuthSecret = UpstreamConfig.JupiterConfig.OAuthClientSecret, + .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), + .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds), + .UseLegacyDdc = false}; + } if (!Options.ServiceUrl.empty()) { |