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

Open the circuit breaker if a number of failures happen over a time intervall. More...

#include <countstrategy.hpp>

Inheritance diagram for resilient::CountStrategy< Clock >:
[legend]

Public Member Functions

 CountStrategy (unsigned long failures, std::chrono::microseconds failureInterval, std::chrono::microseconds tripDuration, unsigned long recoverSuccesses, Clock clock=Clock())
 Construct a new Count Strategy object. More...
 
bool allowCall () override
 Check whether the next call should be execute or should short circuit to failure. More...
 
void registerFailure () override
 Notify the algorithm that an execution resulted in failure.
 
void registerSuccess () override
 Notify the algorithm that an execution resulted in success.
 

Detailed Description

template<typename Clock = std::chrono::steady_clock>
class resilient::CountStrategy< Clock >

Open the circuit breaker if a number of failures happen over a time intervall.

Template Parameters
ClockThe kind of clock to use when measuring time.

Constructor & Destructor Documentation

template<typename Clock >
resilient::CountStrategy< Clock >::CountStrategy ( unsigned long  failures,
std::chrono::microseconds  failureInterval,
std::chrono::microseconds  tripDuration,
unsigned long  recoverSuccesses,
Clock  clock = Clock() 
)

Construct a new Count Strategy object.

Parameters
failuresNumber of failures over the interval which will trigger the circuit breaker.
failureIntervalThe duration of the interval over which to count the failures.
tripDurationHow long to keep the circuit breaker open once it trips.
recoverSuccessesHow many task executions should succeed before resetting the circuit breaker to it's normal state after it triggered.
clockAn instance of the clock to use to measure time. Defaults to a default initialized one.

Member Function Documentation

template<typename Clock = std::chrono::steady_clock>
bool resilient::CountStrategy< Clock >::allowCall ( )
inlineoverridevirtual

Check whether the next call should be execute or should short circuit to failure.

Returns
true Execute the task.
false Return failure instead of executing the task.

Implements resilient::ICircuitbreakerStrategy.


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