userver: components::Server Class Reference
Loading...
Searching...
No Matches
components::Server Class Referencefinal

#include <userver/server/component.hpp>

Detailed Description

Component that listens for incoming requests, manages incoming connections and passes the requests to the appropriate handler.

Starts listening and accepting connections only after all the components are loaded.

All the classes inherited from server::handlers::HttpHandlerBase and registered in components list bind to the components::Server component.

components::Server Dynamic config

Static options of components::Server :

Server is configured by 'listener' and 'listener-monitor' entries. 'listener' is a required entry that describes the request processing socket. 'listener-monitor' is an optional entry that describes the special monitoring socket, used for getting statistics and processing utility requests that should succeed even is the main socket is under heavy pressure.

Name Description Default value
logger_access Set to logger name from components::Logging component to write access logs into it; do not set to avoid writing access logs.
logger_access_tskv Set to logger name from components::Logging component to write access logs in TSKV format into it; do not set to avoid writing access logs.
max_response_size_in_flight Drop incomming requests if the handler allows throttling and the size of waiting for send responses in bytes is greater than this value.
server-name Value to send in HTTP Server header. value from utils::GetUserverIdentifier()
listener Describes the request processing socket.
listener.address IPv6 or IPv4 network interface to bind to. "::" (all the IPv6 and IPv4 local interfaces)
listener.port Port to listen on. 0
listener.unix-socket Unix socket to listen on instead of listening on a port.
listener.unix-socket-permissions Unix socket file permissions. 600
listener.max_connections Max connections count to keep. 32768
listener.task_processor Task processor to process incoming requests. the 'default_task_processor' value from components::ManagerControllerComponent
listener.backlog Max count of new connections pending acceptance. 1024
listener.tls TLS settings.
listener.tls.ca.[] Paths to TLS CAs. Each of the elements: path to TLS CA.
listener.tls.cert Path to TLS certificate chain.
listener.tls.private-key Path to TLS certificate private key.
listener.tls.private-key-passphrase-name Passphrase name located in secdist.
listener.ports.[] Settings of listener port.
listener.ports.[].address IPv6 or IPv4 network interface to bind to. "::" (all the IPv6 and IPv4 local interfaces)
listener.ports.[].port Port to listen on. 0
listener.ports.[].unix-socket Unix socket to listen on instead of listening on a port.
listener.ports.[].unix-socket-permissions Unix socket file permissions. 600
listener.ports.[].tls TLS settings.
listener.ports.[].tls.ca.[] Paths to TLS CAs. Each of the elements: path to TLS CA.
listener.ports.[].tls.cert Path to TLS certificate chain.
listener.ports.[].tls.private-key Path to TLS certificate private key.
listener.ports.[].tls.private-key-passphrase-name Passphrase name located in secdist.
listener.handler-defaults Handler defaults options.
listener.handler-defaults.max_url_size Max path/URL size in bytes. 8192
listener.handler-defaults.max_request_size Max size of the whole data in bytes. 1024 * 1024
listener.handler-defaults.max_headers_size Max headers size in bytes. 65535
listener.handler-defaults.request_body_size_log_limit Trim the request to this size before logging. 512
listener.handler-defaults.request_headers_size_log_limit Trim request headers to this size before logging. 512
listener.handler-defaults.response_data_size_log_limit Trim responses to this size before logging. 512
listener.handler-defaults.parse_args_from_body Optional field to parse request according to x-www-form-urlencoded rules and make parameters accessible as query parameters. false
listener.handler-defaults.set_tracing_headers Whether to set http tracing headers (X-YaTraceId, X-YaSpanId, X-RequestId). true
listener.handler-defaults.deadline_propagation_enabled When false, disables deadline propagation by default in all HTTP handlers. Can be overridden by the corresponding option in server::handlers::HandlerBase. true
listener.handler-defaults.deadline_expired_status_code The HTTP status code to return if the request deadline expires. 498
listener.handler-defaults.enable_write_statistics Whether to write handler statistics. true
listener.connection Connection options.
listener.connection.in_buffer_size Size of the buffer to preallocate for request receive: bigger values use more RAM and less CPU. 32 * 1024
listener.connection.requests_queue_size_threshold Drop requests from handlers that allow throttling if there's more pending requests than allowed by this value. 100
listener.connection.keepalive_timeout Timeout in seconds to drop connection if there's not data received from it. 600
listener.connection.stream_close_check_delay Delay in microseconds of the start of abort check routine. 20ms
listener.connection.http-version HTTP protocol version. Possible values: 1.1, 2. 1.1
listener.connection.http2-session Settings of the HTTP/2.0 session.
listener.connection.http2-session.max_concurrent_streams Max number of concurrent open streams. 100
listener.connection.http2-session.max_frame_size Max size of the HTTP/2.0 frame. 16384
listener.connection.http2-session.initial_window_size The initial window size of the server. 65536
listener.shards How many concurrent tasks harvest data from a single socket; do not set if not sure what it is doing.
listener-monitor Describes the special monitoring socket, used for getting statistics and processing utility requests that should succeed even is the main socket is under heavy pressure.
listener-monitor.address IPv6 or IPv4 network interface to bind to. "::" (all the IPv6 and IPv4 local interfaces)
listener-monitor.port Port to listen on. 0
listener-monitor.unix-socket Unix socket to listen on instead of listening on a port.
listener-monitor.unix-socket-permissions Unix socket file permissions. 600
listener-monitor.max_connections Max connections count to keep. 32768
listener-monitor.task_processor Task processor to process incoming requests. the 'default_task_processor' value from components::ManagerControllerComponent
listener-monitor.backlog Max count of new connections pending acceptance. 1024
listener-monitor.tls TLS settings.
listener-monitor.tls.ca.[] Paths to TLS CAs. Each of the elements: path to TLS CA.
listener-monitor.tls.cert Path to TLS certificate chain.
listener-monitor.tls.private-key Path to TLS certificate private key.
listener-monitor.tls.private-key-passphrase-name Passphrase name located in secdist.
listener-monitor.ports.[] Settings of listener port.
listener-monitor.ports.[].address IPv6 or IPv4 network interface to bind to. "::" (all the IPv6 and IPv4 local interfaces)
listener-monitor.ports.[].port Port to listen on. 0
listener-monitor.ports.[].unix-socket Unix socket to listen on instead of listening on a port.
listener-monitor.ports.[].unix-socket-permissions Unix socket file permissions. 600
listener-monitor.ports.[].tls TLS settings.
listener-monitor.ports.[].tls.ca.[] Paths to TLS CAs. Each of the elements: path to TLS CA.
listener-monitor.ports.[].tls.cert Path to TLS certificate chain.
listener-monitor.ports.[].tls.private-key Path to TLS certificate private key.
listener-monitor.ports.[].tls.private-key-passphrase-name Passphrase name located in secdist.
listener-monitor.handler-defaults Handler defaults options.
listener-monitor.handler-defaults.max_url_size Max path/URL size in bytes. 8192
listener-monitor.handler-defaults.max_request_size Max size of the whole data in bytes. 1024 * 1024
listener-monitor.handler-defaults.max_headers_size Max headers size in bytes. 65535
listener-monitor.handler-defaults.request_body_size_log_limit Trim the request to this size before logging. 512
listener-monitor.handler-defaults.request_headers_size_log_limit Trim request headers to this size before logging. 512
listener-monitor.handler-defaults.response_data_size_log_limit Trim responses to this size before logging. 512
listener-monitor.handler-defaults.parse_args_from_body Optional field to parse request according to x-www-form-urlencoded rules and make parameters accessible as query parameters. false
listener-monitor.handler-defaults.set_tracing_headers Whether to set http tracing headers (X-YaTraceId, X-YaSpanId, X-RequestId). true
listener-monitor.handler-defaults.deadline_propagation_enabled When false, disables deadline propagation by default in all HTTP handlers. Can be overridden by the corresponding option in server::handlers::HandlerBase. true
listener-monitor.handler-defaults.deadline_expired_status_code The HTTP status code to return if the request deadline expires. 498
listener-monitor.handler-defaults.enable_write_statistics Whether to write handler statistics. true
listener-monitor.connection Connection options.
listener-monitor.connection.in_buffer_size Size of the buffer to preallocate for request receive: bigger values use more RAM and less CPU. 32 * 1024
listener-monitor.connection.requests_queue_size_threshold Drop requests from handlers that allow throttling if there's more pending requests than allowed by this value. 100
listener-monitor.connection.keepalive_timeout Timeout in seconds to drop connection if there's not data received from it. 600
listener-monitor.connection.stream_close_check_delay Delay in microseconds of the start of abort check routine. 20ms
listener-monitor.connection.http-version HTTP protocol version. Possible values: 1.1, 2. 1.1
listener-monitor.connection.http2-session Settings of the HTTP/2.0 session.
listener-monitor.connection.http2-session.max_concurrent_streams Max number of concurrent open streams. 100
listener-monitor.connection.http2-session.max_frame_size Max size of the HTTP/2.0 frame. 16384
listener-monitor.connection.http2-session.initial_window_size The initial window size of the server. 65536
listener-monitor.shards How many concurrent tasks harvest data from a single socket; do not set if not sure what it is doing.
set-response-server-hostname Set to true to add the X-YaTaxi-Server-Hostname header with instance name, set to false to not add the header. false
middleware-pipeline-builder Name of a component to build a server-wide middleware pipeline. default-server-middleware-pipeline-builder

