Skip to main content

RetryBudget

Trait RetryBudget 

pub trait RetryBudget:
    Send
    + Sync
    + RefUnwindSafe
    + Debug
    + 'static {
    // Required methods
    fn deposit(&self, op: Operation);
    fn try_reserve(&self, op: Operation) -> bool;
    fn release(&self, op: Operation);
}
Available on crate feature layers-retry only.
Expand description

Controls which retries RetryLayer may issue after temporary failures.

A budget can limit the retries shared by multiple operators to avoid amplifying load on a degraded backend. Methods can be called concurrently and must be quick and non-blocking. The operation identifies which balance to update when the implementation tracks separate budgets per operation.

Required Methods§

fn deposit(&self, op: Operation)

Record a successful operation.

create_dir, stat, rename, restore, and presign deposit once on success. Each reader deposits once when its first range completes, even when it reads multiple ranges concurrently or resumes an interrupted stream. A streaming range completes at EOF or when it yields the final byte of a bounded range. Writers, copiers, and deleters deposit once on successful close. Listers deposit once when they first reach the end.

fn try_reserve(&self, op: Operation) -> bool

Atomically reserve one retry. Return false without changing the balance if the retry cannot be reserved.

fn release(&self, op: Operation)

Return one reservation for a retry that was cancelled before it started.

The layer calls this after a successful reservation if it drops the retry before invoking the inner operation, for example during the backoff sleep. A retry that starts consumes its reservation even if it fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§