Github   Telegram
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
components::Server Class Referencefinal

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

#include <userver/server/component.hpp>

+ Inheritance diagram for components::Server:
+ Collaboration 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)
 
- Public Member Functions inherited from components::LoggableComponentBase
 LoggableComponentBase (const ComponentConfig &, const ComponentContext &)
 
 LoggableComponentBase (LoggableComponentBase &&)=delete
 
 LoggableComponentBase (const LoggableComponentBase &)=delete
 
 ~LoggableComponentBase () override=default
 
ComponentHealth GetComponentHealth () const override
 
void OnLoadingCancelled () override
 
void OnAllComponentsLoaded () override
 
void OnAllComponentsAreStopping () override
 

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
 
- Static Public Member Functions inherited from components::LoggableComponentBase
static yaml_config::Schema GetStaticConfigSchema ()
 

Static Public Attributes

static constexpr std::string_view kName = "server"
 

Detailed Description

Component that listens for incomming requests, manages incomming 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.

Dynamic config

Static options:

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 set it to the size of response in bytes and the component will drop bigger responses from handlers that allow trottling -
server-name value to send in HTTP Server header value from utils::GetUserverIdentifier()
listener (required) see below -
listener-monitor see below -
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

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.

Each of the 'listener' and 'listener-monitor' may be configured with the following options:

Name Description Default value
port port to listen on 0
unix-socket unix socket to listen on instead of listening on a port ''
max_connections max connections count to keep 32768
task_processor task processor to process incomming requests -
backlog max count of new coneections pending acceptance 1024
handler-defaults.max_url_size max path/URL size or empty to not limit 8192
handler-defaults.max_request_size max size of the whole request 1024 * 1024
handler-defaults.max_headers_size max request headers size 65536
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
connection.in_buffer_size size of the buffer to preallocate for request receive: bigger values use more RAM and less CPU 32 * 1024
connection.requests_queue_size_threshold drop requests from handlers that allow trottling if there's more pending requests than allowed by this value 100
connection.keepalive_timeout timeout in seconds to drop connection if there's not data received from it 600
shards how many concurrent tasks harvest data from a single socket; do not set if not sure what it is doing -

Definition at line 75 of file component.hpp.

Member Data Documentation

◆ kName

constexpr std::string_view components::Server::kName = "server"
staticconstexpr

Definition at line 77 of file component.hpp.


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