[−][src]Struct tonic::transport::Channel
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
on 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.
Methods
impl Channel
[src]
pub fn builder(uri: Uri) -> Endpoint
[src]
Create a [Endpoint
] builder that can create a [Channel
]'s.
pub fn from_static(s: &'static str) -> Endpoint
[src]
Create an Endpoint
from a static string.
Channel::from_static("https://example.com");
pub fn from_shared(s: impl Into<Bytes>) -> Result<Endpoint, InvalidUri>
[src]
Create an Endpoint
from shared bytes.
Channel::from_shared("https://example.com");
pub fn balance_list(list: impl Iterator<Item = Endpoint>) -> Self
[src]
Balance a list of [Endpoint
]'s.
This creates a [Channel
] that will load balance accross all the
provided endpoints.
Trait Implementations
impl Clone for Channel
[src]
impl Debug for Channel
[src]
impl GrpcService<BoxBody> for Channel
[src]
type ResponseBody = Body
Responses body given by the service.
type Error = Error
Errors produced by the service.
type Future = ResponseFuture
The future response value.
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>>
[src]
fn call(&mut self, request: Request<BoxBody>) -> Self::Future
[src]
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
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,
ⓘImportant traits for &'_ mut Ffn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
ⓘImportant traits for Instrumented<T>fn instrument(self, span: Span) -> Instrumented<Self>
[src]
ⓘImportant traits for Instrumented<T>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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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.
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>,
impl<T> WithSubscriber for T
[src]
ⓘImportant traits for WithDispatch<T>fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,