Struct tonic::transport::channel::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]
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,
pub fn borrow_mut(&mut self) -> &mut Tⓘ
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a Tⓘ
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tⓘ
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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.
pub 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]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
[src]
Notable traits for WithDispatch<T>
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
S: Into<Dispatch>,
pub fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for WithDispatch<T>
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;