Struct tonic::transport::channel::Channel[][src]

pub struct Channel { /* fields omitted */ }

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]

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.

pub fn balance_channel<K>(
    capacity: usize
) -> (Self, Sender<Change<K, Endpoint>>) where
    K: Hash + Eq + Send + Clone + 'static, 
[src]

Balance a list of Endpoint’s.

This creates a Channel that will listen to a stream of change events and will add or remove 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.

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]

impl<T> WithSubscriber for T[src]