aboutsummaryrefslogtreecommitdiff
path: root/zenserver/upstream/upstreamcache.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-11-16 21:07:17 +0100
committerPer Larsson <[email protected]>2021-11-16 21:07:17 +0100
commit1fda861670f67b3220fc661e7975f160f99e6aed (patch)
treea8fcdfc18d2e3e4b79bb42ef1d0fc61aff6b9dbf /zenserver/upstream/upstreamcache.cpp
parentMerge branch 'main' of https://github.com/EpicGames/zen (diff)
downloadzen-1fda861670f67b3220fc661e7975f160f99e6aed.tar.xz
zen-1fda861670f67b3220fc661e7975f160f99e6aed.zip
Added upstream connect/transfer timeout options.
Diffstat (limited to 'zenserver/upstream/upstreamcache.cpp')
-rw-r--r--zenserver/upstream/upstreamcache.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp
index 085932685..2741e3e51 100644
--- a/zenserver/upstream/upstreamcache.cpp
+++ b/zenserver/upstream/upstreamcache.cpp
@@ -442,9 +442,13 @@ namespace detail {
};
public:
- ZenUpstreamEndpoint(std::span<std::string const> Urls) : m_Log(zen::logging::Get("upstream")), m_DisplayName("ZEN")
+ ZenUpstreamEndpoint(const ZenClientOptions& Options)
+ : m_Log(zen::logging::Get("upstream"))
+ , m_DisplayName("ZEN")
+ , m_ConnectTimeout(Options.ConnectTimeout)
+ , m_Timeout(Options.Timeout)
{
- for (const auto& Url : Urls)
+ for (const auto& Url : Options.Urls)
{
m_Endpoints.push_back({.Url = Url});
}
@@ -461,7 +465,7 @@ namespace detail {
{
m_ServiceUrl = Ep.Url;
m_DisplayName = "ZEN - {}"_format(m_ServiceUrl);
- m_Client = new ZenStructuredCacheClient(m_ServiceUrl);
+ m_Client = new ZenStructuredCacheClient({.Url = m_ServiceUrl, .ConnectTimeout = m_ConnectTimeout, .Timeout = m_Timeout});
m_HealthOk = true;
return {.Ok = true};
@@ -486,7 +490,8 @@ namespace detail {
{
m_ServiceUrl = Ep.Url;
m_DisplayName = "ZEN - {}"_format(m_ServiceUrl);
- m_Client = new ZenStructuredCacheClient(m_ServiceUrl);
+ m_Client =
+ new ZenStructuredCacheClient({.Url = m_ServiceUrl, .ConnectTimeout = m_ConnectTimeout, .Timeout = m_Timeout});
m_HealthOk = true;
return {.Ok = true};
@@ -825,7 +830,7 @@ namespace detail {
{
for (ZenEndpoint& Ep : m_Endpoints)
{
- ZenStructuredCacheClient Client(Ep.Url);
+ ZenStructuredCacheClient Client({.Url = Ep.Url, .ConnectTimeout = std::chrono::milliseconds(1000)});
ZenStructuredCacheSession Session(Client);
const int32_t SampleCount = 2;
@@ -858,6 +863,8 @@ namespace detail {
std::string m_ServiceUrl;
std::vector<ZenEndpoint> m_Endpoints;
std::string m_DisplayName;
+ std::chrono::milliseconds m_ConnectTimeout;
+ std::chrono::milliseconds m_Timeout;
RefPtr<ZenStructuredCacheClient> m_Client;
UpstreamEndpointStats m_Stats;
std::atomic_bool m_HealthOk{false};
@@ -1347,9 +1354,9 @@ MakeJupiterUpstreamEndpoint(const CloudCacheClientOptions& Options)
}
std::unique_ptr<UpstreamEndpoint>
-MakeZenUpstreamEndpoint(std::span<std::string const> Urls)
+MakeZenUpstreamEndpoint(const ZenClientOptions& Options)
{
- return std::make_unique<detail::ZenUpstreamEndpoint>(Urls);
+ return std::make_unique<detail::ZenUpstreamEndpoint>(Options);
}
} // namespace zen