Skip to content

Commit

Permalink
feat userver: add defaults to more static config options
Browse files Browse the repository at this point in the history
- Allow omitting `dynamic-config` if there are no updates and no config overrides
- Omit `coro_pool` and `thread_name` in more tests and samples
  • Loading branch information
Anton3 committed Nov 15, 2023
1 parent 8e31cac commit 00d16a4
Show file tree
Hide file tree
Showing 64 changed files with 72 additions and 317 deletions.
8 changes: 0 additions & 8 deletions clickhouse/functional_tests/basic_chaos/static_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,13 @@ components_manager:
level: debug
overflow_behavior: discard

dynamic-config:
dns-client:
fs-task-processor: fs-task-processor
coro_pool:
initial_size: 500
max_size: 1000

task_processors:

main-task-processor:
worker_threads: 4
thread_name: main-worker

fs-task-processor:
thread_name: fs-worker
worker_threads: 4

default_task_processor: main-task-processor
8 changes: 0 additions & 8 deletions clickhouse/functional_tests/metrics/static_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,13 @@ components_manager:
method: GET
task_processor: main-task-processor

dynamic-config:
dns-client:
fs-task-processor: fs-task-processor
coro_pool:
initial_size: 500
max_size: 1000

task_processors:

main-task-processor:
worker_threads: 4
thread_name: main-worker

fs-task-processor:
thread_name: fs-worker
worker_threads: 4

default_task_processor: main-task-processor
15 changes: 1 addition & 14 deletions conan/test_package/hello_service/static_config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
# yaml
components_manager:
coro_pool:
initial_size: 500 # Preallocate 500 coroutines at startup.
max_size: 1000 # Do not keep more than 1000 preallocated coroutines.

task_processors: # Task processor is an executor for coroutine tasks

main-task-processor: # Make a task processor for CPU-bound couroutine tasks.
worker_threads: 4 # Process tasks in 4 threads.
thread_name: main-worker # OS will show the threads of this task processor with 'main-worker' prefix.

fs-task-processor: # Make a separate task processor for filesystem bound tasks.
thread_name: fs-worker
worker_threads: 4

default_task_processor: main-task-processor
default_task_processor: main-task-processor # Task processor in which components start.

components: # Configuring components that were registered via component_list
server:
Expand All @@ -29,11 +21,6 @@ components_manager:
level: debug
overflow_behavior: discard # Drop logs if the system is too busy to write them down.

tracer: # Component that helps to trace execution times and requests in logs.
service-name: hello-service # "You know. You all know exactly who I am. Say my name. " (c)

dynamic-config: # Dynamic config storage options, do nothing

handler-hello-sample: # Finally! Our handler.
path: /hello # Registering handler by URL '/hello'.
method: GET,POST # It will only reply to GET (HEAD) and POST requests.
Expand Down
6 changes: 0 additions & 6 deletions core/functional_tests/basic_chaos/static_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,11 @@ components_manager:
path: /service/fired-alerts
method: GET
task_processor: main-task-processor
coro_pool:
initial_size: 500
max_size: 1000

task_processors:
main-task-processor:
worker_threads: 4
thread_name: main-worker

fs-task-processor:
thread_name: fs-worker
worker_threads: 2

default_task_processor: main-task-processor
15 changes: 1 addition & 14 deletions core/functional_tests/cache_update/static_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# yaml

config_vars: /etc/cache_update/config_vars.yaml

components_manager:
components:
handler-cache-state:
Expand Down Expand Up @@ -140,23 +136,14 @@ components_manager:
full-update-interval: 1h
update-interval: 10m
has-pre-assign-check: true
tracer:
service-name: $service-name
tracer: native
coro_pool:
initial_size: $coro-pool-initial-size
initial_size#fallback: 5000
max_size: $coro-pool-max-size
max_size#fallback: 50000

default_task_processor: main-task-processor

task_processors:
fs-task-processor:
thread_name: fs-worker
worker_threads: $fs_worker_threads
worker_threads#fallback: 2
main-task-processor:
thread_name: main-worker
worker_threads: $main_worker_threads
worker_threads#fallback: 6
monitor-task-processor:
Expand Down
15 changes: 1 addition & 14 deletions core/functional_tests/metrics/static_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# yaml

config_vars: /etc/test_core_metrics/config_vars.yaml

components_manager:
components:

