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,
impl<Sf, St> Reconnect<DefaultPolicy, Sf, St>where
St: 'static,
Sf: 'static,
Sourcepub 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>,
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>
impl<P, Sf, St> Reconnect<P, Sf, St>
Sourcepub fn retry(self, retry: usize) -> Reconnect<P, Sf, St>
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.
Trait Implementations§
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,
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>
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
type Res = <Sf as ServiceFactory<St, Req>>::Res
Source§type Error = <Sf as ServiceFactory<St, Req>>::Error
type Error = <Sf as ServiceFactory<St, Req>>::Error
Source§type Service = ReconnectService<P, Sf, <Sf as ServiceFactory<St, Req>>::Service, St>
type Service = ReconnectService<P, Sf, <Sf as ServiceFactory<St, Req>>::Service, St>
Service produced by this factory.Source§type InitError = <Sf as ServiceFactory<St, Req>>::Error
type InitError = <Sf as ServiceFactory<St, Req>>::Error
Source§async fn pipeline(
&self,
st: St,
) -> Result<Pipeline<Req, Self::Res, Self::Error>, Self::InitError>where
Self: 'static,
St: 'static,
Req: 'static,
async fn pipeline(
&self,
st: St,
) -> Result<Pipeline<Req, Self::Res, Self::Error>, Self::InitError>where
Self: 'static,
St: 'static,
Req: 'static,
Pipeline.