Resilient
Public Member Functions | List of all members
resilient::Circuitbreaker Class Reference

Fail-fast when tasks are consistently failing. More...

#include <circuitbreaker.hpp>

Public Member Functions

 Circuitbreaker (std::unique_ptr< ICircuitbreakerStrategy > &&strategy)
 Construct a Circuitbreaker with the given strategy.
 
template<typename Callable , typename... Args>
return_type_t< Callable, Args... > execute (Callable &&callable, Args &&...args)
 Execute the task if the Circuitbreaker is not open. More...
 

Detailed Description

Fail-fast when tasks are consistently failing.

A missbehaving dependency might take a long time to respond. When many operations depend on it the slowdown can be propagated to the rest of the system.

The Circuitbreaker uses an algorithm (implemented in the strategy) to determine when to stop contacting the dependency and just assume a failure.

This keeps limit the performance impact a dependency can cause to the whole system.

Member Function Documentation

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

Execute the task if the Circuitbreaker is not open.

Parameters
callableThe task to execute
args...The arguments to the task
Returns
The result of invoking the task, or CircuitbreakerIsOpen if the task was not executed.

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