Expand description
Type-preserving retry policy for synchronous and asynchronous operations.
Retry<E> binds only the operation error type. The success type T is
introduced on run / run_async, so normal error retry does not require
T: Clone + Eq + Hash.
The default error type is BoxError from the qubit-error crate. It is not
re-exported by this crate; callers that need the boxed error alias should
import it from qubit-error directly.
The public workflow is intentionally small:
- Build a
Retrypolicy withRetry::builderorRetry::from_options. - Choose the execution mode:
Retry::runfor low-overhead same-thread synchronous work.Retry::run_asyncfor Tokio futures and async timeouts when thetokiofeature is enabled.Retry::run_in_workerfor blocking work that needs panic capture, timeout waiting, or cooperative cancellation.
- Inspect
RetryErrorwhen the flow stops. It keeps the terminal reason, the last observedAttemptFailure, and the finalRetryContext.
Internally, Retry stays a facade. Options, event dispatch, flow state,
failure policy, and execution loops live in separate objects so each piece
owns one retry concern.
Re-exports§
pub use error::AttemptExecutorError;pub use error::AttemptFailure;pub use error::AttemptPanic;pub use error::RetryConfigError;pub use error::RetryError;pub use error::RetryErrorReason;pub use error::RetryResult;pub use event::AttemptFailureDecision;pub use event::AttemptFailureListener;pub use event::AttemptSuccessListener;pub use event::AttemptTimeoutSource;pub use event::BeforeAttemptListener;pub use event::RetryAfterHint;pub use event::RetryContext;pub use event::RetryErrorListener;pub use event::RetryScheduledListener;pub use executor::AttemptCancelToken;pub use executor::Retry;pub use executor::RetryBuilder;pub use options::RetryConfigValues;pub use options::AttemptTimeoutOption;pub use options::AttemptTimeoutPolicy;pub use options::ParseRetryJitterError;pub use options::RetryDelay;pub use options::RetryJitter;pub use options::RetryOptions;