#[non_exhaustive]pub struct Attempt<'a> {
pub failures: u32,
pub error: Option<&'a (dyn Error + 'static)>,
pub rebuilding: Rebuilding,
}Expand description
The state a ReconnectPolicy decides on.
Non-exhaustive: it gains fields as the backend learns to report more, and an existing policy keeps compiling.
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.failures: u32Consecutive failures so far, resetting on every success.
0 on the first attempt after a drop, when nothing has failed yet: a
policy that returns Duration::ZERO for 0 retries immediately, which
is what BackoffPolicy does, because a failover is often complete by
the time the client notices.
error: Option<&'a (dyn Error + 'static)>What failed last, or None when failures is 0.
Deliberately a plain std::error::Error rather than a concrete type:
the two Rebuilding cases fail with different error types, and a
policy that wants the detail can downcast_ref to
lapin::Error or
queuey_core::Error. Most policies only read failures.
rebuilding: RebuildingWhich of the two things is being rebuilt.
Implementations§
Source§impl<'a> Attempt<'a>
impl<'a> Attempt<'a>
Sourcepub fn first(rebuilding: Rebuilding) -> Self
pub fn first(rebuilding: Rebuilding) -> Self
An attempt that has not failed yet.
The backend builds these; they are public so you can unit-test a
ReconnectPolicy of your own. This type is #[non_exhaustive], so
these constructors are the only way to make one.
Sourcepub fn after(
rebuilding: Rebuilding,
failures: u32,
error: &'a (dyn Error + 'static),
) -> Self
pub fn after( rebuilding: Rebuilding, failures: u32, error: &'a (dyn Error + 'static), ) -> Self
An attempt after failures consecutive failures, the last being error.