Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::Retry Class Reference

A retry mechanism. More...

#include <Retry.hpp>

Classes

struct  Delays
 The delays to use between retry attempts. More...

Public Member Functions

 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.

Detailed Description

A retry mechanism.

Constructor & Destructor Documentation

◆ Retry() [1/2]

util::Retry::Retry ( RetryStrategyPtr strategy,
boost::asio::strand< boost::asio::io_context::executor_type > strand )

Construct a new Retry object.

Parameters
strategyThe retry strategy to use
strandThe 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
strategyThe retry strategy to use
executorThe executor to run the retry timer on

Member Function Documentation

◆ 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
FnThe type of the callable to execute
Parameters
funcThe 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
yieldThe 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