Skip to main content

Module retry

Module retry 

Source
Expand description

Shared retry/backoff helpers built on top of the backon crate.

These constructors give the node a single definition of the “standard” backoff schedules so that retry behaviour stays consistent across components instead of being re-derived at each call site. Use them together with the Retryable suffix extension, e.g.

ⓘ
use miden_node_utils::retry::{self, Retryable};
use miden_node_tracing::warn;

let value = (|| async { do_thing().await })
    .retry(retry::exponential(min, max))
    .when(|err| is_transient(err))
    .notify(|err, dur| {
        warn!(
            err,
            "retrying",
            retry.delay_ms = dur
        );
    })
    .await?;

Traits§

BackoffBuilder
BackoffBuilder is utilized to construct a new backoff.
Retryable
Retryable will add retry support for functions that produce futures with results.
RetryableGrpc
Retries a gRPC call with the node’s standard policy for transient connection failures.
RetryableWithContext
RetryableWithContext adds retry support for functions that produce futures with results and context.

Functions§

constant
Builds a constant-delay backoff schedule.
exponential
Builds an exponential backoff schedule that retries indefinitely.
exponential_bounded
Same as exponential, but stops after max_times retries (i.e. max_times + 1 total attempts).
is_retryable_grpc_error
Identifies service unavailability and local transport failures for retryable gRPC calls.