pub struct ServeOptions { /* private fields */ }Expand description
How serve_with runs its listener.
§Examples
use std::time::Duration;
use structured_proxy::ServeOptions;
let options = ServeOptions::new()
.max_connections(10_000)
.idle_timeout(Some(Duration::from_secs(120)));Implementations§
Source§impl ServeOptions
impl ServeOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Cleartext, with no limit on connections; a connection idle for 60 s is closed, a client gets 30 s to send the headers of an HTTP/1.1 request and 10 s to finish a TLS handshake, and a shutdown waits at most 25 s for open connections.
Sourcepub fn drain_timeout(self, timeout: Option<Duration>) -> Self
pub fn drain_timeout(self, timeout: Option<Duration>) -> Self
How long a shutdown (serve_with_shutdown) waits for the
connections still open to finish what they serve; the ones open after
it are closed. None waits for all of them.
Sourcepub fn idle_timeout(self, timeout: Option<Duration>) -> Self
pub fn idle_timeout(self, timeout: Option<Duration>) -> Self
Close a connection that has had no request in flight for timeout
(gracefully: HTTP/2 gets a GOAWAY); None keeps idle connections
open. A request counts until its response body ends, so a stream keeps
its connection. Without it an idle client holds a
max_connections slot for as long as it likes.
A connection upgraded to another protocol (a WebSocket in a fallback)
leaves HTTP and this timeout with it; it keeps its slot until it
closes.
Sourcepub fn header_read_timeout(self, timeout: Duration) -> Self
pub fn header_read_timeout(self, timeout: Duration) -> Self
How long an HTTP/1.1 client has to send a request’s headers, so a client that trickles them in holds no connection for long.
Sourcepub fn tls_handshake_timeout(self, timeout: Duration) -> Self
pub fn tls_handshake_timeout(self, timeout: Duration) -> Self
How long a client has to finish its TLS handshake before the connection is dropped, so a stalled client holds neither a task nor a connection slot.
Sourcepub fn max_connections(self, max: usize) -> Self
pub fn max_connections(self, max: usize) -> Self
Serve at most max connections at once: past it, the next connection
is accepted when one closes, and waits in the listen backlog until then.
§Panics
max is zero, which would never accept a connection.
Sourcepub fn tls(self, config: ServerConfig) -> Self
pub fn tls(self, config: ServerConfig) -> Self
Terminate TLS with config. Set its alpn_protocols to h2 and
http/1.1 for gRPC clients to get HTTP/2; an empty list is filled in
with those two. A client certificate the config verifies reaches a
tonic upstream as Request::peer_certs.
Trait Implementations§
Source§impl Clone for ServeOptions
impl Clone for ServeOptions
Source§impl Debug for ServeOptions
impl Debug for ServeOptions
Auto Trait Implementations§
impl !RefUnwindSafe for ServeOptions
impl !UnwindSafe for ServeOptions
impl Freeze for ServeOptions
impl Send for ServeOptions
impl Sync for ServeOptions
impl Unpin for ServeOptions
impl UnsafeUnpin for ServeOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request