Expand Down Expand Up @@ -150,23 +146,14 @@ components_manager:
size: 1024
ways: 32
lifetime: 1s
tracer:
service-name: $service-name
tracer: native
coro_pool:
initial_size: $coro-pool-initial-size
initial_size#fallback: 5000
max_size: $coro-pool-max-size
max_size#fallback: 50000

default_task_processor: main-task-processor

task_processors:
fs-task-processor:
thread_name: fs-worker
worker_threads: $fs_worker_threads
worker_threads#fallback: 2
main-task-processor:
thread_name: main-worker
worker_threads: $main_worker_threads
worker_threads#fallback: 6
monitor-task-processor:
Expand Down
8 changes: 0 additions & 8 deletions core/functional_tests/tracing/static_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,12 @@ components_manager:
incoming-format: ['taxi', 'yandex', 'b3-alternative', 'opentelemetry']
new-requests-format: ['taxi', 'yandex', 'b3-alternative', 'opentelemetry']

dynamic-config: # Dynamic config storage options, do nothing

coro_pool:
initial_size: 500 # Preallocate 500 coroutines at startup.
max_size: 1000 # Do not keep more than 1000 preallocated coroutines.

task_processors: # Task processor is an executor for coroutine tasks

main-task-processor: # Make a task processor for CPU-bound coroutine tasks.
worker_threads: 4 # Process tasks in 4 threads.
thread_name: main-worker # OS will show the threads of this task processor with 'main-worker' prefix.

fs-task-processor: # Make a separate task processor for filesystem bound tasks.
thread_name: fs-worker
worker_threads: 4

default_task_processor: main-task-processor
8 changes: 1 addition & 7 deletions core/functional_tests/uctl/static_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# yaml

config_vars: /etc/test_core_uctl/config_vars.yaml

components_manager:
components:

Expand Down Expand Up @@ -136,14 +132,12 @@ components_manager:
throttling_enabled: false
testsuite-support:
testsuite-periodic-dumps-enabled: $userver-dumps-periodic
tracer:
service-name: $service-name
tracer: native
coro_pool:
initial_size: $coro-pool-initial-size
initial_size#fallback: 5000
max_size: $coro-pool-max-size
max_size#fallback: 50000

default_task_processor: main-task-processor

task_processors:
Expand Down
9 changes: 0 additions & 9 deletions core/functional_tests/websocket/static_config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
components_manager:
coro_pool:
initial_size: 500 # Preallocate 500 coroutines at startup.
max_size: 1000 # Do not keep more than 1000 preallocated coroutines.

task_processors: # Task processor is an executor for coroutine tasks

main-task-processor: # Make a task processor for CPU-bound couroutine tasks.
worker_threads: 4 # Process tasks in 4 threads.
thread_name: main-worker # OS will show the threads of this task processor with 'main-worker' prefix.

fs-task-processor: # Make a separate task processor for filesystem bound tasks.
thread_name: fs-worker
worker_threads: 4

default_task_processor: main-task-processor
Expand All @@ -28,8 +21,6 @@ components_manager:
level: debug
overflow_behavior: discard # Drop logs if the system is too busy to write them down.

dynamic-config: # Dynamic config storage options, do nothing

websocket-handler: # Finally! Websocket handler.
path: /chat # Registering handlers '/*' find files.
method: GET # Handle only GET requests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class ManagerControllerComponent final : public impl::ComponentBase {

~ManagerControllerComponent() override;

/// @ingroup userver_component_names
/// @brief The default name of components::ManagerControllerComponent
static constexpr std::string_view kName = "manager-controller";

private:
Expand Down
1 change: 0 additions & 1 deletion core/include/userver/components/run.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <string>

#include <userver/components/component_list.hpp>
#include <userver/logging/format.hpp>
#include <userver/utils/strong_typedef.hpp>

USERVER_NAMESPACE_BEGIN
Expand Down
4 changes: 4 additions & 0 deletions core/include/userver/dynamic_config/storage/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ class DynamicConfig::NoblockSubscriber final {
template <>
inline constexpr bool kHasValidate<DynamicConfig> = true;

template <>
inline constexpr auto kConfigFileMode<DynamicConfig> =
ConfigFileMode::kNotRequired;

} // namespace components

