Struct teaclave_rpc::transport::Channel
source · [−]pub struct Channel { /* private fields */ }
Expand description
A default batteries included transport
channel.
This provides a fully featured http2 gRPC client based on [hyper::Client
]
and tower
services.
Multiplexing requests
Sending a request on a channel requires a &mut self
and thus can only send
one request in flight. This is intentional and is required to follow the Service
contract from the tower
library which this channel implementation is built on
top of.
tower
itself has a concept of poll_ready
which is the main mechanism to apply
back pressure. poll_ready
takes a &mut self
and when it returns Poll::Ready
we know the Service
is able to accept only one request before we must poll_ready
again. Due to this fact any async fn
that wants to poll for readiness and submit
the request must have a &mut self
reference.
To work around this and to ease the use of the channel, Channel
provides a
Clone
implementation that is cheap. This is because at the very top level
the channel is backed by a tower_buffer::Buffer
which runs the connection
in a background task and provides a mpsc
channel interface. Due to this
cloning the Channel
type is cheap and encouraged.
Implementations
sourceimpl Channel
impl Channel
sourcepub fn from_static(s: &'static str) -> Endpoint
pub fn from_static(s: &'static str) -> Endpoint
Create an Endpoint
from a static string.
Channel::from_static("https://example.com");
Create an Endpoint
from shared bytes.
Channel::from_shared("https://example.com");
sourcepub fn balance_list(list: impl Iterator<Item = Endpoint>) -> Channel
pub fn balance_list(list: impl Iterator<Item = Endpoint>) -> Channel
sourcepub fn balance_channel<K>(
capacity: usize
) -> (Channel, Sender<Change<K, Endpoint>>)where
K: 'static + Hash + Eq + Send + Clone,
pub fn balance_channel<K>(
capacity: usize
) -> (Channel, Sender<Change<K, Endpoint>>)where
K: 'static + Hash + Eq + Send + Clone,
Trait Implementations
sourceimpl Service<Request<UnsyncBoxBody<Bytes, Status>>> for Channel
impl Service<Request<UnsyncBoxBody<Bytes, Status>>> for Channel
Auto Trait Implementations
impl !RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl !UnwindSafe for Channel
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T, ReqBody, ResBody> GrpcService<ReqBody> for Twhere
T: Service<Request<ReqBody>, Response = Response<ResBody>>,
<T as Service<Request<ReqBody>>>::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
ResBody: Body,
<ResBody as Body>::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
impl<T, ReqBody, ResBody> GrpcService<ReqBody> for Twhere
T: Service<Request<ReqBody>, Response = Response<ResBody>>,
<T as Service<Request<ReqBody>>>::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
ResBody: Body,
<ResBody as Body>::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
type ResponseBody = ResBody
type ResponseBody = ResBody
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>>
Ready
when the service is able to process requests. Read moresourceimpl<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>
T
in a tonic::Request
sourceimpl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
sourcefn into_make_service(self) -> IntoMakeService<S>
fn into_make_service(self) -> IntoMakeService<S>
MakeService
, that is a Service
whose
response is another service. Read moresourceimpl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
sourcefn ready(&mut self) -> Ready<'_, Self, Request>
fn ready(&mut self) -> Ready<'_, Self, Request>
sourcefn ready_and(&mut self) -> Ready<'_, Self, Request>
fn ready_and(&mut self) -> Ready<'_, Self, Request>
ServiceExt::ready
method insteadsourcefn ready_oneshot(self) -> ReadyOneshot<Self, Request>
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>
sourcefn oneshot(self, req: Request) -> Oneshot<Self, Request>
fn oneshot(self, req: Request) -> Oneshot<Self, Request>
Service
, calling with the providing request once it is ready.sourcefn call_all<S>(self, reqs: S) -> CallAll<Self, S>where
Self::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
S: Stream<Item = Request>,
fn call_all<S>(self, reqs: S) -> CallAll<Self, S>where
Self::Error: Into<Box<dyn Error + Sync + Send + 'static, Global>>,
S: Stream<Item = Request>,
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,
poll_ready
method. Read moresourcefn 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,
poll_ready
method. Read moresourcefn 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,
poll_ready
method. Read moresourcefn 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,
Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more