Struct tonic::transport::Channel [−][src]
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
impl Channel
[src][−]
pub fn builder(uri: Uri) -> Endpoint
[src][−]
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.
pub fn balance_channel<K>(
capacity: usize
) -> (Self, Sender<Change<K, Endpoint>>) where
K: Hash + Eq + Send + Clone + 'static,
[src][−]
capacity: usize
) -> (Self, Sender<Change<K, Endpoint>>) where
K: Hash + Eq + Send + Clone + 'static,
Trait Implementations
impl Clone for Channel
[src][+]
impl Debug for Channel
[src][+]
impl GrpcService<BoxBody> for Channel
[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,
impl<T> From<T> for T
[src][+]
impl<T> Instrument for T
[src][+]
impl<T> Instrument for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> Pointable for T
[src][+]
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src][+]
V: MultiLane<T>,