#[non_exhaustive]pub struct FailurePolicies {
pub panic: FailurePolicy,
pub decode: FailurePolicy,
}Expand description
The pair of failure policies a subscriber carries: one for a handler panic, one for a decode
failure. Threaded from the def to the dispatch loop alongside the
Workers policy.
§Examples
use ruststream::memory::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Order {
id: u64,
}
#[subscriber]
async fn ingest(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, "ingested");
HandlerOutcome::ack()
}
fn app() -> RustStream {
RustStream::new(AppInfo::new("ingest", "0.1.0")).with_broker(MemoryBroker::new(), |b| {
// An untrusted topic: a malformed payload is requeued, a handler bug still stops the
// service (the default panic policy).
b.include(
ingest
.name("ingest")
.on_failure(FailurePolicies::default().with_decode(FailurePolicy::Retry)),
);
})
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.panic: FailurePolicyWhat to do when the handler panics. Defaults to FailurePolicy::FailFast.
decode: FailurePolicyWhat to do when a delivery’s typed view cannot be materialized: the codec fails to decode
the payload, a Headers contract fails to parse, the delivery carries
no value (Carries), or the broker reports that it could not read the
delivery (IncomingMessage::decode_error). One
policy covers all four - each is the same class of bad external input as a payload that
does not decode. Defaults to FailurePolicy::Drop.
Implementations§
Source§impl FailurePolicies
impl FailurePolicies
Sourcepub fn with_panic(self, policy: FailurePolicy) -> FailurePolicies
pub fn with_panic(self, policy: FailurePolicy) -> FailurePolicies
Overrides the handler-panic policy, leaving the decode policy unchanged. The builder the
#[subscriber] macro uses to fill in the keys named in on_failure(..).
Sourcepub fn with_decode(self, policy: FailurePolicy) -> FailurePolicies
pub fn with_decode(self, policy: FailurePolicy) -> FailurePolicies
Overrides the decode-failure policy, leaving the panic policy unchanged.
Trait Implementations§
Source§impl Clone for FailurePolicies
impl Clone for FailurePolicies
Source§fn clone(&self) -> FailurePolicies
fn clone(&self) -> FailurePolicies
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FailurePolicies
Source§impl Debug for FailurePolicies
impl Debug for FailurePolicies
Source§impl Default for FailurePolicies
impl Default for FailurePolicies
Source§fn default() -> FailurePolicies
fn default() -> FailurePolicies
impl Eq for FailurePolicies
Source§impl PartialEq for FailurePolicies
impl PartialEq for FailurePolicies
impl StructuralPartialEq for FailurePolicies
Auto Trait Implementations§
impl Freeze for FailurePolicies
impl RefUnwindSafe for FailurePolicies
impl Send for FailurePolicies
impl Sync for FailurePolicies
impl Unpin for FailurePolicies
impl UnsafeUnpin for FailurePolicies
impl UnwindSafe for FailurePolicies
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more