diff options
| author | Per Larsson <[email protected]> | 2021-11-16 21:07:17 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-11-16 21:07:17 +0100 |
| commit | 1fda861670f67b3220fc661e7975f160f99e6aed (patch) | |
| tree | a8fcdfc18d2e3e4b79bb42ef1d0fc61aff6b9dbf /zenserver/upstream/zen.cpp | |
| parent | Merge branch 'main' of https://github.com/EpicGames/zen (diff) | |
| download | zen-1fda861670f67b3220fc661e7975f160f99e6aed.tar.xz zen-1fda861670f67b3220fc661e7975f160f99e6aed.zip | |
Added upstream connect/transfer timeout options.
Diffstat (limited to 'zenserver/upstream/zen.cpp')
| -rw-r--r-- | zenserver/upstream/zen.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/zenserver/upstream/zen.cpp b/zenserver/upstream/zen.cpp index 9ba767098..3e5a42c22 100644 --- a/zenserver/upstream/zen.cpp +++ b/zenserver/upstream/zen.cpp @@ -313,6 +313,15 @@ namespace detail { void Reset() {} + cpr::Session& GetSession() + { + OwnerClient.InitializeSessionState(*this); + return Session; + } + + private: + friend class ZenStructuredCacheClient; + ZenStructuredCacheClient& OwnerClient; cpr::Session Session; }; @@ -321,9 +330,11 @@ namespace detail { ////////////////////////////////////////////////////////////////////////// -ZenStructuredCacheClient::ZenStructuredCacheClient(std::string_view ServiceUrl) +ZenStructuredCacheClient::ZenStructuredCacheClient(const ZenClientOptions& Options) : m_Log(logging::Get(std::string_view("zenclient"))) -, m_ServiceUrl(ServiceUrl) +, m_ServiceUrl(Options.Url) +, m_ConnectTimeout(Options.ConnectTimeout) +, m_Timeout(Options.Timeout) { } @@ -359,6 +370,13 @@ ZenStructuredCacheClient::FreeSessionState(detail::ZenCacheSessionState* State) m_SessionStateCache.push_front(State); } +void +ZenStructuredCacheClient::InitializeSessionState(detail::ZenCacheSessionState& State) +{ + State.Session.SetConnectTimeout(m_ConnectTimeout); + State.Session.SetTimeout(m_Timeout); +} + ////////////////////////////////////////////////////////////////////////// using namespace std::literals; @@ -381,7 +399,7 @@ ZenStructuredCacheSession::CheckHealth() ExtendableStringBuilder<256> Uri; Uri << m_Client.ServiceUrl() << "/health/check"; - cpr::Session& Session = m_SessionState->Session; + cpr::Session& Session = m_SessionState->GetSession(); Session.SetOption(cpr::Url{Uri.c_str()}); cpr::Response Response = Session.Get(); @@ -399,7 +417,7 @@ ZenStructuredCacheSession::GetCacheRecord(std::string_view BucketId, const IoHas ExtendableStringBuilder<256> Uri; Uri << m_Client.ServiceUrl() << "/z$/" << BucketId << "/" << Key.ToHexString(); - cpr::Session& Session = m_SessionState->Session; + cpr::Session& Session = m_SessionState->GetSession(); Session.SetOption(cpr::Url{Uri.c_str()}); Session.SetHeader(cpr::Header{{"Accept", @@ -427,7 +445,7 @@ ZenStructuredCacheSession::GetCachePayload(std::string_view BucketId, const IoHa ExtendableStringBuilder<256> Uri; Uri << m_Client.ServiceUrl() << "/z$/" << BucketId << "/" << Key.ToHexString() << "/" << PayloadId.ToHexString(); - cpr::Session& Session = m_SessionState->Session; + cpr::Session& Session = m_SessionState->GetSession(); Session.SetOption(cpr::Url{Uri.c_str()}); Session.SetHeader(cpr::Header{{"Accept", "application/x-ue-comp"}}); @@ -452,7 +470,7 @@ ZenStructuredCacheSession::PutCacheRecord(std::string_view BucketId, const IoHas ExtendableStringBuilder<256> Uri; Uri << m_Client.ServiceUrl() << "/z$/" << BucketId << "/" << Key.ToHexString(); - cpr::Session& Session = m_SessionState->Session; + cpr::Session& Session = m_SessionState->GetSession(); Session.SetOption(cpr::Url{Uri.c_str()}); Session.SetHeader(cpr::Header{{"Content-Type", @@ -480,7 +498,7 @@ ZenStructuredCacheSession::PutCachePayload(std::string_view BucketId, const IoHa ExtendableStringBuilder<256> Uri; Uri << m_Client.ServiceUrl() << "/z$/" << BucketId << "/" << Key.ToHexString() << "/" << PayloadId.ToHexString(); - cpr::Session& Session = m_SessionState->Session; + cpr::Session& Session = m_SessionState->GetSession(); Session.SetOption(cpr::Url{Uri.c_str()}); Session.SetHeader(cpr::Header{{"Content-Type", "application/x-ue-comp"}}); @@ -508,7 +526,7 @@ ZenStructuredCacheSession::InvokeRpc(const CbObjectView& Request) BinaryWriter Body; Request.CopyTo(Body); - cpr::Session& Session = m_SessionState->Session; + cpr::Session& Session = m_SessionState->GetSession(); Session.SetOption(cpr::Url{Uri.c_str()}); Session.SetHeader(cpr::Header{{"Content-Type", "application/x-ue-cb"}, {"Accept", "application/x-ue-cbpkg"}}); |