Skip to main content

Reconnect

Struct Reconnect 

Source
pub struct Reconnect<P, Sf, St> { /* private fields */ }
Expand description

Factory for independent, lazily connected ReconnectService instances.

Each ServiceFactory::create call returns a disconnected wrapper without invoking the wrapped factory. The child is created when readiness is first needed, using the state supplied by that operation’s context.

The wrapped factory is shared through Rc; policy and retry settings are copied into each service. The default policy permits reconnection after any error, with a budget of three retries.

Implementations§

Source§

impl<Sf, St> Reconnect<DefaultPolicy, Sf, St>
where St: 'static, Sf: 'static,

Source

pub fn new<Req>( name: &'static str, factory: Sf, ) -> Reconnect<DefaultPolicy, Sf, St>
where Sf: ServiceFactory<St, Req> + 'static, <Sf as ServiceFactory<St, Req>>::InitError: Into<<Sf as ServiceFactory<St, Req>>::Error>,

Wraps factory with DefaultPolicy and a budget of three retries.

name identifies the service in diagnostic messages. Construction does not invoke the factory or establish a connection.

Source§

impl<P, Sf, St> Reconnect<P, Sf, St>

Source

pub fn retry(self, retry: usize) -> Reconnect<P, Sf, St>

Sets the number of additional attempts after creation or readiness errors.

Zero permits the initial attempt but no retries. Each created service restores this budget after successful child readiness. A rejecting policy or exhausted backoff can stop retries before the budget is consumed.

Source

pub fn policy<T, Req>(self, policy: T) -> Reconnect<T, Sf, St>
where T: ReconnectPolicy<<Sf as ServiceFactory<St, Req>>::Error>, Sf: ServiceFactory<St, Req>,

Replaces the error policy while preserving the factory and retry settings.

The new policy is cloned into services created by this factory.

Trait Implementations§

Source§

impl<P, Sf, St> Clone for Reconnect<P, Sf, St>
where P: Clone,

Source§

fn clone(&self) -> Reconnect<P, Sf, St>

Shares the wrapped factory and copies configuration without creating a child.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P, Sf, St> Debug for Reconnect<P, Sf, St>
where P: Debug, Sf: Debug, St: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<P, Sf, St, Req> ServiceFactory<St, Req> for Reconnect<P, Sf, St>
where P: ReconnectPolicy<<Sf as ServiceFactory<St, Req>>::Error>, Sf: ServiceFactory<St, Req>, <Sf as ServiceFactory<St, Req>>::Error: Error, <Sf as ServiceFactory<St, Req>>::InitError: Into<<Sf as ServiceFactory<St, Req>>::Error> + Error, St: 'static,

Source§

async fn create( &self, _: &St, ) -> Result<<Reconnect<P, Sf, St> as ServiceFactory<St, Req>>::Service, <Reconnect<P, Sf, St> as ServiceFactory<St, Req>>::InitError>

Creates a disconnected service with independent readiness and retry state.

The supplied state is not retained and the wrapped factory is not called. Child creation, including initialization errors, is deferred until readiness is needed and uses that operation’s Ctx::st.

Source§

type Res = <Sf as ServiceFactory<St, Req>>::Res

Response produced by the created services.
Source§

type Error = <Sf as ServiceFactory<St, Req>>::Error

Error produced by the created services.
Source§

type Service = ReconnectService<P, Sf, <Sf as ServiceFactory<St, Req>>::Service, St>

The type of Service produced by this factory.
Source§

type InitError = <Sf as ServiceFactory<St, Req>>::Error

Error that can occur while constructing a service.
Source§

async fn pipeline( &self, st: St, ) -> Result<Pipeline<Req, Self::Res, Self::Error>, Self::InitError>
where Self: 'static, St: 'static, Req: 'static,

Creates a service and wraps it with its state in a Pipeline.
Source§

fn map<F, Res>( self, f: F, ) -> ServiceChainFactory<MapFactory<F, Self, Res>, St, Req>
where Self: Sized, F: Fn(Self::Res) -> Res + Clone,

Returns a factory whose services map responses to a different type.
Source§

fn map_err<F, E>( self, f: F, ) -> ServiceChainFactory<MapErrFactory<F, Self, E>, St, Req>
where Self: Sized, F: Fn(Self::Error) -> E + Clone,

Returns a factory whose services map errors to a different type.
Source§

fn map_init_err<F, E>( self, f: F, ) -> ServiceChainFactory<MapInitErr<F, Self, E>, St, Req>
where Self: Sized, F: Fn(Self::InitError) -> E + Clone,

Maps this factory’s initialization error to a different error, returning a new service factory.
Source§

fn and_then<U, F>( self, f: F, ) -> ServiceChainFactory<AndThenFactory<Self, U>, St, Req>
where Self: Sized, U: ServiceFactory<St, Self::Res, Error = Self::Error, InitError = Self::InitError>, F: IntoServiceFactory<U, St, Self::Res>,

Chains another factory after this factory’s services. Read more
Source§

fn boxed( self, ) -> BoxServiceFactory<St, Req, Self::Res, Self::Error, Self::InitError>
where St: 'static, Req: 'static, Self: Sized + 'static,

Creates a boxed service factory.

Auto Trait Implementations§

§

impl<P, Sf, St> !Send for Reconnect<P, Sf, St>

§

impl<P, Sf, St> !Sync for Reconnect<P, Sf, St>

§

impl<P, Sf, St> Freeze for Reconnect<P, Sf, St>
where P: Freeze,

§

impl<P, Sf, St> RefUnwindSafe for Reconnect<P, Sf, St>

§

impl<P, Sf, St> Unpin for Reconnect<P, Sf, St>
where P: Unpin, St: Unpin,

§

impl<P, Sf, St> UnsafeUnpin for Reconnect<P, Sf, St>
where P: UnsafeUnpin,

§

impl<P, Sf, St> UnwindSafe for Reconnect<P, Sf, St>
where P: UnwindSafe, Sf: RefUnwindSafe, St: 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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<Sf, St, Req> IntoServiceFactory<Sf, St, Req> for Sf
where Sf: ServiceFactory<St, Req>,

Source§

fn into_factory(self) -> Sf

Converts this value into a service factory.
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V