Struct tower::steer::Steer[][src]

pub struct Steer<S, F, Req> { /* fields omitted */ }
This is supported on crate feature steer only.

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 coresponds 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.


impl<S, F, Req> Steer<S, F, Req>[src]

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

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

impl<S: Debug, F: Debug, Req: Debug> Debug for Steer<S, F, Req>[src]

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

type Response = S::Response

Responses given by the service.

type Error = S::Error

Errors produced by the service.

type Future = S::Future

The future response value.

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

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

impl<T, Request> ServiceExt<Request> for T where
    T: Service<Request> + ?Sized

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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