1#pragma once
2
3#include <Poco/Net/StreamSocket.h>
4#include <Poco/Timespan.h>
5
6
7namespace DB
8{
9/// Temporarily overrides socket send/receive timeouts and reset them back into destructor
10/// If "limit_max_timeout" is true, timeouts could be only decreased (maxed by previous value).
11struct TimeoutSetter
12{
13 TimeoutSetter(Poco::Net::StreamSocket & socket_,
14 const Poco::Timespan & send_timeout_,
15 const Poco::Timespan & receive_timeout_,
16 bool limit_max_timeout = false);
17
18 TimeoutSetter(Poco::Net::StreamSocket & socket_, const Poco::Timespan & timeout_, bool limit_max_timeout = false);
19
20 ~TimeoutSetter();
21
22 Poco::Net::StreamSocket & socket;
23
24 Poco::Timespan send_timeout;
25 Poco::Timespan receive_timeout;
26
27 Poco::Timespan old_send_timeout;
28 Poco::Timespan old_receive_timeout;
29};
30}
31