Struct ginepro::LoadBalancedChannel
source · [−]pub struct LoadBalancedChannel(_);
Expand description
Implements tonic GrpcService
for a client-side load balanced Channel
(using The Power of Two Choices
).
#[tokio::main]
async fn main() {
use ginepro::LoadBalancedChannel;
use shared_proto::pb::tester_client::TesterClient;
use std::convert::TryInto;
let load_balanced_channel = LoadBalancedChannel::builder(("my.hostname", 5000))
.channel()
.await
.expect("failed to construct LoadBalancedChannel");
let client = TesterClient::new(load_balanced_channel);
}
Implementations
sourceimpl LoadBalancedChannel
impl LoadBalancedChannel
sourcepub fn builder<S>(
service_definition: S
) -> LoadBalancedChannelBuilder<DnsResolver, S> where
S: TryInto<ServiceDefinition> + Send + Sync + 'static,
S::Error: Into<Box<dyn Error + Send + Sync>> + Send + Sync,
pub fn builder<S>(
service_definition: S
) -> LoadBalancedChannelBuilder<DnsResolver, S> where
S: TryInto<ServiceDefinition> + Send + Sync + 'static,
S::Error: Into<Box<dyn Error + Send + Sync>> + Send + Sync,
Start configuring a LoadBalancedChannel
by passing in the ServiceDefinition
for the gRPC server service you want to call - e.g. my.service.uri
and 5000
.
All the service endpoints of a ServiceDefinition
will be
constructed by resolving IPs for ServiceDefinition::hostname
, and
using the port number ServiceDefinition::port
.
Trait Implementations
sourceimpl Clone for LoadBalancedChannel
impl Clone for LoadBalancedChannel
sourcefn clone(&self) -> LoadBalancedChannel
fn clone(&self) -> LoadBalancedChannel
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for LoadBalancedChannel
impl Debug for LoadBalancedChannel
sourceimpl From<LoadBalancedChannel> for Channel
impl From<LoadBalancedChannel> for Channel
sourcefn from(channel: LoadBalancedChannel) -> Self
fn from(channel: LoadBalancedChannel) -> Self
Converts to this type from the input type.
sourceimpl Service<Request<UnsyncBoxBody<Bytes, Status>>> for LoadBalancedChannel
impl Service<Request<UnsyncBoxBody<Bytes, Status>>> for LoadBalancedChannel
type Response = Response<<Channel as GrpcService<UnsyncBoxBody<Bytes, Status>>>::ResponseBody>
type Response = Response<<Channel as GrpcService<UnsyncBoxBody<Bytes, Status>>>::ResponseBody>
Responses given by the service.
type Error = <Channel as GrpcService<UnsyncBoxBody<Bytes, Status>>>::Error
type Error = <Channel as GrpcService<UnsyncBoxBody<Bytes, Status>>>::Error
Errors produced by the service.
type Future = <Channel as GrpcService<UnsyncBoxBody<Bytes, Status>>>::Future
type Future = <Channel as GrpcService<UnsyncBoxBody<Bytes, Status>>>::Future
The future response value.
Auto Trait Implementations
impl !RefUnwindSafe for LoadBalancedChannel
impl Send for LoadBalancedChannel
impl Sync for LoadBalancedChannel
impl Unpin for LoadBalancedChannel
impl !UnwindSafe for LoadBalancedChannel
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T, ReqBody, ResBody> GrpcService<ReqBody> for T where
T: Service<Request<ReqBody>, Response = Response<ResBody>>,
ResBody: Body,
<T as Service<Request<ReqBody>>>::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
<ResBody as Body>::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
impl<T, ReqBody, ResBody> GrpcService<ReqBody> for T where
T: Service<Request<ReqBody>, Response = Response<ResBody>>,
ResBody: Body,
<T as Service<Request<ReqBody>>>::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
<ResBody as Body>::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
type ResponseBody = ResBody
type ResponseBody = ResBody
Responses body given by the service.
sourcefn poll_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), <T as GrpcService<ReqBody>>::Error>>
fn poll_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), <T as GrpcService<ReqBody>>::Error>>
Returns Ready
when the service is able to process requests. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
sourceimpl<T, Request> ServiceExt<Request> for T where
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for T where
T: Service<Request> + ?Sized,
sourcefn ready(&mut self) -> Ready<'_, Self, Request>
fn ready(&mut self) -> Ready<'_, Self, Request>
Yields a mutable reference to the service when it is ready to accept a request.
sourcefn ready_and(&mut self) -> Ready<'_, Self, Request>
fn ready_and(&mut self) -> Ready<'_, Self, Request>
please use the ServiceExt::ready
method instead
Yields a mutable reference to the service when it is ready to accept a request.
sourcefn ready_oneshot(self) -> ReadyOneshot<Self, Request>
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>
Yields the service when it is ready to accept a request.
sourcefn oneshot(self, req: Request) -> Oneshot<Self, Request>
fn oneshot(self, req: Request) -> Oneshot<Self, Request>
Consume this Service
, calling with the providing request once it is ready.
sourcefn call_all<S>(self, reqs: S) -> CallAll<Self, S> where
S: Stream<Item = Request>,
Self::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
fn call_all<S>(self, reqs: S) -> CallAll<Self, S> where
S: Stream<Item = Request>,
Self::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
sourcefn and_then<F>(self, f: F) -> AndThen<Self, F> where
F: Clone,
fn and_then<F>(self, f: F) -> AndThen<Self, F> where
F: Clone,
Executes a new future after this service’s future resolves. This does
not alter the behaviour of the poll_ready
method. Read more
sourcefn map_response<F, Response>(self, f: F) -> MapResponse<Self, F> where
F: FnOnce(Self::Response) -> Response + Clone,
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F> where
F: FnOnce(Self::Response) -> Response + Clone,
Maps this service’s response value to a different value. This does not
alter the behaviour of the poll_ready
method. Read more
sourcefn map_err<F, Error>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(Self::Error) -> Error + Clone,
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(Self::Error) -> Error + Clone,
Maps this service’s error value to a different value. This does not
alter the behaviour of the poll_ready
method. Read more
sourcefn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F> where
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F> where
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
Maps this service’s result type (Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more
sourcefn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
F: FnMut(NewRequest) -> Request,
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
F: FnMut(NewRequest) -> Request,
Composes a function in front of the service. Read more
sourcefn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F> where
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Fut + Clone,
Fut: Future<Output = Result<Response, Error>>,
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F> where
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Fut + Clone,
Fut: Future<Output = Result<Response, Error>>,
Composes an asynchronous function after this service. Read more
sourcefn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F> where
F: FnMut(Self::Future) -> Fut,
Error: From<Self::Error>,
Fut: Future<Output = Result<Response, Error>>,
fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F> where
F: FnMut(Self::Future) -> Fut,
Error: From<Self::Error>,
Fut: Future<Output = Result<Response, Error>>,
Composes a function that transforms futures produced by the service. Read more
sourcefn boxed(self) -> BoxService<Request, Self::Response, Self::Error> where
Self: 'static + Send,
Self::Future: 'static,
Self::Future: Send,
fn boxed(self) -> BoxService<Request, Self::Response, Self::Error> where
Self: 'static + Send,
Self::Future: 'static,
Self::Future: Send,
sourcefn boxed_clone(self) -> BoxCloneService<Request, Self::Response, Self::Error> where
Self: 'static + Clone + Send,
Self::Future: 'static,
Self::Future: Send,
fn boxed_clone(self) -> BoxCloneService<Request, Self::Response, Self::Error> where
Self: 'static + Clone + Send,
Self::Future: 'static,
Self::Future: Send,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more