pub struct BackoffTable { /* private fields */ }Expand description
Per-peer exponential backoff table.
Implementations§
Source§impl BackoffTable
impl BackoffTable
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a fresh table using the spec’s default schedule (10 ms base, 60 s cap).
Sourcepub fn with_schedule(base_ns: u64, max_delay_ns: u64) -> Self
pub fn with_schedule(base_ns: u64, max_delay_ns: u64) -> Self
Construct a table with a custom exponential schedule.
Sourcepub fn record_failure(&mut self, peer: PeerId, now_ns: u64)
pub fn record_failure(&mut self, peer: PeerId, now_ns: u64)
Record a failure for peer observed at now_ns. Increments
the attempt counter + schedules the next retry.
Sourcepub fn record_remote_advisory(
&mut self,
peer: PeerId,
now_ns: u64,
min_backoff_ns: u64,
)
pub fn record_remote_advisory( &mut self, peer: PeerId, now_ns: u64, min_backoff_ns: u64, )
Record a remotely-advised back-off for peer per the
backpressure protocol at
docs/internal/superpowers/specs/2026-06-23-backpressure-runtime.md
§5.2. Unlike Self::record_failure, the advisory sets
next_retry_ns = now_ns + min_backoff_ns directly instead of
applying the local exponential schedule - the receiver knows
best how long the sender should pause.
Bumps the attempt counter so a subsequent local
record_failure resumes the exponential schedule at the
next step. Caps min_backoff_ns at max_delay_ns so a
pathological remote advisory cannot pin the peer indefinitely.
Sourcepub fn record_success(&mut self, peer: PeerId)
pub fn record_success(&mut self, peer: PeerId)
Record a success for peer; clears any tracked failure
state. Subsequent should_retry returns true immediately.
Sourcepub fn should_retry(&self, peer: PeerId, now_ns: u64) -> bool
pub fn should_retry(&self, peer: PeerId, now_ns: u64) -> bool
Whether a retry to peer is permitted at now_ns. Peers
with no recorded failures retry immediately.
Sourcepub fn state(&self, peer: PeerId) -> Option<BackoffState>
pub fn state(&self, peer: PeerId) -> Option<BackoffState>
Inspect the recorded state for peer. Returns None when no
failures have been recorded.
Sourcepub fn iter(&self) -> impl Iterator<Item = (PeerId, BackoffState)> + '_
pub fn iter(&self) -> impl Iterator<Item = (PeerId, BackoffState)> + '_
Iterate (PeerId, BackoffState) for snapshot capture.
.
Sourcepub fn restore_state(&mut self, peer: PeerId, state: BackoffState)
pub fn restore_state(&mut self, peer: PeerId, state: BackoffState)
Restore one peer’s backoff state directly. Used by
Node::restore to re-seed peers from a
FrameworkSnapshot::backoff_table entry without going
through the failure-counting path.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BackoffTable
impl RefUnwindSafe for BackoffTable
impl Send for BackoffTable
impl Sync for BackoffTable
impl Unpin for BackoffTable
impl UnsafeUnpin for BackoffTable
impl UnwindSafe for BackoffTable
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
impl<T> ErasedComponent for T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request