[−][src]Struct tower::balance::p2c::Balance
Efficiently distributes requests across an arbitrary number of services.
See the module-level documentation for details.
Note that Balance requires that the Discover you use is Unpin in order to implement
Service. This is because it needs to be accessed from Service::poll_ready, which takes
&mut self. You can achieve this easily by wrapping your Discover in Box::pin before you
construct the Balance instance. For more details, see #319.
Implementations
impl<D, Req> Balance<D, Req> where
D: Discover,
D::Key: Hash,
D::Service: Service<Req>,
<D::Service as Service<Req>>::Error: Into<BoxError>, [src]
D: Discover,
D::Key: Hash,
D::Service: Service<Req>,
<D::Service as Service<Req>>::Error: Into<BoxError>,
pub fn new(discover: D) -> Self[src]
Constructs a load balancer that uses operating system entropy.
pub fn from_rng<R: Rng>(discover: D, rng: R) -> Result<Self, Error>[src]
Constructs a load balancer seeded with the provided random number generator.
pub fn len(&self) -> usize[src]
Returns the number of endpoints currently tracked by the balancer.
pub fn is_empty(&self) -> bool[src]
Returns whether or not the balancer is empty.
Trait Implementations
impl<D: Discover, Req> Debug for Balance<D, Req> where
D: Debug,
D::Key: Hash + Debug,
D::Service: Debug,
Req: Debug, [src]
D: Debug,
D::Key: Hash + Debug,
D::Service: Debug,
Req: Debug,
impl<D, Req> Service<Req> for Balance<D, Req> where
D: Discover + Unpin,
D::Key: Hash + Clone,
D::Error: Into<BoxError>,
D::Service: Service<Req> + Load,
<D::Service as Load>::Metric: Debug,
<D::Service as Service<Req>>::Error: Into<BoxError>, [src]
D: Discover + Unpin,
D::Key: Hash + Clone,
D::Error: Into<BoxError>,
D::Service: Service<Req> + Load,
<D::Service as Load>::Metric: Debug,
<D::Service as Service<Req>>::Error: Into<BoxError>,
type Response = <D::Service as Service<Req>>::Response
Responses given by the service.
type Error = BoxError
Errors produced by the service.
type Future = MapErr<<D::Service as Service<Req>>::Future, fn(_: <D::Service as Service<Req>>::Error) -> BoxError>
The future response value.
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>[src]
fn call(&mut self, request: Req) -> Self::Future[src]
Auto Trait Implementations
impl<D, Req> !RefUnwindSafe for Balance<D, Req>
impl<D, Req> Send for Balance<D, Req> where
D: Send,
Req: Send,
<D as Discover>::Key: Send,
<D as Discover>::Service: Send,
D: Send,
Req: Send,
<D as Discover>::Key: Send,
<D as Discover>::Service: Send,
impl<D, Req> Sync for Balance<D, Req> where
D: Sync,
Req: Sync,
<D as Discover>::Key: Sync,
<D as Discover>::Service: Sync,
D: Sync,
Req: Sync,
<D as Discover>::Key: Sync,
<D as Discover>::Service: Sync,
impl<D, Req> Unpin for Balance<D, Req> where
D: Unpin,
Req: Unpin,
<D as Discover>::Key: Eq,
D: Unpin,
Req: Unpin,
<D as Discover>::Key: Eq,
impl<D, Req> !UnwindSafe for Balance<D, Req>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> Instrument for T[src]
fn instrument(self, span: Span) -> Instrumented<Self>[src]
fn in_current_span(self) -> Instrumented<Self>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, Request> ServiceExt<Request> for T where
T: Service<Request> + ?Sized, [src]
T: Service<Request> + ?Sized,
fn ready_and(&mut self) -> ReadyAnd<'_, Self, Request>ⓘ where
Self: Sized, [src]
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>ⓘNotable traits for ReadyOneshot<T, Request>
impl<T, Request> Future for ReadyOneshot<T, Request> where
T: Service<Request>, type Output = Result<T, T::Error>; where
Self: Sized, [src]
Notable traits for ReadyOneshot<T, Request>
impl<T, Request> Future for ReadyOneshot<T, Request> where
T: Service<Request>, type Output = Result<T, T::Error>;Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>ⓘ where
Self: Sized, [src]
Self: Sized,
fn call_all<S>(self, reqs: S) -> CallAll<Self, S> where
Self: Sized,
Self::Error: Into<BoxError>,
S: Stream<Item = Request>, [src]
Self: Sized,
Self::Error: Into<BoxError>,
S: Stream<Item = Request>,
fn and_then<F>(self, f: F) -> AndThen<Self, F> where
Self: Sized,
F: Clone, [src]
Self: Sized,
F: Clone,
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F> where
Self: Sized,
F: FnOnce(Self::Response) -> Response + Clone, [src]
Self: Sized,
F: FnOnce(Self::Response) -> Response + Clone,
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F> where
Self: Sized,
F: FnOnce(Self::Error) -> Error + Clone, [src]
Self: Sized,
F: FnOnce(Self::Error) -> Error + Clone,
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F> where
Self: Sized,
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone, [src]
Self: Sized,
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
Self: Sized,
F: FnMut(NewRequest) -> Request + Clone, [src]
Self: Sized,
F: FnMut(NewRequest) -> Request + Clone,
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F> where
Self: Sized,
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Fut + Clone,
Fut: Future<Output = Result<Response, Error>>, [src]
Self: Sized,
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Fut + Clone,
Fut: Future<Output = Result<Response, Error>>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>, [src]
V: MultiLane<T>,