Struct Steer

pub struct Steer<S, F, Req> { /* private fields */ }

Steer manages a list of Services which all handle the same type of request.

An example use case is a sharded service. It accepts new requests, then:

  1. Determines, via the provided Picker, which Service the request corresponds to.
  2. Waits (in Service::poll_ready) for all services to be ready.
  3. Calls the correct Service with the request, and returns a future corresponding to the call.

Note that Steer must wait for all services to be ready since it can't know ahead of time which Service the next message will arrive for, and is unwilling to buffer items indefinitely. This will cause head-of-line blocking unless paired with a Service that does buffer items indefinitely, and thus always returns Poll::Ready. For example, wrapping each component service with a Buffer with a high enough limit (the maximum number of concurrent requests) will prevent head-of-line blocking in Steer.

Implementations

impl<S, F, Req> Steer<S, F, Req>

fn new(services: impl IntoIterator<Item = S>, router: F) -> Self

Make a new Steer with a list of Service's and a Picker.

Note: the order of the Service's is significant for Picker::pick's return value.

Trait Implementations

impl<S, F, Req> Clone for Steer<S, F, Req> where S: Clone, F: Clone,

fn clone(&self) -> Self

impl<S, F, Req> Debug for Steer<S, F, Req> where S: Debug, F: Debug,

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

impl<S, Req, F> Service<Req> for Steer<S, F, Req> where S: Service<Req>, F: Picker<S, Req>,

type Response = <S as Service<Req>>::Response;
type Error = <S as Service<Req>>::Error;
type Future = <S as Service<Req>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Req) -> Self::Future

Auto Trait Implementations

impl<S, F, Req> Freeze for Steer<S, F, Req> where F: Freeze, Vec<S>: Freeze, PhantomData<Req>: Freeze,

impl<S, F, Req> RefUnwindSafe for Steer<S, F, Req> where F: RefUnwindSafe, Vec<S>: RefUnwindSafe, PhantomData<Req>: RefUnwindSafe,

impl<S, F, Req> Send for Steer<S, F, Req> where F: Send, Vec<S>: Send, PhantomData<Req>: Send,

impl<S, F, Req> Sync for Steer<S, F, Req> where F: Sync, Vec<S>: Sync, PhantomData<Req>: Sync,

impl<S, F, Req> Unpin for Steer<S, F, Req> where F: Unpin, Vec<S>: Unpin, PhantomData<Req>: Unpin,

impl<S, F, Req> UnsafeUnpin for Steer<S, F, Req> where F: UnsafeUnpin, Vec<S>: UnsafeUnpin, PhantomData<Req>: UnsafeUnpin,

impl<S, F, Req> UnwindSafe for Steer<S, F, Req> where F: UnwindSafe, Vec<S>: UnwindSafe, PhantomData<Req>: UnwindSafe,

Blanket Implementations

impl<C, Target> MakeConnection<Target> for Steer<S, F, Req> where C: Service<Target>, <C as Service<Target>>::Response: AsyncRead + AsyncWrite,

impl<M, S, Target, Request> MakeService<Target, Request> for Steer<S, F, Req> where M: Service<Target, Response = S>, S: Service<Request>,

impl<T> Any for Steer<S, F, Req> where T: 'static + ?Sized,

impl<T> Borrow<T> for Steer<S, F, Req> where T: ?Sized,

impl<T> BorrowMut<T> for Steer<S, F, Req> where T: ?Sized,

impl<T> CloneToUninit for Steer<S, F, Req> where T: Clone,

impl<T> From<T> for Steer<S, F, Req>

impl<T> Instrument for Steer<S, F, Req>

impl<T> ToOwned for Steer<S, F, Req> where T: Clone,

impl<T> WithSubscriber for Steer<S, F, Req>

impl<T, Request> ServiceExt<Request> for Steer<S, F, Req> where T: Service<Request> + ?Sized,

impl<T, U> Into<U> for Steer<S, F, Req> where U: From<T>,

impl<T, U> TryFrom<U> for Steer<S, F, Req> where U: Into<T>,

impl<T, U> TryInto<U> for Steer<S, F, Req> where U: TryFrom<T>,