mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 03:42:48 +00:00
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <IO/ConnectionTimeouts.h>
|
|
#include <Poco/Util/AbstractConfiguration.h>
|
|
#include <Interpreters/Context.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/// Timeouts for the case when we have just single attempt to connect.
|
|
inline ConnectionTimeouts ConnectionTimeouts::getTCPTimeoutsWithoutFailover(const Settings & settings)
|
|
{
|
|
return ConnectionTimeouts(settings.connect_timeout, settings.send_timeout, settings.receive_timeout, settings.tcp_keep_alive_timeout);
|
|
}
|
|
|
|
/// Timeouts for the case when we will try many addresses in a loop.
|
|
inline ConnectionTimeouts ConnectionTimeouts::getTCPTimeoutsWithFailover(const Settings & settings)
|
|
{
|
|
return ConnectionTimeouts(
|
|
settings.connect_timeout_with_failover_ms,
|
|
settings.send_timeout,
|
|
settings.receive_timeout,
|
|
settings.tcp_keep_alive_timeout,
|
|
0,
|
|
settings.connect_timeout_with_failover_secure_ms,
|
|
settings.hedged_connection_timeout_ms,
|
|
settings.receive_data_timeout_ms);
|
|
}
|
|
|
|
inline ConnectionTimeouts ConnectionTimeouts::getHTTPTimeouts(ContextPtr context)
|
|
{
|
|
const auto & settings = context->getSettingsRef();
|
|
const auto & config = context->getConfigRef();
|
|
Poco::Timespan http_keep_alive_timeout{config.getUInt("keep_alive_timeout", 10), 0};
|
|
return ConnectionTimeouts(settings.http_connection_timeout, settings.http_send_timeout, settings.http_receive_timeout, settings.tcp_keep_alive_timeout, http_keep_alive_timeout);
|
|
}
|
|
|
|
}
|