Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
circuit_state.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
15#pragma once
16
17#include <string>
18
20
31enum class circuit_state {
36 CLOSED,
37
43 OPEN,
44
50};
51
57inline auto to_string(circuit_state state) -> std::string
58{
59 switch (state) {
61 return "CLOSED";
63 return "OPEN";
65 return "HALF_OPEN";
66 default:
67 return "UNKNOWN";
68 }
69}
70
71} // namespace kcenon::common::resilience
circuit_state
Represents the current state of a circuit breaker.
@ 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...
auto to_string(circuit_state state) -> std::string
Convert circuit state to human-readable string.