aboutsummaryrefslogtreecommitdiff
path: root/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-01-24 11:11:10 +0100
committerPer Larsson <[email protected]>2022-01-24 11:11:10 +0100
commitdc6becffb513280170958f94e18c1b2966ade4d1 (patch)
treec7f9cccafcc21e241abdecde6f5219ab1009aff6 /zenserver/zenserver.cpp
parentFormat fix. (diff)
downloadzen-dc6becffb513280170958f94e18c1b2966ade4d1.tar.xz
zen-dc6becffb513280170958f94e18c1b2966ade4d1.zip
Refactored upstream cache to better handle different states in prep for dynamic auth tokens.
Diffstat (limited to 'zenserver/zenserver.cpp')
-rw-r--r--zenserver/zenserver.cpp78
1 files changed, 35 insertions, 43 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index 60691222b..b8648c8ee 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -99,6 +99,7 @@ ZEN_THIRD_PARTY_INCLUDES_END
//
#include "admin/admin.h"
+#include "auth/authservice.h"
#include "cache/structuredcache.h"
#include "cache/structuredcachestore.h"
#include "compute/apply.h"
@@ -110,9 +111,7 @@ ZEN_THIRD_PARTY_INCLUDES_END
#include "projectstore.h"
#include "testing/httptest.h"
#include "testing/launch.h"
-#include "upstream/jupiter.h"
-#include "upstream/upstreamcache.h"
-#include "upstream/zen.h"
+#include "upstream/upstream.h"
#include "zenstore/gc.h"
#include "zenstore/scrub.h"
@@ -203,6 +202,10 @@ public:
m_Http = zen::CreateHttpServer(ServerOptions.HttpServerClass);
m_Http->Initialize(ServerOptions.BasePort);
+
+ m_AuthService = std::make_unique<zen::HttpAuthService>();
+ m_Http->RegisterService(*m_AuthService);
+
m_Http->RegisterService(m_HealthService);
m_Http->RegisterService(m_StatsService);
m_Http->RegisterService(m_StatusService);
@@ -278,11 +281,6 @@ public:
m_Http->RegisterService(m_CasService);
- if (m_StructuredCacheService)
- {
- m_Http->RegisterService(*m_StructuredCacheService);
- }
-
#if ZEN_WITH_COMPUTE_SERVICES
if (m_HttpLaunchService)
{
@@ -529,6 +527,7 @@ private:
}
zen::Ref<zen::HttpServer> m_Http;
+ std::unique_ptr<zen::HttpAuthService> m_AuthService;
zen::HttpStatusService m_StatusService;
zen::HttpStatsService m_StatsService;
zen::CasGc m_CasGc;
@@ -543,6 +542,8 @@ private:
zen::RefPtr<zen::ProjectStore> m_ProjectStore;
zen::Ref<zen::LocalProjectService> m_LocalProjectService;
std::unique_ptr<zen::HttpProjectService> m_HttpProjectService;
+ std::unique_ptr<zen::UpstreamCache> m_UpstreamCache;
+ std::unique_ptr<zen::HttpUpstreamService> m_UpstreamService;
std::unique_ptr<zen::HttpStructuredCacheService> m_StructuredCacheService;
zen::HttpAdminService m_AdminService{m_GcScheduler};
zen::HttpHealthService m_HealthService;
@@ -682,24 +683,23 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
ZEN_INFO("instantiating structured cache service");
m_CacheStore = std::make_unique<ZenCacheStore>(m_CasGc, m_DataRoot / "cache");
- std::unique_ptr<zen::UpstreamCache> UpstreamCache;
- if (ServerOptions.UpstreamCacheConfig.CachePolicy != UpstreamCachePolicy::Disabled)
- {
- const ZenUpstreamCacheConfig& UpstreamConfig = ServerOptions.UpstreamCacheConfig;
-
- zen::UpstreamCacheOptions UpstreamOptions;
- UpstreamOptions.ReadUpstream = (uint8_t(ServerOptions.UpstreamCacheConfig.CachePolicy) & uint8_t(UpstreamCachePolicy::Read)) != 0;
- UpstreamOptions.WriteUpstream = (uint8_t(ServerOptions.UpstreamCacheConfig.CachePolicy) & uint8_t(UpstreamCachePolicy::Write)) != 0;
+ const ZenUpstreamCacheConfig& UpstreamConfig = ServerOptions.UpstreamCacheConfig;
- if (UpstreamConfig.UpstreamThreadCount < 32)
- {
- UpstreamOptions.ThreadCount = static_cast<uint32_t>(UpstreamConfig.UpstreamThreadCount);
- }
+ zen::UpstreamCacheOptions UpstreamOptions;
+ UpstreamOptions.ReadUpstream = (uint8_t(ServerOptions.UpstreamCacheConfig.CachePolicy) & uint8_t(UpstreamCachePolicy::Read)) != 0;
+ UpstreamOptions.WriteUpstream = (uint8_t(ServerOptions.UpstreamCacheConfig.CachePolicy) & uint8_t(UpstreamCachePolicy::Write)) != 0;
- UpstreamOptions.StatsEnabled = UpstreamConfig.StatsEnabled;
+ if (UpstreamConfig.UpstreamThreadCount < 32)
+ {
+ UpstreamOptions.ThreadCount = static_cast<uint32_t>(UpstreamConfig.UpstreamThreadCount);
+ }
- UpstreamCache = zen::MakeUpstreamCache(UpstreamOptions, *m_CacheStore, *m_CidStore);
+ m_UpstreamCache = zen::MakeUpstreamCache(UpstreamOptions, *m_CacheStore, *m_CidStore);
+ m_UpstreamService = std::make_unique<HttpUpstreamService>(*m_UpstreamCache);
+ m_UpstreamCache->Initialize();
+ if (ServerOptions.UpstreamCacheConfig.CachePolicy != UpstreamCachePolicy::Disabled)
+ {
// Zen upstream
{
std::vector<std::string> ZenUrls = UpstreamConfig.ZenConfig.Urls;
@@ -723,10 +723,11 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
if (!ZenUrls.empty())
{
std::unique_ptr<zen::UpstreamEndpoint> ZenEndpoint =
- zen::MakeZenUpstreamEndpoint({.Urls = ZenUrls,
+ zen::MakeZenUpstreamEndpoint({.Name = "Zen"sv,
+ .Urls = ZenUrls,
.ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds),
.Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds)});
- UpstreamCache->RegisterEndpoint(std::move(ZenEndpoint));
+ m_UpstreamCache->RegisterEndpoint(std::move(ZenEndpoint));
}
}
@@ -736,7 +737,8 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
if (UpstreamConfig.JupiterConfig.UseProductionSettings)
{
Options =
- zen::CloudCacheClientOptions{.ServiceUrl = "https://jupiter.devtools.epicgames.com"sv,
+ zen::CloudCacheClientOptions{.Name = "Horde"sv,
+ .ServiceUrl = "https://jupiter.devtools.epicgames.com"sv,
.DdcNamespace = "ue.ddc"sv,
.BlobStoreNamespace = "ue.ddc"sv,
.OAuthProvider = "https://epicgames.okta.com/oauth2/auso645ojjWVdRI3d0x7/v1/token"sv,
@@ -749,7 +751,8 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
else if (UpstreamConfig.JupiterConfig.UseDevelopmentSettings)
{
Options =
- zen::CloudCacheClientOptions{.ServiceUrl = "https://jupiter.devtools-dev.epicgames.com"sv,
+ zen::CloudCacheClientOptions{.Name = "Horde"sv,
+ .ServiceUrl = "https://jupiter.devtools-dev.epicgames.com"sv,
.DdcNamespace = "ue.ddc"sv,
.BlobStoreNamespace = "ue.ddc"sv,
.OAuthProvider = "https://epicgames.okta.com/oauth2/auso645ojjWVdRI3d0x7/v1/token"sv,
@@ -771,27 +774,16 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
if (!Options.ServiceUrl.empty())
{
std::unique_ptr<zen::UpstreamEndpoint> JupiterEndpoint = zen::MakeJupiterUpstreamEndpoint(Options);
- UpstreamCache->RegisterEndpoint(std::move(JupiterEndpoint));
+ m_UpstreamCache->RegisterEndpoint(std::move(JupiterEndpoint));
}
}
-
- if (UpstreamCache->Initialize())
- {
- ZEN_INFO("upstream cache active ({})",
- UpstreamOptions.ReadUpstream && UpstreamOptions.WriteUpstream ? "READ|WRITE"
- : UpstreamOptions.ReadUpstream ? "READONLY"
- : UpstreamOptions.WriteUpstream ? "WRITEONLY"
- : "DISABLED");
- }
- else
- {
- UpstreamCache.reset();
- ZEN_INFO("NOT using upstream cache");
- }
}
- m_StructuredCacheService.reset(
- new zen::HttpStructuredCacheService(*m_CacheStore, *m_CidStore, m_StatsService, m_StatusService, std::move(UpstreamCache)));
+ m_StructuredCacheService =
+ std::make_unique<HttpStructuredCacheService>(*m_CacheStore, *m_CidStore, m_StatsService, m_StatusService, *m_UpstreamCache);
+
+ m_Http->RegisterService(*m_StructuredCacheService);
+ m_Http->RegisterService(*m_UpstreamService);
}
////////////////////////////////////////////////////////////////////////////////