pub struct CircuitBreakerConfig {
pub failure_threshold: usize,
pub cooldown_duration: Duration,
pub half_open_max_attempts: usize,
}Expand description
Circuit breaker configuration for node execution
Controls when a node’s circuit breaker trips (opens) after repeated failures, and how long it stays open before allowing a retry attempt.
§State Machine
Closed --[failures >= threshold]--> Open
Open --[cooldown elapsed]--> HalfOpen
HalfOpen --[success]--> Closed
HalfOpen --[failure]--> Open§Examples
ⓘ
use juncture_core::graph::CircuitBreakerConfig;
use std::time::Duration;
let config = CircuitBreakerConfig::new(5, Duration::from_secs(30));
assert_eq!(config.failure_threshold, 5);Fields§
§failure_threshold: usizeNumber of consecutive failures before the circuit opens
cooldown_duration: DurationDuration the circuit stays open before transitioning to half-open
half_open_max_attempts: usizeMaximum attempts allowed in half-open state before re-opening
Implementations§
Source§impl CircuitBreakerConfig
impl CircuitBreakerConfig
Sourcepub const fn new(failure_threshold: usize, cooldown_duration: Duration) -> Self
pub const fn new(failure_threshold: usize, cooldown_duration: Duration) -> Self
Create a new circuit breaker configuration
§Arguments
failure_threshold- Consecutive failures before openingcooldown_duration- How long the circuit stays open
Sourcepub const fn with_half_open_max_attempts(self, max_attempts: usize) -> Self
pub const fn with_half_open_max_attempts(self, max_attempts: usize) -> Self
Set the maximum attempts allowed in half-open state
The value is clamped to a minimum of 1 to prevent the circuit
from being permanently stuck in HalfOpen state.
Trait Implementations§
Source§impl Clone for CircuitBreakerConfig
impl Clone for CircuitBreakerConfig
Source§fn clone(&self) -> CircuitBreakerConfig
fn clone(&self) -> CircuitBreakerConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CircuitBreakerConfig
impl RefUnwindSafe for CircuitBreakerConfig
impl Send for CircuitBreakerConfig
impl Sync for CircuitBreakerConfig
impl Unpin for CircuitBreakerConfig
impl UnsafeUnpin for CircuitBreakerConfig
impl UnwindSafe for CircuitBreakerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more