Skip to main content

reliar_core/
failure.rs

1//! Failure classification shared by [`crate::Publisher`] and `OutboxStore` (`reliar-outbox`)
2//! (SRS §19.4, §23, ADR 0008, ADR 0032).
3
4/// Implemented by every [`crate::Publisher::Error`] and `OutboxStore::Error`
5/// (`reliar-outbox`) so a dispatcher can decide retry vs. dead without a downcast. Carried **by
6/// the error type**, not by the publisher: the error value is what crosses a `JoinSet` boundary
7/// into the dispatcher, so it must carry its own verdict (ADR 0008).
8pub trait Classify {
9    /// Whether the failure this error represents can succeed on retry.
10    fn kind(&self) -> FailureKind;
11}
12
13/// Whether a failure is worth retrying.
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15pub enum FailureKind {
16    /// May succeed if retried (a timeout, a connection blip, a lock conflict).
17    Transient,
18    /// No retry can fix it (an oversized payload, an unresolvable schema).
19    Permanent,
20}