diff options
| author | Per Larsson <[email protected]> | 2021-11-17 12:21:28 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-11-17 12:21:28 +0100 |
| commit | f45fb6c13407e98434db255b36e3cff402387588 (patch) | |
| tree | 91a1078a6ad62ba940bf7bab17c743fb4eeddc8b /zenserver/upstream/zen.cpp | |
| parent | Format fix. (diff) | |
| download | zen-f45fb6c13407e98434db255b36e3cff402387588.tar.xz zen-f45fb6c13407e98434db255b36e3cff402387588.zip | |
Added connect/transfer timeout options for Jupiter client.
Diffstat (limited to 'zenserver/upstream/zen.cpp')
| -rw-r--r-- | zenserver/upstream/zen.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/zenserver/upstream/zen.cpp b/zenserver/upstream/zen.cpp index 3e5a42c22..cd7f48334 100644 --- a/zenserver/upstream/zen.cpp +++ b/zenserver/upstream/zen.cpp @@ -311,17 +311,17 @@ namespace detail { ZenCacheSessionState(ZenStructuredCacheClient& Client) : OwnerClient(Client) {} ~ZenCacheSessionState() {} - void Reset() {} - - cpr::Session& GetSession() + void Reset(std::chrono::milliseconds ConnectTimeout, std::chrono::milliseconds Timeout) { - OwnerClient.InitializeSessionState(*this); - return Session; + Session.SetBody({}); + Session.SetHeader({}); + Session.SetConnectTimeout(ConnectTimeout); + Session.SetTimeout(Timeout); } - private: - friend class ZenStructuredCacheClient; + cpr::Session& GetSession() { return Session; } + private: ZenStructuredCacheClient& OwnerClient; cpr::Session Session; }; @@ -330,7 +330,7 @@ namespace detail { ////////////////////////////////////////////////////////////////////////// -ZenStructuredCacheClient::ZenStructuredCacheClient(const ZenClientOptions& Options) +ZenStructuredCacheClient::ZenStructuredCacheClient(const ZenStructuredCacheClientOptions& Options) : m_Log(logging::Get(std::string_view("zenclient"))) , m_ServiceUrl(Options.Url) , m_ConnectTimeout(Options.ConnectTimeout) @@ -358,7 +358,7 @@ ZenStructuredCacheClient::AllocSessionState() State = new detail::ZenCacheSessionState(*this); } - State->Reset(); + State->Reset(m_ConnectTimeout, m_Timeout); return State; } @@ -370,13 +370,6 @@ 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; |