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:
- Determines, via the provided
Picker, whichServicethe request corresponds to. - Waits (in
Service::poll_ready) for all services to be ready. - Calls the correct
Servicewith 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) -> SelfMake a new
Steerwith a list ofService's and aPicker.Note: the order of the
Service's is significant forPicker::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