Options inherited from components::RawComponentBase :

Name Description Default value
load-enabled Set to false to disable loading of the component. true
See also
HTTP, HTTPS, WebSocket

Definition at line 48 of file component.hpp.

+ Inheritance diagram for components::Server:

Public Member Functions

 Server (const components::ComponentConfig &component_config, const components::ComponentContext &component_context)
 
void OnAllComponentsLoaded () override
 
void OnAllComponentsAreStopping () override
 
const server::ServerGetServer () const
 
server::ServerGetServer ()
 
void AddHandler (const server::handlers::HttpHandlerBase &handler, engine::TaskProcessor &task_processor)
 
ComponentHealth GetComponentHealth () const override
 
void OnLoadingCancelled () override
 

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
 

Static Public Attributes

static constexpr std::string_view kName = "server"
 The default name of components::Server component.
 

Protected Types

using LoggableComponentBase = ComponentBase
 

Member Typedef Documentation

◆ LoggableComponentBase

Member Function Documentation

◆ GetComponentHealth()

ComponentHealth components::ComponentBase::GetComponentHealth ( ) const
inlineoverridevirtualinherited

Override this function to inform the world of the state of your component.

Warning
The function is called concurrently from multiple threads.

Reimplemented from components::RawComponentBase.

Reimplemented in server::handlers::Restart.

Definition at line 35 of file component_base.hpp.

◆ OnAllComponentsAreStopping()

void components::Server::OnAllComponentsAreStopping ( )
overridevirtual

Component may use this function to stop doing work before the stop of the components that depend on it.

Base components may override it and make final to do some work before the derived object constructor is called. Don't use it otherwise.

Reimplemented from components::ComponentBase.

◆ OnAllComponentsLoaded()

void components::Server::OnAllComponentsLoaded ( )
overridevirtual

Component may use this function to finalize registration of other components that depend on it (for example, handler components register in server component, and the latter uses OnAllComponentsLoaded() to start processing requests).

Base components may override it and make final to do some work after the derived object constructor is called. Don't use it otherwise.

Reimplemented from components::ComponentBase.

◆ OnLoadingCancelled()

void components::ComponentBase::OnLoadingCancelled ( )
inlineoverridevirtualinherited

Called once if the creation of any other component failed. If the current component expects some other component to take any action with the current component, this call is a signal that such action may never happen due to components loading was cancelled. Application components might not want to override it.

Reimplemented from components::RawComponentBase.

Definition at line 42 of file component_base.hpp.


The documentation for this class was generated from the following file: