pub struct HttpServer<S> { /* private fields */ }Expand description
An HTTP server.
Serves a single Service over a connection-oriented listener, optionally with TLS. The server can’t be run
directly: it is only usable by adding it to a supervisor.
§Supervision
The listen address is bound during initialization, so a failure to bind is raised before the supervised worker starts running, and a restart rebinds.
The server will attempt to gracefully shutdown existing connections when the parent supervisor signals shutdown. This will cause the worker to utilize the maximum allowable grace period during shutdown: it will attempt to take as long as necessary to gracefully shutdown existing connections, bounded only by the parent supervisor.
Implementations§
Source§impl<S> HttpServer<S>
impl<S> HttpServer<S>
Sourcepub fn from_listen_address(listen_address: ListenAddress, service: S) -> Self
pub fn from_listen_address(listen_address: ListenAddress, service: S) -> Self
Creates a server that will listen on the given address.
Sourcepub fn with_graceful_shutdown_timeout(self, timeout: Duration) -> Self
pub fn with_graceful_shutdown_timeout(self, timeout: Duration) -> Self
Sets the graceful shutdown timeout for this server.
During shutdown, the server will for all in-flight connections to complete before ultimately completing itself. When no timeout is specified, this will lead to the worker taking the maximum allowable time to shutdown if connections are blocked or otherwise “stuck.” Setting an explicit graceful shutdown timeout will cause the worker to bound how long it waits for in-flight connections to shutdown before forcefully completing and moving on.
Defaults to no timeout (wait as long as allowed).
Sourcepub fn with_tls_config(self, config: ServerConfig) -> Self
pub fn with_tls_config(self, config: ServerConfig) -> Self
Sets the TLS configuration for the server.
This enables TLS, after which the server only accepts connections that are encrypted with TLS.
Defaults to TLS being disabled.
Trait Implementations§
Source§impl<S, B> Supervisable for HttpServer<S>
impl<S, B> Supervisable for HttpServer<S>
Source§fn shutdown_strategy(&self) -> ShutdownStrategy
fn shutdown_strategy(&self) -> ShutdownStrategy
Source§fn initialize<'life0, 'async_trait>(
&'life0 self,
process_shutdown: ShutdownHandle,
) -> Pin<Box<dyn Future<Output = Result<SupervisorFuture, InitializationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize<'life0, 'async_trait>(
&'life0 self,
process_shutdown: ShutdownHandle,
) -> Pin<Box<dyn Future<Output = Result<SupervisorFuture, InitializationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<S> Freeze for HttpServer<S>where
S: Freeze,
impl<S> !RefUnwindSafe for HttpServer<S>
impl<S> Send for HttpServer<S>where
S: Send,
impl<S> Sync for HttpServer<S>where
S: Sync,
impl<S> Unpin for HttpServer<S>where
S: Unpin,
impl<S> !UnwindSafe for HttpServer<S>
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> 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::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Track for T
impl<T> Track for T
Source§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read moreSource§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more