pub struct ResilientIndexBackend<I: IndexBackend> {
inner: I,
config: StorageResilienceConfig,
breaker: Mutex<CircuitBreaker>,
backend_name: &'static str,
}Expand description
Index backend wrapper with circuit breaker and retry protection.
Fields§
§inner: I§config: StorageResilienceConfig§breaker: Mutex<CircuitBreaker>§backend_name: &'static strImplementations§
Source§impl<I: IndexBackend> ResilientIndexBackend<I>
impl<I: IndexBackend> ResilientIndexBackend<I>
Sourcepub fn new(
inner: I,
config: StorageResilienceConfig,
backend_name: &'static str,
) -> Self
pub fn new( inner: I, config: StorageResilienceConfig, backend_name: &'static str, ) -> Self
Creates a new resilient index 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<I: IndexBackend> IndexBackend for ResilientIndexBackend<I>
impl<I: IndexBackend> IndexBackend for ResilientIndexBackend<I>
Source§fn index(&self, memory: &Memory) -> Result<()>
fn index(&self, memory: &Memory) -> Result<()>
Indexes a memory for full-text search. Read more
Source§fn search(
&self,
query: &str,
filter: &SearchFilter,
limit: usize,
) -> Result<Vec<(MemoryId, f32)>>
fn search( &self, query: &str, filter: &SearchFilter, limit: usize, ) -> Result<Vec<(MemoryId, f32)>>
Searches for memories matching a text query. Read more
Source§fn list_all(
&self,
filter: &SearchFilter,
limit: usize,
) -> Result<Vec<(MemoryId, f32)>>
fn list_all( &self, filter: &SearchFilter, limit: usize, ) -> Result<Vec<(MemoryId, f32)>>
Lists all indexed memories, optionally filtered. Read more
Auto Trait Implementations§
impl<I> !Freeze for ResilientIndexBackend<I>
impl<I> RefUnwindSafe for ResilientIndexBackend<I>where
I: RefUnwindSafe,
impl<I> Send for ResilientIndexBackend<I>
impl<I> Sync for ResilientIndexBackend<I>
impl<I> Unpin for ResilientIndexBackend<I>where
I: Unpin,
impl<I> UnwindSafe for ResilientIndexBackend<I>where
I: 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].