Skip to main content

Reconnect

Struct Reconnect 

Source
pub struct Reconnect<A, E> { /* private fields */ }
Expand description

Client connect policy as a poll machine; see the module docs.

A is the caller’s address type and E its error type, which takes the Error a session closes with and the Failures the policy decides on.

Implementations§

Source§

impl<A: Target, E: Clone + Display + From<Error> + From<Failure>> Reconnect<A, E>

Source

pub fn new( config: Config, targets: Vec<A>, now: Instant, ) -> Result<Self, ConfigError>

Walk targets in order under config, starting at now.

Source

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.

Source

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.

Source

pub fn session(&self) -> Option<&Session>

The live session, if one is serving and has not received a GOAWAY.

Source

pub fn targets(&self) -> &[A]

The addresses the next walk dials, in order: the configured ones, or the one a GOAWAY redirected to.

Source

pub fn predecessor(&self) -> Option<(&Session, Instant)>

The session draining after a GOAWAY, and the deadline its handover ends by.

Source

pub fn poll(&mut self, now: Instant, waiter: &Waiter) -> Action<A, E>

Advance to now, returning what the caller must do next.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<A, E> Drop for Reconnect<A, E>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<A, E> Freeze for Reconnect<A, E>
where E: Freeze,

§

impl<A, E> RefUnwindSafe for Reconnect<A, E>

§

impl<A, E> Send for Reconnect<A, E>
where E: Send, A: Send,

§

impl<A, E> Sync for Reconnect<A, E>
where E: Sync + Send, A: Sync,

§

impl<A, E> Unpin for Reconnect<A, E>
where E: Unpin, A: Unpin,

§

impl<A, E> UnsafeUnpin for Reconnect<A, E>
where E: UnsafeUnpin,

§

impl<A, E> UnwindSafe for Reconnect<A, E>
where E: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more