Template Class conservative_strategy¶
Defined in File pool_strategy.hpp
Inheritance Relationships¶
Base Type¶
public stream_client::connector::pool_strategy< Connector >
(Template Class pool_strategy)
Class Documentation¶
-
template<typename
Connector
>
classstream_client::connector
::
conservative_strategy
: public stream_client::connector::pool_strategy<Connector>¶ Conservative strategy.
Will try to refill up to 2/3 of vacant places in the pool. If failed will back off with delay and try to add only one new session.
Public Types
-
using
connector_type
= typename pool_strategy<Connector>::connector_type¶
-
using
stream_type
= typename pool_strategy<Connector>::stream_type¶
-
using
append_func_type
= typename pool_strategy<Connector>::append_func_type¶
-
using
clock_type
= typename connector_type::clock_type¶
-
using
time_duration_type
= typename connector_type::time_duration_type¶
-
using
time_point_type
= typename connector_type::time_point_type¶
Public Functions
-
conservative_strategy
(unsigned long first_delay_ms = kDefaultDelayMs, unsigned delay_multiplier = kDefaultDelayMul)¶ Creates conservative strategy with specified delay and multiplier.
Strategy allows to add new sessions with increasing delays upon failures.
- Parameters
first_delay_ms – Initial delay to use.
delay_multiplier – Multiply delay by this number each time we fail. Should be >= 1
-
virtual
~conservative_strategy
() = default¶ Destructor.
-
virtual bool
refill
(connector_type &connector, std::size_t vacant_places, append_func_type append_func) override¶ Adds up to 2/3 of
vacant_places
sessions viaconnector
simultaneously.On failures will set a delay and until it is passed will do nothing. Also, will add only one session if previously failed.
Delay initially set to
first_delay_ms
and multiplied by random number in [1..delay_multiplier
) interval on each fail.- Parameters
connector – Connector to use for new sessions.
vacant_places – Number of required connection to fulfill the pool.
append_func – Function is used to add new session to the pool.
- Returns
true if added at least one session; false if failed or wait time is not reached.
-
using