15#include <kcenon/common/resilience/circuit_breaker.h>
16#include <kcenon/common/resilience/circuit_breaker_config.h>
17#include <kcenon/common/resilience/circuit_state.h>
26 using common::resilience::circuit_breaker;
27 using common::resilience::circuit_breaker_config;
28 using common::resilience::circuit_state;
132 [[nodiscard]]
auto get_name() const ->
std::
string override;
138 [[nodiscard]] auto
is_enabled() const ->
bool override;
160 [[nodiscard]] auto
get_state() const -> circuit_state;
Pool policy that implements circuit breaker pattern for failure protection.
circuit_breaker_policy & operator=(const circuit_breaker_policy &)=delete
void on_job_complete(job &j, bool success, const std::exception *error=nullptr) override
Records job completion in the circuit breaker.
~circuit_breaker_policy() override=default
Destructor.
auto is_enabled() const -> bool override
Checks if the policy is enabled.
auto get_circuit_breaker() const -> std::shared_ptr< circuit_breaker >
Gets the underlying circuit breaker.
auto is_accepting_work() const -> bool
Checks if the circuit is accepting work.
circuit_breaker_policy & operator=(circuit_breaker_policy &&)=delete
auto on_enqueue(job &j) -> common::VoidResult override
Checks circuit state before allowing job enqueue.
void set_enabled(bool enabled) override
Enables or disables the policy.
std::shared_ptr< circuit_breaker > circuit_breaker_
circuit_breaker_policy(circuit_breaker_policy &&)=delete
auto get_name() const -> std::string override
Gets the policy name.
std::atomic< bool > enabled_
circuit_breaker_policy(const circuit_breaker_config &config={})
Constructs a circuit breaker policy with the given configuration.
auto get_state() const -> circuit_state
Gets the current circuit state.
circuit_breaker_policy(const circuit_breaker_policy &)=delete
void on_job_start(job &j) override
Called when job starts executing.
Represents an error in the thread system.
Represents a unit of work (task) to be executed, typically by a job queue.
Base interface for thread pool policies.
Core threading foundation of the thread system library.
Base interface for extensible thread pool behavior policies.