Resilient
Public Member Functions | List of all members
resilient::Ratelimiter< Strategy > Class Template Reference

Execute a Task limiting the times it can be executed following a strategy. More...

#include <ratelimiter.hpp>

Public Member Functions

 Ratelimiter (std::unique_ptr< Strategy > strategy)
 Construct a Ratelimiter with the provided strategy. More...
 
template<typename Callable , typename... Args>
return_type_t< Callable, Args... > execute (Callable &&callable, Args &&...args)
 Execute the task, using the strategy to ensure that the rate limit is satisfied. More...
 

Detailed Description

template<typename Strategy>
class resilient::Ratelimiter< Strategy >

Execute a Task limiting the times it can be executed following a strategy.

A rate limiter distributes executions over time to guarantee that they stay below a specific rate. Ratelimiter uses a strategy, which is an implementation of a rate limiting algorithm, to execute the provided Task.

Template Parameters
Strategythe strategy to use. Must derive from IRateLimiterStrategy.

Constructor & Destructor Documentation

template<typename Strategy >
resilient::Ratelimiter< Strategy >::Ratelimiter ( std::unique_ptr< Strategy >  strategy)
inline

Construct a Ratelimiter with the provided strategy.

Parameters
strategyA pointer to the strategy to use.

Member Function Documentation

template<typename Strategy >
template<typename Callable , typename... Args>
return_type_t<Callable, Args...> resilient::Ratelimiter< Strategy >::execute ( Callable &&  callable,
Args &&...  args 
)
inline

Execute the task, using the strategy to ensure that the rate limit is satisfied.

Parameters
callableThe task to execute
args...The arguments to the task
Returns
The result of invoking the task with the arguments

The documentation for this class was generated from the following file: