pub struct Endpoint { /* private fields */ }
Expand description

Channel builder.

This struct is used to build and configure HTTP/2 channels.

Implementations

Convert an Endpoint from a static string.

Panics

This function panics if the argument is an invalid URI.

Endpoint::from_static("https://example.com");

Convert an Endpoint from shared bytes.

Endpoint::from_shared("https://example.com".to_string());

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"

Apply a timeout to each request.

builder.timeout(Duration::from_secs(5));
Notes

This does not set the timeout metadata (grpc-timeout header) on the request, meaning the server will not be informed of this timeout, for that use Request::set_timeout.

Apply a timeout to connecting to the uri.

Defaults to no timeout.

builder.connect_timeout(Duration::from_secs(5));

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)

Apply a concurrency limit to each request.

builder.concurrency_limit(256);

Apply a rate limit to each request.

builder.rate_limit(32, Duration::from_secs(1));

Sets the SETTINGS_INITIAL_WINDOW_SIZE option for HTTP2 stream-level flow control.

Default is 65,535

Sets the max connection-level flow control for HTTP2

Default is 65,535

Configures TLS for the endpoint.

Set the value of TCP_NODELAY option for accepted connections. Enabled by default.

Set http2 KEEP_ALIVE_INTERVAL. Uses hyper’s default otherwise.

Set http2 KEEP_ALIVE_TIMEOUT. Uses hyper’s default otherwise.

Set http2 KEEP_ALIVE_WHILE_IDLE. Uses hyper’s default otherwise.

Sets whether to use an adaptive flow control. Uses hyper’s default otherwise.

Create a channel from this config.

Create a channel from this config.

The channel returned by this method does not attempt to connect to the endpoint until first use.

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.

The connect_timeout will still be applied.

Connect with a custom connector lazily.

This allows you to build a Channel that uses a non-HTTP transport connec to it lazily.

See the uds example for an example on how to use this function to build channel that uses a Unix socket transport.

Get the endpoint uri.

let endpoint = Endpoint::from_static("https://example.com");

assert_eq!(endpoint.uri(), &Uri::from_static("https://example.com"));

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more