Trait MakeService

Source
pub trait MakeService<Target, Request>: Sealed<(Target, Request)> {
    type Response;
    type Error;
    type Service: Service<Request, Response = Self::Response, Error = Self::Error>;
    type MakeError;
    type Future: Future<Item = Self::Service, Error = Self::MakeError>;

    // Required methods
    fn poll_ready(&mut self) -> Result<Async<()>, Self::MakeError>;
    fn make_service(&mut self, target: Target) -> Self::Future;
}
Expand description

Creates new Service values.

Acts as a service factory. This is useful for cases where new Service values must be produced. One case is a TCP servier listener. The listner accepts new TCP streams, obtains a new Service value using the MakeService trait, and uses that new Service value to process inbound requests on that new TCP stream.

This is essentially a trait alias for a Service of Services.

Required Associated Types§

Source

type Response

Responses given by the service

Source

type Error

Errors produced by the service

Source

type Service: Service<Request, Response = Self::Response, Error = Self::Error>

The Service value created by this factory

Source

type MakeError

Errors produced while building a service.

Source

type Future: Future<Item = Self::Service, Error = Self::MakeError>

The future of the Service instance.

Required Methods§

Source

fn poll_ready(&mut self) -> Result<Async<()>, Self::MakeError>

Returns Ready when the factory is able to process create more services.

If the service is at capacity, then NotReady is returned and the task is notified when the service becomes ready again. This function is expected to be called while on a task.

This is a best effort implementation. False positives are permitted. It is permitted for the service to return Ready from a poll_ready call and the next invocation of call results in an error.

Source

fn make_service(&mut self, target: Target) -> Self::Future

Create and return a new service value asynchronously.

Implementors§

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

Source§

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

Source§

type Service = S

Source§

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

Source§

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