userver: components::TcpAcceptorBase Class Reference
Loading...
Searching...
No Matches
components::TcpAcceptorBase Class Referenceabstract

#include <userver/components/tcp_acceptor_base.hpp>

Detailed Description

Component for accepting incoming TCP connections.

Each accepted socket is processed in a new coroutine by ProcessSocket of the derived class.

Static options of components::TcpAcceptorBase :

Name Description Default value
port Port to listen on.
unix-socket Unix socket to listen on instead of listening on a port.
task_processor Task processor to accept incoming connections. the 'default_task_processor' value from components::ManagerControllerComponent
backlog Max count of new connections pending acceptance. 1024
no_delay Whether to set the TCP_NODELAY option on incoming sockets. true
sockets_task_processor Task processor to process accepted sockets. value of task_processor

Options inherited from components::ComponentBase :

Name Description Default value
load-enabled Set to false to disable loading of the component. true
See also
TCP half-duplex server with static configs validation
Examples
samples/tcp_full_duplex_service/main.cpp, and samples/tcp_service/main.cpp.

Definition at line 32 of file tcp_acceptor_base.hpp.

+ Inheritance diagram for components::TcpAcceptorBase:

Public Member Functions

 TcpAcceptorBase (const ComponentConfig &, const ComponentContext &)
 
ComponentHealth GetComponentHealth () const override
 
void OnLoadingCancelled () override
 
void OnAllComponentsLoaded () override
 
void OnAllComponentsAreStopping () override
 

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
 

Protected Types

using LoggableComponentBase = ComponentBase
 

Protected Member Functions

virtual void ProcessSocket (engine::io::Socket &&sock)=0
 

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::ComponentBase::OnAllComponentsAreStopping ( )
inlineoverridevirtualinherited

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::RawComponentBase.

Reimplemented in components::Server, and urabbitmq::ConsumerComponentBase.

Definition at line 58 of file component_base.hpp.

◆ OnAllComponentsLoaded()

void components::ComponentBase::OnAllComponentsLoaded ( )
inlineoverridevirtualinherited

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::RawComponentBase.

Reimplemented in components::Server, server::handlers::Ping, and urabbitmq::ConsumerComponentBase.

Definition at line 51 of file component_base.hpp.

◆ 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.

◆ ProcessSocket()

virtual void components::TcpAcceptorBase::ProcessSocket ( engine::io::Socket && sock)
protectedpure virtual

Override this function to process incoming sockets.

Warning
The function is called concurrently from multiple threads on each new socket.

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