pub enum ErrorClass {
Transient,
RateLimited,
Timeout,
InvalidInput,
DependencyFailure,
ResourceExhausted,
Cancelled,
Unknown,
}Expand description
Why a task attempt failed. Closed set; the scheduler matches exhaustively on it, and new classes are additive (old senders still deserialize).
The class is declared by the executor of the work — the worker that ran
the handler or the transport that carried it — not inferred from logs.
Each variant documents its retry semantics; the mechanical mapping lives
in classify_retry.
Variants§
Transient
A transient fault with no lasting cause: connection reset, broken pipe, a dependency’s internal hiccup. Retry with backoff; the same request is expected to succeed later.
RateLimited
The callee asked to be slowed down (HTTP 429, Retry-After).
Retry with backoff; a callee-supplied Retry-After value floors the
delay (applied by the scheduler, outside this contract).
Timeout
The attempt did not finish within its deadline. Retry with backoff,
but note the ambiguity: the work may have partially executed, which
is exactly why the Effect gate in classify_retry exists — a
timed-out non-idempotent effect must not be re-attempted silently.
InvalidInput
The input is malformed or violates the callee’s contract (HTTP 400, schema validation). Never retried: the same bytes will fail the same way on every attempt. Fails the task immediately.
DependencyFailure
An upstream dependency the task needs is down or degraded (database
unreachable, model endpoint 5xx). Retry with backoff; distinct from
ErrorClass::Transient so operators can distinguish “our wiring”
from “their outage” in telemetry and alerting.
ResourceExhausted
The worker or the callee is out of capacity: memory pressure, connection-pool exhaustion, quota exhaustion. Retry with backoff — ideally on a different worker (placement is the scheduler’s concern; this contract only carries the classification).
Cancelled
The attempt ended because the task was cancelled. Control flow, not a failure: never retried, never dead-lettered. Cancellation propagation (wave 2) classifies interrupted attempts this way so the retry machinery stays out of the cancellation path.
Unknown
The failure could not be classified — the handler returned an unclassified error, or the worker died mid-attempt (lease expiry classifies here). Retried with backoff up to the attempt limit, then dead-lettered: unknown failures are the DLQ’s primary input, since they are the ones that need human eyes.
Implementations§
Source§impl ErrorClass
impl ErrorClass
Sourcepub fn is_retryable(self) -> bool
pub fn is_retryable(self) -> bool
Whether this class is retryable at all. InvalidInput and
Cancelled are the only non-retryable classes; everything else —
including Unknown — may be re-attempted up to the attempt limit.
Retryability of the class is necessary but not sufficient for a
retry: classify_retry additionally gates on the work’s declared
Effect.