5#include <QtCore/QElapsedTimer>
37 using Action = std::function<bool()>;
53 int resetTimeoutMsecs = 30000);
88 int _failureThreshold;
89 int _resetTimeoutMsecs;
92 int _failureCount = 0;
93 QElapsedTimer _tripTimer;
State circuitState() const
Get the current circuit state.
std::function< bool()> Action
bool isTripped() const
Check if the circuit is currently tripped (open)
void tripped()
Emitted when the circuit trips (too many failures)
int failureCount() const
Get the current failure count.
void succeeded()
Emitted when action succeeds.
void failed()
Emitted when action fails (or circuit is open)
void reset()
Manually reset the circuit breaker.
void onEnter() override
Override to perform actions on state entry.
int failureThreshold() const
Get the failure threshold.
void circuitReset()
Emitted when the circuit resets (after successful half-open test)
@ Closed
Normal operation.
@ Open
Tripped, failing fast.
@ HalfOpen
Testing if service recovered.
QString stateName() const