pub struct ResilientPersistenceBackend<P: PersistenceBackend> {
inner: P,
config: StorageResilienceConfig,
breaker: Mutex<CircuitBreaker>,
backend_name: &'static str,
}Expand description
Persistence backend wrapper with circuit breaker and retry protection.
Fields§
§inner: P§config: StorageResilienceConfig§breaker: Mutex<CircuitBreaker>§backend_name: &'static strImplementations§
Source§impl<P: PersistenceBackend> ResilientPersistenceBackend<P>
impl<P: PersistenceBackend> ResilientPersistenceBackend<P>
Sourcepub fn new(
inner: P,
config: StorageResilienceConfig,
backend_name: &'static str,
) -> Self
pub fn new( inner: P, config: StorageResilienceConfig, backend_name: &'static str, ) -> Self
Creates a new resilient persistence backend wrapper.
fn execute<T, F>(&self, operation: &'static str, call: F) -> Result<T>
Sourcefn check_circuit_breaker(&self, operation: &'static str) -> Option<Error>
fn check_circuit_breaker(&self, operation: &'static str) -> Option<Error>
Checks circuit breaker and returns error if open.
Sourcefn handle_success<T>(&self, operation: &'static str, value: T) -> T
fn handle_success<T>(&self, operation: &'static str, value: T) -> T
Handles successful operation result.
Sourcefn handle_error(
&self,
operation: &'static str,
err: Error,
attempts: u32,
max_attempts: u32,
) -> Result<Option<Error>>
fn handle_error( &self, operation: &'static str, err: Error, attempts: u32, max_attempts: u32, ) -> Result<Option<Error>>
Handles operation error. Returns Ok(Some(err)) to continue retrying, Err to stop.
Sourcefn apply_retry_backoff(&self, attempts: u32)
fn apply_retry_backoff(&self, attempts: u32)
Applies retry backoff delay if configured.
fn record_metrics( backend: &'static str, operation: &'static str, status: &'static str, state: u8, )
Sourcefn record_circuit_trip(backend: &'static str, operation: &'static str)
fn record_circuit_trip(backend: &'static str, operation: &'static str)
Records metrics and logs when circuit breaker trips.
Trait Implementations§
Source§impl<P: PersistenceBackend> PersistenceBackend for ResilientPersistenceBackend<P>
impl<P: PersistenceBackend> PersistenceBackend for ResilientPersistenceBackend<P>
Auto Trait Implementations§
impl<P> !Freeze for ResilientPersistenceBackend<P>
impl<P> RefUnwindSafe for ResilientPersistenceBackend<P>where
P: RefUnwindSafe,
impl<P> Send for ResilientPersistenceBackend<P>
impl<P> Sync for ResilientPersistenceBackend<P>
impl<P> Unpin for ResilientPersistenceBackend<P>where
P: Unpin,
impl<P> UnwindSafe for ResilientPersistenceBackend<P>where
P: UnwindSafe,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].