pub struct Reconnect<A, E> { /* private fields */ }Expand description
Implementations§
Source§impl<A: Target, E: Clone + Display + From<Error> + From<Failure>> Reconnect<A, E>
impl<A: Target, E: Clone + Display + From<Error> + From<Failure>> Reconnect<A, E>
Sourcepub fn new(
config: Config,
targets: Vec<A>,
now: Instant,
) -> Result<Self, ConfigError>
pub fn new( config: Config, targets: Vec<A>, now: Instant, ) -> Result<Self, ConfigError>
Walk targets in order under config, starting at now.
Sourcepub fn with_tokens(self, tokens: Tokens) -> Self
pub fn with_tokens(self, tokens: Tokens) -> Self
Present tokens on every dial, through Attempt::client.
An ended tokens handle ends the policy at its next walk.
Sourcepub fn with_dials(self, dials: Dials<E>) -> Self
pub fn with_dials(self, dials: Dials<E>) -> Self
Ask dials for the tokens of every dial, as it starts, instead of presenting fixed ones;
see Dials. Each answer replaces the tokens from with_tokens, or
from a handle of their own without one.
They serve one policy: given dials another policy took, even one that ended since, this
one ends at once with Failure::Taken, leaving them to the other.
Sourcepub fn session(&self) -> Option<&Session>
pub fn session(&self) -> Option<&Session>
The live session, if one is serving and has not received a GOAWAY.
Sourcepub fn targets(&self) -> &[A]
pub fn targets(&self) -> &[A]
The addresses the next walk dials, in order: the configured ones, or the one a GOAWAY redirected to.
Sourcepub fn predecessor(&self) -> Option<(&Session, Instant)>
pub fn predecessor(&self) -> Option<(&Session, Instant)>
The session draining after a GOAWAY, and the deadline its handover ends by.
Sourcepub fn poll(&mut self, now: Instant, waiter: &Waiter) -> Action<A, E>
pub fn poll(&mut self, now: Instant, waiter: &Waiter) -> Action<A, E>
Advance to now, returning what the caller must do next.
Sourcepub fn connected(&mut self, now: Instant, session: Session)
pub fn connected(&mut self, now: Instant, session: Session)
Report that the dial asked for connected session, at now.
Ignored unless a dial is in flight, as after Action::Abandon.
Sourcepub fn fallback(&mut self, now: Instant)
pub fn fallback(&mut self, now: Instant)
Report that the live session runs on a fallback transport, at now.
The policy then asks for Action::Probe dials of the preferred transport, the
first 5 to 10 s from now and the rest on a doubling backoff capped at one every 5
minutes, until one connects. Ignored unless a session is live, or when connecting once.
Sourcepub fn probed(&mut self, now: Instant, result: Result<(), E>) -> bool
pub fn probed(&mut self, now: Instant, result: Result<(), E>) -> bool
Report whether the probe asked for reached the preferred transport, at now.
On Ok, the fallback session sends its own GOAWAY and drains as the
predecessor, queuing Action::Migrating, and the probe becomes
the dial in flight: finish the MoQ handshake over the transport it reached and report it
with connected or failed. The fallback drains
first because the tokens back one session at a time, and keeps serving until the
replacement does. Returns whether the probe became that dial: one reported with none in
flight, as after Action::Abandon, is ignored, and one reported once the peer’s GOAWAY
arrived yields to it.
Sourcepub fn failed(&mut self, now: Instant, err: E, verdict: Verdict)
pub fn failed(&mut self, now: Instant, err: E, verdict: Verdict)
Report that the dial asked for failed with err, judged as verdict.
Ignored unless a dial is in flight, as after Action::Abandon.