Trait CircuitBreakerObserver

Source
pub trait CircuitBreakerObserver: Send + Sync {
    // Required methods
    fn on_state_change(&self, name: &str, event: &CircuitTransitionEvent);
    fn on_operation_attempt(&self, name: &str, state: CircuitBreakerState);
    fn on_operation_result(
        &self,
        name: &str,
        op_type: CircuitOperationType,
        duration: Duration,
        error: Option<&DecrustError>,
    );
    fn on_reset(&self, name: &str);
}
Expand description

Observer trait for circuit breaker events.

Implement this trait to react to state changes, operation results, and other significant events from the circuit breaker.

Required Methods§

Source

fn on_state_change(&self, name: &str, event: &CircuitTransitionEvent)

Called when the circuit breaker’s state changes.

Source

fn on_operation_attempt(&self, name: &str, state: CircuitBreakerState)

Called before an operation is attempted (if not rejected immediately).

Source

fn on_operation_result( &self, name: &str, op_type: CircuitOperationType, duration: Duration, error: Option<&DecrustError>, )

Called after an operation completes or is rejected/timed out.

Source

fn on_reset(&self, name: &str)

Called when the circuit breaker is manually reset.

Implementors§