USERVER_NAMESPACE_END
8 changes: 0 additions & 8 deletions core/src/cache/lru_cache_component_base_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@ namespace {
// BEWARE! No separate fs-task-processor. Testing almost single thread mode
constexpr std::string_view kStaticConfig = R"(
components_manager:
coro_pool:
initial_size: 50
max_size: 500
default_task_processor: main-task-processor
event_thread_pool:
threads: 1
task_processors:
main-task-processor:
thread_name: main-worker
worker_threads: 1
components:
manager-controller: # Nothing
# /// [Sample lru cache component config]
# yaml
example-cache:
Expand All @@ -42,8 +37,6 @@ constexpr std::string_view kStaticConfig = R"(
loggers:
default:
file_path: '@null'
statistics-storage:
# Nothing
testsuite-support:
testsuite-periodic-update-enabled: true
testsuite-pg-execute-timeout: 300ms
Expand All @@ -52,7 +45,6 @@ constexpr std::string_view kStaticConfig = R"(
testsuite-redis-timeout-connect: 5s
testsuite-redis-timeout-single: 1s
testsuite-redis-timeout-all: 750ms
dynamic-config:
)";

void ValidateExampleCacheConfig(const formats::yaml::Value& static_config) {
Expand Down
2 changes: 2 additions & 0 deletions core/src/components/common_component_list_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ constexpr std::string_view kConfigVarsTemplate = R"(
log_level: {2}
)";

// We deliberately have some defaulted options explicitly specified here, for
// testing and documentation purposes.
// clang-format off
constexpr std::string_view kStaticConfig = R"(
# /// [Sample components manager config component config]
Expand Down
2 changes: 2 additions & 0 deletions core/src/components/common_server_component_list_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ constexpr std::string_view kConfigVarsTemplate = R"(
server-monitor-port: {6}
)";

// We deliberately have some defaulted options explicitly specified here, for
// testing and documentation purposes.
// BEWARE! No separate fs-task-processor. Testing almost single thread mode
constexpr std::string_view kStaticConfig = R"(
components_manager:
Expand Down
4 changes: 0 additions & 4 deletions core/src/components/component_list_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,14 @@ inline constexpr std::string_view kMinimalStaticConfig = R"(
threads: 1
task_processors:
main-task-processor:
thread_name: main-worker
worker_threads: 1
components:
manager-controller:
logging:
fs-task-processor: main-task-processor
loggers:
default:
file_path: $logger_file_path
format: ltsv
statistics-storage:
dynamic-config:
config_vars: )";

struct TracingGuard final {
Expand Down
8 changes: 1 addition & 7 deletions core/src/components/config_not_required_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,18 @@ namespace {

constexpr std::string_view kStaticConfigBase = R"(
components_manager:
coro_pool:
initial_size: 50
max_size: 500
default_task_processor: main-task-processor
event_thread_pool:
threads: 1
default_task_processor: main-task-processor
task_processors:
main-task-processor:
thread_name: main-worker
worker_threads: 1
components:
logging:
fs-task-processor: main-task-processor
loggers:
default:
file_path: '@null'
tracer:
service-name: config-service
)";

constexpr std::string_view kCustomGreetingConfig = R"(
Expand Down
1 change: 0 additions & 1 deletion core/src/components/manager_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <userver/formats/parse/common_containers.hpp>
#include <userver/formats/yaml/serialize.hpp>
#include <userver/formats/yaml/value_builder.hpp>
#include <userver/logging/log.hpp>
#include <userver/utils/impl/userver_experiments.hpp>
#include <userver/yaml_config/impl/validate_static_config.hpp>
#include <userver/yaml_config/map_to_array.hpp>
Expand Down
1 change: 1 addition & 0 deletions core/src/components/manager_config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ constexpr char kConfig[] = R"(
logger_access_tskv: ''
statistics-storage: null
dynamic-config:
updates-enabled: true
fs-cache-path: /var/cache/yandex/taxi-device-notify/config_cache.json
fs-task-processor: fs-task-processor
dynamic-config-client-updater:
Expand Down
5 changes: 0 additions & 5 deletions core/src/components/minimal_server_component_list_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ constexpr std::string_view kStaticConfig = R"(
# yaml
task_processors:
fs-task-processor:
thread_name: fs-worker
worker_threads: 2
main-task-processor:
thread_name: main-worker
worker_threads: 4
task-trace:
every: 1
Expand All @@ -70,9 +68,6 @@ constexpr std::string_view kStaticConfig = R"(
listener:
port: $server-port
task_processor: main-task-processor
statistics-storage: # Nothing
auth-checker-settings: # Nothing
manager-controller: # Nothing
init-open-file-checker:
init-logger-path: $init_log_path
Expand Down
Loading

0 comments on commit 00d16a4

Please sign in to comment.