#include <ozo/failover/retry.h>
Retry strategy.
Retry strategy is a factory for ozo::fallback::basic_try
object. This class is an options' factory (see ozo::options_factory_base
).
Public Member Functions | |
constexpr | retry_strategy (Options options=Options{}) |
Construct a new retry strategy object. More... | |
template<typename Operation , typename Allocator , typename ConnectionProvider , typename TimeConstraint , typename ... Args> | |
auto | get_first_try (const Operation &, const Allocator &, ConnectionProvider &&provider, TimeConstraint t, Args &&...args) const |
Get the first try object. More... | |
constexpr decltype(auto) | tries (int n) const & |
Specify number of tries. More... | |
constexpr int | get_tries () const |
Number of maximum tries count are setted with ozo::retry_strategy::tries() More... | |
constexpr auto | get_conditions () const |
Retry error conditions of the strategy. More... | |
constexpr decltype(auto) | operator* (int n) const & |
Sintactic sugar for ozo::retry_strategy::tries() More... | |
![]() | |
constexpr | options_factory_base (decltype(hana::make_map()) v) |
constexpr decltype(auto) | set (decltype(hana::make_map()) &&...options) && |
constexpr auto | has (ozo::option< Key > op) const |
constexpr decltype(auto) | get (ozo::option< Key > op) const |
constexpr const decltype(hana::make_map()) & | options () const & |
constexpr decltype(hana::make_map()) & | options () & |
constexpr decltype(hana::make_map()) && | options () && |
Friends | |
class | ozo::options_factory_base< retry_strategy< Options >, Options > |
|
constexpr |
Construct a new retry strategy object.
options | — boost::hana::map of ozo::failover::retry_options and values. |
|
constexpr |
Retry error conditions of the strategy.
boost::hana::tuple
— tuple of retryable error conditions setted for this strategy. References ozo::failover::retry_options::conditions, and ozo::options_factory_base< retry_strategy< decltype(hana::make_map()) >, decltype(hana::make_map()) >::get().
auto ozo::failover::retry_strategy< Options >::get_first_try | ( | const Operation & | , |
const Allocator & | , | ||
ConnectionProvider && | provider, | ||
TimeConstraint | t, | ||
Args &&... | args | ||
) | const |
Get the first try object.
Default implementation for ozo::fallback::get_first_try()
failover strategy interface function.
alloc | — allocator which should be used for try context. |
args | — operation arguments. |
References ozo::deadline(), ozo::options_factory_base< retry_strategy< decltype(hana::make_map()) >, decltype(hana::make_map()) >::has(), ozo::options_factory_base< retry_strategy< decltype(hana::make_map()) >, decltype(hana::make_map()) >::options(), and ozo::failover::retry_options::tries.
|
constexpr |
Number of maximum tries count are setted with ozo::retry_strategy::tries()
References ozo::options_factory_base< retry_strategy< decltype(hana::make_map()) >, decltype(hana::make_map()) >::get(), and ozo::failover::retry_options::tries.
|
constexpr |
Sintactic sugar for ozo::retry_strategy::tries()
n | — number of tries |
retry_strategy
specialization object References ozo::failover::retry_strategy< Options >::tries().
|
constexpr |
Specify number of tries.
Specify number of tries for an operation.
n | — number of tries |
retry_strategy
specialization objectIf operation has time constraint T
each try would have its own time constraint according to the rule, there ti — actual time of ith try:
Try number | Time constraint |
---|---|
1 | T /n |
2 | (T - t1) / (n - 1) |
3 | (T - (t1 + t2)) / (n - 2) |
... | |
N | (T - (t1 + t2 + ... + tn-1))) |
Retry on a network problem and operation timed-out no more than 3 tries. Each try has own time duration constraint calculated as:
References ozo::options_factory_base< retry_strategy< decltype(hana::make_map()) >, decltype(hana::make_map()) >::set(), and ozo::failover::retry_options::tries.
Referenced by ozo::failover::retry_strategy< Options >::operator*().