userver: userver/components/manager_controller_component.hpp Source File
Loading...
Searching...
No Matches
manager_controller_component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/components/manager_controller_component.hpp
4/// @brief @copybrief components::ManagerControllerComponent
5
6#include <userver/components/component_fwd.hpp>
7#include <userver/components/impl/component_base.hpp>
8#include <userver/concurrent/async_event_source.hpp>
9#include <userver/dynamic_config/snapshot.hpp>
10#include <userver/engine/task/task_processor_fwd.hpp>
11#include <userver/utils/statistics/entry.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace components {
16
17class Manager;
18
19// clang-format off
20
21/// @ingroup userver_components
22///
23/// @brief Component that prepares the engine internals and starts all the
24/// other components.
25///
26/// ## Dynamic config
27/// * @ref USERVER_TASK_PROCESSOR_PROFILER_DEBUG
28/// * @ref USERVER_TASK_PROCESSOR_QOS
29///
30/// ## Static options:
31/// Name | Description | Default value
32/// ---- | ----------- | -------------
33/// coro_pool.initial_size | amount of coroutines to preallocate on startup | 1000
34/// coro_pool.max_size | max amount of coroutines to keep preallocated | 4000
35/// coro_pool.stack_size | size of a single coroutine | 256 * 1024
36/// event_thread_pool.threads | number of threads to process low level IO system calls (number of ev loops to start in libev) | 2
37/// event_thread_pool.thread_name | set OS thread name to this value | 'event-worker'
38/// components | dictionary of "component name": "options" | -
39/// default_task_processor | name of the default task processor to use in components | -
40/// task_processors.*NAME*.*OPTIONS* | dictionary of task processors to create and their options. See description below | -
41/// mlock_debug_info | whether to mlock(2) process debug info to prevent major page faults on unwinding | true
42/// disable_phdr_cache | whether to disable caching of phdr_info objects. Usable if rebuilding with cmake variable USERVER_DISABLE_PHDR_CACHE is off limits, and has the same effect | false
43/// preheat_stacktrace_collector | whether to collect a dummy stacktrace at server start up (usable to avoid loading debug info at random point at runtime) | true
44///
45/// ## Static task_processor options:
46/// Name | Description | Default value
47/// ---- | ----------- | -------------
48/// guess-cpu-limit | guess optimal threads count | false
49/// thread_name | set OS thread name to this value | Part of the task_processor name before the first '-' symbol with '-worker' appended; for example 'fs-worker' or 'main-worker'
50/// worker_threads | threads count for the task processor | -
51/// os-scheduling | OS scheduling mode for the task processor threads. 'idle' sets the lowest priority. 'low-priority' sets the priority below 'normal' but higher than 'idle'. | normal
52/// spinning-iterations | tunes the number of spin-wait iterations in case of an empty task queue before threads go to sleep | 10000
53/// task-trace | optional dictionary of tracing options | empty (disabled)
54/// task-trace.every | set N to trace each Nth task | 1000
55/// task-trace.max-context-switch-count | set upper limit of context switches to trace for a single task | 1000
56/// task-trace.logger | required name of logger to write traces to, should not be the 'default' logger | -
57///
58/// Tips and tricks on `task-trace` usage are described in
59/// @ref scripts/docs/en/userver/profile_context_switches.md.
60///
61/// ## Static configuration example:
62///
63/// @snippet components/common_component_list_test.cpp Sample components manager config component config
64
65// clang-format on
66class ManagerControllerComponent final : public impl::ComponentBase {
67 public:
68 ManagerControllerComponent(const components::ComponentConfig& config,
69 const components::ComponentContext& context);
70
71 ~ManagerControllerComponent() override;
72
73 /// @ingroup userver_component_names
74 /// @brief The default name of components::ManagerControllerComponent
75 static constexpr std::string_view kName = "manager-controller";
76
77 private:
78 void WriteStatistics(utils::statistics::Writer& writer);
79
80 void OnConfigUpdate(const dynamic_config::Snapshot& cfg);
81
82 const components::Manager& components_manager_;
83 utils::statistics::Entry statistics_holder_;
84 concurrent::AsyncEventSubscriberScope config_subscription_;
85};
86
87template <>
88inline constexpr auto kConfigFileMode<ManagerControllerComponent> =
90
91} // namespace components
92
93USERVER_NAMESPACE_END