[go: up one dir, main page]

Struct Pool

Source
pub struct Pool<MS, Target, Request>
where MS: MakeService<Target, Request>, MS::MakeError: Into<Box<dyn Error + Send + Sync>>, MS::Error: Into<Box<dyn Error + Send + Sync>>, Target: Clone,
{ /* private fields */ }
Expand description

A dynamically sized, load-balanced pool of Service instances.

Implementations§

Source§

impl<MS, Target, Request> Pool<MS, Target, Request>
where MS: MakeService<Target, Request>, MS::Service: Load, <MS::Service as Load>::Metric: Debug, MS::MakeError: Into<Box<dyn Error + Send + Sync>>, MS::Error: Into<Box<dyn Error + Send + Sync>>, Target: Clone,

Source

pub fn new(make_service: MS, target: Target) -> Self

Construct a new dynamically sized Pool.

If many calls to poll_ready return Pending, new_service is used to construct another Service that is then added to the load-balanced pool. If many calls to poll_ready succeed, the most recently added Service is dropped from the pool.

Trait Implementations§

Source§

impl<MS, Target, Request> Debug for Pool<MS, Target, Request>
where MS: MakeService<Target, Request> + Debug, MS::MakeError: Into<Box<dyn Error + Send + Sync>>, MS::Error: Into<Box<dyn Error + Send + Sync>>, Target: Clone + Debug, MS::Service: Debug, Request: Debug,

Source§

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

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

impl<MS, Target, Req> Service<Req> for Pool<MS, Target, Req>
where MS: MakeService<Target, Req>, MS::Service: Load, <MS::Service as Load>::Metric: Debug, MS::MakeError: Into<Box<dyn Error + Send + Sync>>, MS::Error: Into<Box<dyn Error + Send + Sync>>, Target: Clone,

Source§

type Response = <Balance<Pin<Box<PoolDiscoverer<MS, Target, Req>>>, Req> as Service<Req>>::Response

Responses given by the service.
Source§

type Error = <Balance<Pin<Box<PoolDiscoverer<MS, Target, Req>>>, Req> as Service<Req>>::Error

Errors produced by the service.
Source§

type Future = <Balance<Pin<Box<PoolDiscoverer<MS, Target, Req>>>, Req> as Service<Req>>::Future

The future response value.
Source§

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, req: Req) -> Self::Future

Process the request and return the response asynchronously. Read more

Auto Trait Implementations§

§

impl<MS, Target, Request> !Freeze for Pool<MS, Target, Request>

§

impl<MS, Target, Request> !RefUnwindSafe for Pool<MS, Target, Request>

§

impl<MS, Target, Request> Send for Pool<MS, Target, Request>
where <MS as MakeService<Target, Request>>::Error: Sized, <MS as MakeService<Target, Request>>::MakeError: Sized, Request: Send, MS: Send, Target: Send, <MS as MakeService<Target, Request>>::Future: Send, <MS as MakeService<Target, Request>>::Service: Send,

§

impl<MS, Target, Request> Sync for Pool<MS, Target, Request>
where <MS as MakeService<Target, Request>>::Error: Sized, <MS as MakeService<Target, Request>>::MakeError: Sized, Request: Sync, MS: Sync, Target: Sync, <MS as MakeService<Target, Request>>::Future: Sync, <MS as MakeService<Target, Request>>::Service: Sync,

§

impl<MS, Target, Request> Unpin for Pool<MS, Target, Request>
where <MS as MakeService<Target, Request>>::Error: Sized, <MS as MakeService<Target, Request>>::MakeError: Sized, Request: Unpin,

§

impl<MS, Target, Request> !UnwindSafe for Pool<MS, Target, Request>

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, 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<M, S, Target, Request> MakeService<Target, Request> for M
where M: Service<Target, Response = S>, S: Service<Request>,

Source§

type Response = <S as Service<Request>>::Response

Responses given by the service
Source§

type Error = <S as Service<Request>>::Error

Errors produced by the service
Source§

type Service = S

The Service value created by this factory
Source§

type MakeError = <M as Service<Target>>::Error

Errors produced while building a service.
Source§

type Future = <M as Service<Target>>::Future

The future of the Service instance.
Source§

fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>

Returns Ready when the factory is able to create more services. Read more
Source§

fn make_service( &mut self, target: Target, ) -> <M as MakeService<Target, Request>>::Future

Create and return a new service value asynchronously.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V