Struct ginepro::LoadBalancedChannel [−][src]
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; let load_balanced_channel = LoadBalancedChannel::builder(("my_hostname", 5000)) .await .expect("failed to read system conf") .channel(); let client = TesterClient::new(load_balanced_channel); }
Implementations
pub async fn builder<H: Into<ServiceDefinition>>(
service_definition: H
) -> Result<LoadBalancedChannelBuilder<DnsResolver>, Error>
pub async fn builder<H: Into<ServiceDefinition>>(
service_definition: H
) -> Result<LoadBalancedChannelBuilder<DnsResolver>, Error>
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
Performs the conversion.
type Response = Response<<Channel as GrpcService<BoxBody>>::ResponseBody>
type Response = Response<<Channel as GrpcService<BoxBody>>::ResponseBody>
Responses given by the service.
type Error = <Channel as GrpcService<BoxBody>>::Error
type Error = <Channel as GrpcService<BoxBody>>::Error
Errors produced by the service.
type Future = <Channel as GrpcService<BoxBody>>::Future
type Future = <Channel as GrpcService<BoxBody>>::Future
The future response value.
Returns Poll::Ready(Ok(()))
when the service is able to process requests. Read more
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
Mutably borrows from an owned value. Read more
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>>,
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.
pub fn poll_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), <T as GrpcService<ReqBody>>::Error>>
pub 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
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Wrap the input message T
in a tonic::Request
Yields a mutable reference to the service when it is ready to accept a request.
please use the ServiceExt::ready
method instead
Yields a mutable reference to the service when it is ready to accept a request.
Yields the service when it is ready to accept a request.
Consume this Service
, calling with the providing request once it is ready.
Executes a new future after this service’s future resolves. This does
not alter the behaviour of the poll_ready
method. Read more
fn 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
Maps this service’s error value to a different value. This does not
alter the behaviour of the poll_ready
method. Read more
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
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
F: FnMut(NewRequest) -> Request + Clone,
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
F: FnMut(NewRequest) -> Request + Clone,
Composes a function in front of the service. Read more
Composes an asynchronous function after this service. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more