pub struct CircuitBreaker { /* private fields */ }Expand description
Circuit breaker implementation
Implementations§
Source§impl CircuitBreaker
impl CircuitBreaker
Sourcepub fn new(config: CircuitBreakerConfig) -> Self
pub fn new(config: CircuitBreakerConfig) -> Self
Create a new circuit breaker
Sourcepub fn with_endpoint(
config: CircuitBreakerConfig,
endpoint: impl Into<String>,
) -> Self
pub fn with_endpoint( config: CircuitBreakerConfig, endpoint: impl Into<String>, ) -> Self
Create a new circuit breaker with endpoint name
Sourcepub fn with_persistence(self, path: PathBuf) -> Self
pub fn with_persistence(self, path: PathBuf) -> Self
Enable persistence to file system
Sourcepub fn subscribe_state_changes(&self) -> Receiver<CircuitStateChange>
pub fn subscribe_state_changes(&self) -> Receiver<CircuitStateChange>
Subscribe to state changes
Sourcepub async fn save_state(&self) -> Result<()>
pub async fn save_state(&self) -> Result<()>
Save state to disk
Sourcepub async fn load_state(&self) -> Result<()>
pub async fn load_state(&self) -> Result<()>
Load state from disk
Sourcepub async fn allow_request(&self) -> bool
pub async fn allow_request(&self) -> bool
Check if request is allowed
Sourcepub async fn record_success(&self)
pub async fn record_success(&self)
Record successful request
Sourcepub async fn record_failure(&self)
pub async fn record_failure(&self)
Record failed request
Sourcepub async fn stats(&self) -> CircuitStats
pub async fn stats(&self) -> CircuitStats
Get current statistics
Sourcepub async fn state(&self) -> CircuitState
pub async fn state(&self) -> CircuitState
Get current state
Sourcepub async fn update_config(&self, config: CircuitBreakerConfig)
pub async fn update_config(&self, config: CircuitBreakerConfig)
Update configuration
Sourcepub async fn config(&self) -> CircuitBreakerConfig
pub async fn config(&self) -> CircuitBreakerConfig
Get configuration
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CircuitBreaker
impl !RefUnwindSafe for CircuitBreaker
impl Send for CircuitBreaker
impl Sync for CircuitBreaker
impl Unpin for CircuitBreaker
impl !UnwindSafe for CircuitBreaker
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,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request