A retry mechanism.
More...
#include <Retry.hpp>
|
| | Retry (RetryStrategyPtr strategy, boost::asio::strand< boost::asio::io_context::executor_type > strand) |
| | Construct a new Retry object.
|
| | Retry (RetryStrategyPtr strategy, boost::asio::any_io_executor executor) |
| | Construct a new Retry object from any I/O executor.
|
|
| ~Retry () |
| | Destroy the Retry object.
|
| template<typename Fn> |
| void | retry (Fn &&func) |
| | Schedule a retry.
|
| void | wait (boost::asio::yield_context yield) |
| | Wait out the current delay by suspending the calling coroutine, then back off.
|
|
void | cancel () |
| | Cancel scheduled retry if any.
|
| size_t | attemptNumber () const |
| std::chrono::steady_clock::duration | delayValue () const |
|
void | reset () |
| | Reset the delay value and attempt number.
|
◆ Retry() [1/2]
| util::Retry::Retry |
( |
RetryStrategyPtr | strategy, |
|
|
boost::asio::strand< boost::asio::io_context::executor_type > | strand ) |
Construct a new Retry object.
- Parameters
-
| strategy | The retry strategy to use |
| strand | The strand to use for async operations |
◆ Retry() [2/2]
| util::Retry::Retry |
( |
RetryStrategyPtr | strategy, |
|
|
boost::asio::any_io_executor | executor ) |
Construct a new Retry object from any I/O executor.
For coroutines, pass yield.get_executor() and drive it with wait().
- Parameters
-
| strategy | The retry strategy to use |
| executor | The executor to run the retry timer on |
◆ attemptNumber()
| size_t util::Retry::attemptNumber |
( |
| ) |
const |
|
nodiscard |
- Returns
- The current attempt number
◆ delayValue()
| std::chrono::steady_clock::duration util::Retry::delayValue |
( |
| ) |
const |
|
nodiscard |
- Returns
- The current delay value
◆ retry()
template<typename Fn>
| void util::Retry::retry |
( |
Fn && | func | ) |
|
|
inline |
Schedule a retry.
- Template Parameters
-
| Fn | The type of the callable to execute |
- Parameters
-
| func | The callable to execute |
◆ wait()
| void util::Retry::wait |
( |
boost::asio::yield_context | yield | ) |
|
Wait out the current delay by suspending the calling coroutine, then back off.
Unlike retry() this returns once the delay elapsed instead of scheduling a callback, so the caller can keep its own loop. Advances the delay and attempt number like retry().
- Parameters
-
| yield | The coroutine to suspend |
The documentation for this class was generated from the following files:
- /__w/clio/clio/src/util/Retry.hpp
- /__w/clio/clio/src/util/Retry.cpp