Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
kcenon::common::resilience Namespace Reference

Classes

class  circuit_breaker
 Thread-safe circuit breaker for fault tolerance. More...
 
struct  circuit_breaker_config
 Configuration parameters for circuit breaker. More...
 
class  failure_window
 Thread-safe sliding window for failure tracking. More...
 

Enumerations

enum class  circuit_state { CLOSED , OPEN , HALF_OPEN }
 Represents the current state of a circuit breaker. More...
 

Functions

auto to_string (circuit_state state) -> std::string
 Convert circuit state to human-readable string.
 

Enumeration Type Documentation

◆ circuit_state

Represents the current state of a circuit breaker.

State Transitions: CLOSED -> OPEN: When failure threshold is exceeded OPEN -> HALF_OPEN: After timeout period expires HALF_OPEN -> CLOSED: When success threshold is met HALF_OPEN -> OPEN: When any failure occurs during testing

Enumerator
CLOSED 

Normal operation state. Requests are allowed and failures are tracked.

OPEN 

Failure state. Requests are immediately rejected without execution. Transitions to HALF_OPEN after timeout.

HALF_OPEN 

Recovery testing state. Limited requests are allowed to test if service has recovered.

Definition at line 31 of file circuit_state.h.

31 {
36 CLOSED,
37
43 OPEN,
44
50};
@ CLOSED
Normal operation state. Requests are allowed and failures are tracked.
@ HALF_OPEN
Recovery testing state. Limited requests are allowed to test if service has recovered.
@ OPEN
Failure state. Requests are immediately rejected without execution. Transitions to HALF_OPEN after ti...

Function Documentation

◆ to_string()

auto kcenon::common::resilience::to_string ( circuit_state state) -> std::string
inline

Convert circuit state to human-readable string.

Parameters
stateCircuit state to convert
Returns
String representation of the state

Definition at line 57 of file circuit_state.h.

58{
59 switch (state) {
60 case circuit_state::CLOSED:
61 return "CLOSED";
62 case circuit_state::OPEN:
63 return "OPEN";
64 case circuit_state::HALF_OPEN:
65 return "HALF_OPEN";
66 default:
67 return "UNKNOWN";
68 }
69}

References CLOSED, HALF_OPEN, and OPEN.

Referenced by kcenon::common::resilience::circuit_breaker::get_stats().

Here is the caller graph for this function: