userver: congestion_control::Component Class Reference
Loading...
Searching...
No Matches
congestion_control::Component Class Referencefinal

#include <userver/congestion_control/component.hpp>

Detailed Description

Component to limit too active requests, also known as CC.

congestion_control::Component Dynamic config

Static options of congestion_control::Component :

Name Description Default value
fake-mode If set, an actual throttling is skipped, but FSM is still working and producing informational logs. false
min-cpu Force fake-mode if the current cpu number is less than the specified value. 1
only-rtc If set to true and hostinfo::IsInRtc() returns false then forces the fake-mode. true
status-code HTTP status code for ratelimited responses. 429

Options inherited from components::ComponentBase :

Name Description Default value
load-enabled Set to false to disable loading of the component. true

Static configuration example:

# yaml
congestion-control:
fake-mode: true
min-cpu: 2
only-rtc: false
# Uncomment if you want to change status code for ratelimited responses
# status-code: 503
# Common component options
load-enabled: true
Examples
grpc-generic-proxy/main.cpp, and samples/grpc_middleware_service/main.cpp.

Definition at line 36 of file component.hpp.

+ Inheritance diagram for congestion_control::Component:

Public Member Functions

 Component (const components::ComponentConfig &, const components::ComponentContext &)
 
server::congestion_control::LimiterGetServerLimiter ()
 
server::congestion_control::SensorGetServerSensor ()
 
const congestion_control::ControllerGetServerController () const
 
ComponentHealth GetComponentHealth () const override
 
void OnLoadingCancelled () override
 
void OnGracefulShutdown (engine::Deadline) override
 

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
 

Static Public Attributes

static constexpr std::string_view kName = "congestion-control"
 The default name of congestion_control::Component component.
 

Protected Types

using LoggableComponentBase = ComponentBase
 

Member Typedef Documentation

◆ LoggableComponentBase

using components::ComponentBase::LoggableComponentBase = ComponentBase
protectedinherited
Deprecated
use components::ComponentBase instead.

Definition at line 79 of file component_base.hpp.

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.

◆ OnGracefulShutdown()

void components::ComponentBase::OnGracefulShutdown ( engine::Deadline )
overridevirtualinherited

Serving components like HTTP and gRPC servers may use this function to stop accepting new requests and shutdown serving in the given time interval. Application components likely do not need to override it.

Parameters
[in]serving_shutdown_deadlineThe deadline until already running requests should be allowed to complete. The component is supposed to stop accepting new requests and continue processing of already active requests until this deadline (unless those requests finish earlier). And it might completely shutdown requests processing when the deadline is reached (or when no active requests left).

Reimplemented from components::RawComponentBase.

Reimplemented in components::Server.

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