pub struct CircuitBreakerManager {
circuits: Arc<DashMap<String, ProviderCircuit>>,
config: CircuitBreakerConfig,
}Expand description
Manages circuit breakers for all diagram providers.
Fields§
§circuits: Arc<DashMap<String, ProviderCircuit>>§config: CircuitBreakerConfigImplementations§
Source§impl CircuitBreakerManager
impl CircuitBreakerManager
Sourcepub fn new(config: &CircuitBreakerConfig) -> Self
pub fn new(config: &CircuitBreakerConfig) -> Self
Creates a new circuit breaker manager.
Sourcepub fn should_allow(&self, provider: &str) -> bool
pub fn should_allow(&self, provider: &str) -> bool
Checks if the circuit for the given provider allows requests.
Returns true if the request should proceed, false if it should be rejected.
Sourcepub fn record_success(&self, provider: &str)
pub fn record_success(&self, provider: &str)
Records a successful request for the given provider.
Sourcepub fn record_failure(&self, provider: &str)
pub fn record_failure(&self, provider: &str)
Records a failed request for the given provider.
Sourcepub fn get_state(&self, provider: &str) -> CircuitState
pub fn get_state(&self, provider: &str) -> CircuitState
Returns the current state of the circuit for a given provider.
Sourcepub fn get_all_states(&self) -> Vec<(String, CircuitState)>
pub fn get_all_states(&self) -> Vec<(String, CircuitState)>
Returns the states of all known circuits.
Trait Implementations§
Source§impl Clone for CircuitBreakerManager
impl Clone for CircuitBreakerManager
Source§fn clone(&self) -> CircuitBreakerManager
fn clone(&self) -> CircuitBreakerManager
Returns a duplicate of the value. Read more
1.0.0 · 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 CircuitBreakerManager
impl !RefUnwindSafe for CircuitBreakerManager
impl Send for CircuitBreakerManager
impl Sync for CircuitBreakerManager
impl Unpin for CircuitBreakerManager
impl !UnwindSafe for CircuitBreakerManager
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more