gcp_sdk_gax::retry_policy

Trait RetryPolicy

Source
pub trait RetryPolicy:
    Send
    + Sync
    + Debug {
    // Required method
    fn on_error(
        &self,
        loop_start: Instant,
        attempt_count: u32,
        idempotent: bool,
        error: Error,
    ) -> RetryFlow;

    // Provided method
    fn remaining_time(
        &self,
        _loop_start: Instant,
        _attempt_count: u32,
    ) -> Option<Duration> { ... }
}
Expand description

Determines how errors are handled in the retry loop.

Implementations of this trait determine if errors are retryable, and for how long the retry loop may continue.

Required Methods§

Source

fn on_error( &self, loop_start: Instant, attempt_count: u32, idempotent: bool, error: Error, ) -> RetryFlow

Query the retry policy after an error.

§Parameters
  • loop_start - when the retry loop started.
  • attempt_count - the number of attempts. This includes the initial attempt. This method called after the first attempt, so the value is always non-zero.
  • idempotent - if true assume the operation is idempotent. Many more errors are retryable on idempotent operations.
  • error - the last error when attempting the request.

Provided Methods§

Source

fn remaining_time( &self, _loop_start: Instant, _attempt_count: u32, ) -> Option<Duration>

The remaining time in the retry policy.

For policies based on time, this returns the remaining time in the policy. The retry loop can use this value to adjust the next RPC timeout. For policies that are not time based this returns None.

§Parameters
  • loop_start - when the retry loop started.
  • attempt_count - the number of attempts. This method is called before the first attempt, so the first value is zero.

Implementors§