Struct tonic::transport::Endpoint [−][src]
pub struct Endpoint { /* fields omitted */ }
transport
only.Channel builder.
This struct is used to build and configure HTTP/2 channels.
Implementations
impl Endpoint
[src]
impl Endpoint
[src]pub fn from_static(s: &'static str) -> Self
[src]
Convert an Endpoint
from a static string.
Panics
This function panics if the argument is an invalid URI.
Endpoint::from_static("https://example.com");
pub fn from_shared(s: impl Into<Bytes>) -> Result<Self, InvalidUri>
[src]
Convert an Endpoint
from shared bytes.
Endpoint::from_shared("https://example.com".to_string());
pub fn user_agent<T>(self, user_agent: T) -> Result<Self, Error> where
T: TryInto<HeaderValue>,
[src]
T: TryInto<HeaderValue>,
Set a custom user-agent header.
user_agent
will be prepended to Tonic’s default user-agent string (tonic/x.x.x
).
It must be a value that can be converted into a valid http::HeaderValue
or building
the endpoint will fail.
builder.user_agent("Greeter").expect("Greeter should be a valid header value"); // user-agent: "Greeter tonic/x.x.x"
pub fn timeout(self, dur: Duration) -> Self
[src]
Apply a timeout to each request.
builder.timeout(Duration::from_secs(5));
pub fn tcp_keepalive(self, tcp_keepalive: Option<Duration>) -> Self
[src]
Set whether TCP keepalive messages are enabled on accepted connections.
If None
is specified, keepalive is disabled, otherwise the duration
specified will be the time to remain idle before sending TCP keepalive
probes.
Default is no keepalive (None
)
pub fn concurrency_limit(self, limit: usize) -> Self
[src]
Apply a concurrency limit to each request.
builder.concurrency_limit(256);
pub fn rate_limit(self, limit: u64, duration: Duration) -> Self
[src]
Apply a rate limit to each request.
builder.rate_limit(32, Duration::from_secs(1));
pub fn initial_stream_window_size(self, sz: impl Into<Option<u32>>) -> Self
[src]
Sets the SETTINGS_INITIAL_WINDOW_SIZE
option for HTTP2
stream-level flow control.
Default is 65,535
pub fn initial_connection_window_size(self, sz: impl Into<Option<u32>>) -> Self
[src]
Sets the max connection-level flow control for HTTP2
Default is 65,535
pub fn tls_config(self, tls_config: ClientTlsConfig) -> Result<Self, Error>
[src]
tls
only.Configures TLS for the endpoint.
pub fn tcp_nodelay(self, enabled: bool) -> Self
[src]
Set the value of TCP_NODELAY
option for accepted connections. Enabled by default.
pub fn http2_keep_alive_interval(self, interval: Duration) -> Self
[src]
Set http2 KEEP_ALIVE_INTERVAL. Uses hyper
’s default otherwise.
pub fn keep_alive_timeout(self, duration: Duration) -> Self
[src]
Set http2 KEEP_ALIVE_TIMEOUT. Uses hyper
’s default otherwise.
pub fn keep_alive_while_idle(self, enabled: bool) -> Self
[src]
Set http2 KEEP_ALIVE_WHILE_IDLE. Uses hyper
’s default otherwise.
pub async fn connect(&self) -> Result<Channel, Error>
[src]
Create a channel from this config.
pub fn connect_lazy(&self) -> Result<Channel, Error>
[src]
Create a channel from this config.
The channel returned by this method does not attempt to connect to the endpoint until first use.
pub async fn connect_with_connector<C>(
&self,
connector: C
) -> Result<Channel, Error> where
C: MakeConnection<Uri> + Send + 'static,
C::Connection: Unpin + Send + 'static,
C::Future: Send + 'static,
Box<dyn Error + Send + Sync>: From<C::Error> + Send + 'static,
[src]
&self,
connector: C
) -> Result<Channel, Error> where
C: MakeConnection<Uri> + Send + 'static,
C::Connection: Unpin + Send + 'static,
C::Future: Send + 'static,
Box<dyn Error + Send + Sync>: From<C::Error> + Send + 'static,
Connect with a custom connector.
This allows you to build a Channel that uses a non-HTTP transport.
See the uds
example for an example on how to use this function to build channel that
uses a Unix socket transport.
pub fn uri(&self) -> &Uri
[src]
Get the endpoint uri.
let endpoint = Endpoint::from_static("https://example.com"); assert_eq!(endpoint.uri(), &Uri::from_static("https://example.com"));
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Endpoint
impl !RefUnwindSafe for Endpoint
impl !UnwindSafe for Endpoint
impl !UnwindSafe for Endpoint
Blanket Implementations
impl<T> Instrument 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]
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<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
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;