From d026688539e207f74819f3338085d92fed4ba9fe Mon Sep 17 00:00:00 2001 From: saipubw Date: Fri, 19 Jul 2024 13:36:32 +0800 Subject: [PATCH] [coro_rpc][coro_http] set default timout as 30s (#720) --- include/ylt/coro_io/client_pool.hpp | 3 +-- include/ylt/coro_rpc/impl/coro_rpc_client.hpp | 17 +++++++++-------- .../ylt/standalone/cinatra/coro_http_client.hpp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/ylt/coro_io/client_pool.hpp b/include/ylt/coro_io/client_pool.hpp index efb2f111d..a67c9008c 100644 --- a/include/ylt/coro_io/client_pool.hpp +++ b/include/ylt/coro_io/client_pool.hpp @@ -121,7 +121,7 @@ class client_pool : public std::enable_shared_from_this< do { ELOG_TRACE << "try to reconnect client{" << client.get() << "},host:{" << client->get_host() << ":" << client->get_port() - << "}, try count:" << i << "max retry limit:" + << "}, try count:" << i + 1 << "max retry limit:" << self->pool_config_.connect_retry_count; auto pre_time_point = std::chrono::steady_clock::now(); bool ok = client_t::is_ok(co_await client->connect(self->host_name_)); @@ -245,7 +245,6 @@ class client_pool : public std::enable_shared_from_this< std::chrono::milliseconds reconnect_wait_time{1000}; std::chrono::milliseconds idle_timeout{30000}; std::chrono::milliseconds short_connect_idle_timeout{1000}; - std::chrono::milliseconds max_connection_time{60000}; typename client_t::config client_config; }; diff --git a/include/ylt/coro_rpc/impl/coro_rpc_client.hpp b/include/ylt/coro_rpc/impl/coro_rpc_client.hpp index 93b6cdf66..e84b09f6c 100644 --- a/include/ylt/coro_rpc/impl/coro_rpc_client.hpp +++ b/include/ylt/coro_rpc/impl/coro_rpc_client.hpp @@ -162,7 +162,7 @@ class coro_rpc_client { struct config { uint64_t client_id = get_global_client_id(); std::chrono::milliseconds timeout_duration = - std::chrono::milliseconds{5000}; + std::chrono::milliseconds{30000}; std::string host; std::string port; bool enable_tcp_no_delay = true; @@ -234,7 +234,7 @@ class coro_rpc_client { [[nodiscard]] async_simple::coro::Lazy connect( std::string host, std::string port, std::chrono::steady_clock::duration timeout_duration = - std::chrono::seconds(5)) { + std::chrono::seconds(30)) { auto lock_ok = connect_mutex_.tryLock(); if (!lock_ok) { co_await connect_mutex_.coScopedLock(); @@ -252,7 +252,7 @@ class coro_rpc_client { [[nodiscard]] async_simple::coro::Lazy connect( std::string_view endpoint, std::chrono::steady_clock::duration timeout_duration = - std::chrono::seconds(5)) { + std::chrono::seconds(30)) { auto pos = endpoint.find(':'); auto lock_ok = connect_mutex_.tryLock(); if (!lock_ok) { @@ -296,7 +296,7 @@ class coro_rpc_client { ~coro_rpc_client() { close(); } /*! - * Call RPC function with default timeout (5 second) + * Call RPC function with default timeout (30 second) * * @tparam func the address of RPC function * @tparam Args the type of arguments @@ -306,7 +306,8 @@ class coro_rpc_client { template async_simple::coro::Lazy())>> call( Args &&...args) { - return call_for(std::chrono::seconds(5), std::forward(args)...); + return call_for(std::chrono::seconds(30), + std::forward(args)...); } /*! @@ -919,7 +920,7 @@ class coro_rpc_client { async_simple::coro::Lazy())>>> send_request(Args &&...args) { - return send_request_for_with_attachment(std::chrono::seconds{5}, {}, + return send_request_for_with_attachment(std::chrono::seconds{30}, {}, std::forward(args)...); } @@ -928,7 +929,7 @@ class coro_rpc_client { async_rpc_result())>>> send_request_with_attachment(std::string_view request_attachment, Args &&...args) { - return send_request_for_with_attachment(std::chrono::seconds{5}, + return send_request_for_with_attachment(std::chrono::seconds{30}, request_attachment, std::forward(args)...); } @@ -937,7 +938,7 @@ class coro_rpc_client { async_simple::coro::Lazy())>>> send_request_for(Args &&...args) { - return send_request_for_with_attachment(std::chrono::seconds{5}, + return send_request_for_with_attachment(std::chrono::seconds{30}, std::string_view{}, std::forward(args)...); } diff --git a/include/ylt/standalone/cinatra/coro_http_client.hpp b/include/ylt/standalone/cinatra/coro_http_client.hpp index 7473c7ded..063ccb687 100644 --- a/include/ylt/standalone/cinatra/coro_http_client.hpp +++ b/include/ylt/standalone/cinatra/coro_http_client.hpp @@ -2424,7 +2424,7 @@ class coro_http_client : public std::enable_shared_from_this { bool enable_follow_redirect_ = false; bool enable_timeout_ = false; std::chrono::steady_clock::duration conn_timeout_duration_ = - std::chrono::seconds(8); + std::chrono::seconds(30); std::chrono::steady_clock::duration req_timeout_duration_ = std::chrono::seconds(60); bool enable_tcp_no_delay_ = true;