pub trait RetryStrategy:
    Send
    + Sync
    + Debug {
    // Required methods
    fn should_attempt_initial_request(
        &self,
        runtime_components: &RuntimeComponents,
        cfg: &ConfigBag,
    ) -> Result<ShouldAttempt, BoxError>;
    fn should_attempt_retry(
        &self,
        context: &InterceptorContext,
        runtime_components: &RuntimeComponents,
        cfg: &ConfigBag,
    ) -> Result<ShouldAttempt, BoxError>;
}
Expand description

Decider for whether or not to attempt a request, and when.

The orchestrator consults the retry strategy every time before making a request. This includes the initial request, and any retry attempts thereafter. The orchestrator will retry indefinitely (until success) if the retry strategy always returns ShouldAttempt::Yes from should_attempt_retry.

Required Methods§

source

fn should_attempt_initial_request( &self, runtime_components: &RuntimeComponents, cfg: &ConfigBag, ) -> Result<ShouldAttempt, BoxError>

Decides if the initial attempt should be made.

source

fn should_attempt_retry( &self, context: &InterceptorContext, runtime_components: &RuntimeComponents, cfg: &ConfigBag, ) -> Result<ShouldAttempt, BoxError>

Decides if a retry should be done.

The previous attempt’s output or error are provided in the InterceptorContext when this is called.

ShouldAttempt::YesAfterDelay can be used to add a backoff time.

Implementors§