Skip to main content

RecoveryStrategy

Trait RecoveryStrategy 

Source
pub trait RecoveryStrategy<T, E>: Send + Sync
where T: Send + 'static, E: Send + 'static,
{ // Required methods fn name(&self) -> String; fn description(&self) -> String; fn attempt<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, error: &'life1 E, context: &'life2 RecoveryContext, op: RecoveryOperation<T, E>, cancel: &'life3 CancelCheckpoint, ) -> Pin<Box<dyn Future<Output = StrategyOutcome<T, E>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; // Provided method fn on_cancel<'life0, 'life1, 'async_trait>( &'life0 self, _context: &'life1 RecoveryContext, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } }
Expand description

Bock spec:

trait RecoveryStrategy[E, T] {
  fn name(self) -> String
  fn description(self) -> String
  fn attempt(self, error: E, context: RecoveryContext)
    -> Result[T, E] | Cancelled
  fn on_cancel(self, context: RecoveryContext) -> Void = {}
}

Required Methods§

Source

fn name(&self) -> String

Stable identifier used in manifest entries and select() options.

Source

fn description(&self) -> String

Human-readable description shown to the provider when selecting.

Source

fn attempt<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, error: &'life1 E, context: &'life2 RecoveryContext, op: RecoveryOperation<T, E>, cancel: &'life3 CancelCheckpoint, ) -> Pin<Box<dyn Future<Output = StrategyOutcome<T, E>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Attempt recovery. op is the caller-provided effect operation that originally failed; strategies invoke it as needed (retries, single-shot fallbacks, or not at all).

Provided Methods§

Source

fn on_cancel<'life0, 'life1, 'async_trait>( &'life0 self, _context: &'life1 RecoveryContext, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Cleanup hook fired when attempt returns StrategyOutcome::Cancelled. Default is a no-op.

Implementors§

Source§

impl<T, E> RecoveryStrategy<T, E> for CircuitBreakerStrategy<T>
where T: Send + Sync + 'static, E: Send + 'static,

Source§

impl<T, E> RecoveryStrategy<T, E> for DegradeStrategy<T>
where T: Clone + Send + Sync + 'static, E: Send + 'static,

Source§

impl<T, E> RecoveryStrategy<T, E> for EscalateStrategy
where T: Send + 'static, E: Send + 'static,

Source§

impl<T, E> RecoveryStrategy<T, E> for RetryStrategy
where T: Send + 'static, E: Send + 'static,

Source§

impl<T, E> RecoveryStrategy<T, E> for UseCachedStrategy<T>
where T: Send + Sync + Clone + 'static, E: Send + 'static,