Skip to content

Commit 7579bad

Browse files
author
smorivan
committed
feat core: use component lists for common http client and dynamic config updater components
To simplify future changes related to @ref components::HttpClient and runtime config updates, all components required for that are added into @ref clients::http::ComponentList and @ref dynamic\_config::updater::ComponentList. Migration guide: 1. Instead of adding default @ref components::HttpClientCore and @ref components::HttpClient to your component list, use @ref clients::HttpComponentList. For example: ```cpp // before: // #include <userver/clients/http/component_list.hpp> // after: #include <userver/clients/http/component_list.hpp> components::ComponentList MyComponentList() { return components::ComponentList() ... // before: // .Append<components::HttpClientCore>() // .Append<components::HttpClient>() // after: .AppendComponentList(clients::http::ComponentList()) ...; } ``` Non-default clients still need to be added manually. 2. If you also use runtime config updates, use @ref dynamic\_config::updater::ComponentList instead of adding @ref components::DynamicConfigClient and @ref components::DynamicConfigClientUpdater. For example: ```cpp // before: // #include <userver/dynamic_config/client/component.hpp> // #include <userver/dynamic_config/updater/component.hpp> // after: #include <userver/dynamic_config/updater/component_list.hpp> components::ComponentList MyComponentList() { return components::ComponentList() ... // before: // .Append<components::DynamicConfigClient>() // .Append<components::DynamicConfigClientUpdater>() // after: .AppendComponentList(dynamic_config::updater::ComponentList()) ...; } ``` commit_hash:6dab3fbdbc73328113415ffc1ebdd07d93c23039
1 parent 73fa662 commit 7579bad

File tree

61 files changed

+231
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+231
-225
lines changed

.mapping.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@
838838
"core/include/userver/clients/http/client_with_plugins.hpp":"taxi/uservices/userver/core/include/userver/clients/http/client_with_plugins.hpp",
839839
"core/include/userver/clients/http/component.hpp":"taxi/uservices/userver/core/include/userver/clients/http/component.hpp",
840840
"core/include/userver/clients/http/component_core.hpp":"taxi/uservices/userver/core/include/userver/clients/http/component_core.hpp",
841+
"core/include/userver/clients/http/component_list.hpp":"taxi/uservices/userver/core/include/userver/clients/http/component_list.hpp",
841842
"core/include/userver/clients/http/config.hpp":"taxi/uservices/userver/core/include/userver/clients/http/config.hpp",
842843
"core/include/userver/clients/http/connect_to.hpp":"taxi/uservices/userver/core/include/userver/clients/http/connect_to.hpp",
843844
"core/include/userver/clients/http/error.hpp":"taxi/uservices/userver/core/include/userver/clients/http/error.hpp",
@@ -942,6 +943,7 @@
942943
"core/include/userver/dynamic_config/test_helpers.hpp":"taxi/uservices/userver/core/include/userver/dynamic_config/test_helpers.hpp",
943944
"core/include/userver/dynamic_config/updater/additional_keys_token.hpp":"taxi/uservices/userver/core/include/userver/dynamic_config/updater/additional_keys_token.hpp",
944945
"core/include/userver/dynamic_config/updater/component.hpp":"taxi/uservices/userver/core/include/userver/dynamic_config/updater/component.hpp",
946+
"core/include/userver/dynamic_config/updater/component_list.hpp":"taxi/uservices/userver/core/include/userver/dynamic_config/updater/component_list.hpp",
945947
"core/include/userver/dynamic_config/updates_sink/component.hpp":"taxi/uservices/userver/core/include/userver/dynamic_config/updates_sink/component.hpp",
946948
"core/include/userver/dynamic_config/updates_sink/find.hpp":"taxi/uservices/userver/core/include/userver/dynamic_config/updates_sink/find.hpp",
947949
"core/include/userver/dynamic_config/value.hpp":"taxi/uservices/userver/core/include/userver/dynamic_config/value.hpp",
@@ -1250,6 +1252,7 @@
12501252
"core/src/clients/http/component.yaml":"taxi/uservices/userver/core/src/clients/http/component.yaml",
12511253
"core/src/clients/http/component_core.cpp":"taxi/uservices/userver/core/src/clients/http/component_core.cpp",
12521254
"core/src/clients/http/component_core.yaml":"taxi/uservices/userver/core/src/clients/http/component_core.yaml",
1255+
"core/src/clients/http/component_list.cpp":"taxi/uservices/userver/core/src/clients/http/component_list.cpp",
12531256
"core/src/clients/http/config.cpp":"taxi/uservices/userver/core/src/clients/http/config.cpp",
12541257
"core/src/clients/http/connect_to.cpp":"taxi/uservices/userver/core/src/clients/http/connect_to.cpp",
12551258
"core/src/clients/http/destination_statistics.cpp":"taxi/uservices/userver/core/src/clients/http/destination_statistics.cpp",
@@ -1473,6 +1476,7 @@
14731476
"core/src/dynamic_config/updater/additional_keys_token.cpp":"taxi/uservices/userver/core/src/dynamic_config/updater/additional_keys_token.cpp",
14741477
"core/src/dynamic_config/updater/component.cpp":"taxi/uservices/userver/core/src/dynamic_config/updater/component.cpp",
14751478
"core/src/dynamic_config/updater/component.yaml":"taxi/uservices/userver/core/src/dynamic_config/updater/component.yaml",
1479+
"core/src/dynamic_config/updater/component_list.cpp":"taxi/uservices/userver/core/src/dynamic_config/updater/component_list.cpp",
14761480
"core/src/dynamic_config/updates_sink/component.cpp":"taxi/uservices/userver/core/src/dynamic_config/updates_sink/component.cpp",
14771481
"core/src/dynamic_config/updates_sink/find.cpp":"taxi/uservices/userver/core/src/dynamic_config/updates_sink/find.cpp",
14781482
"core/src/dynamic_config/value.cpp":"taxi/uservices/userver/core/src/dynamic_config/value.cpp",

clickhouse/functional_tests/metrics/service.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include <userver/storages/secdist/component.hpp>
1818
#include <userver/storages/secdist/provider_component.hpp>
1919

20+
#include <userver/clients/http/component_list.hpp>
2021
#include <userver/utils/daemon_run.hpp>
21-
#include "userver/clients/http/component.hpp"
2222
#include "userver/server/handlers/server_monitor.hpp"
2323
#include "userver/server/handlers/tests_control.hpp"
2424
#include "userver/storages/clickhouse/io/columns/datetime_column.hpp"
@@ -106,8 +106,7 @@ int main(int argc, char* argv[]) {
106106
.Append<server::handlers::ServerMonitor>()
107107
.Append<clickhouse::metrics::HandlerMetricsClickhouse>()
108108
.Append<components::ClickHouse>("clickhouse-database")
109-
.Append<components::HttpClientCore>()
110-
.Append<components::HttpClient>()
109+
.AppendComponentList(clients::http::ComponentList())
111110
.Append<components::TestsuiteSupport>()
112111
.Append<server::handlers::TestsControl>()
113112
.Append<clients::dns::Component>()

core/functional_tests/basic_chaos/service.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <userver/clients/dns/component.hpp>
2+
#include <userver/clients/http/component_list.hpp>
23
#include <userver/testsuite/testsuite_support.hpp>
34

45
#include <userver/components/logging_configurator.hpp>
56
#include <userver/components/minimal_server_component_list.hpp>
6-
#include <userver/dynamic_config/client/component.hpp>
7-
#include <userver/dynamic_config/updater/component.hpp>
7+
#include <userver/dynamic_config/updater/component_list.hpp>
88
#include <userver/server/handlers/dynamic_debug_log.hpp>
99
#include <userver/server/handlers/on_log_rotate.hpp>
1010
#include <userver/server/handlers/ping.hpp>
@@ -22,24 +22,22 @@
2222
int main(int argc, char* argv[]) {
2323
const auto component_list =
2424
components::MinimalServerComponentList()
25+
.AppendComponentList(USERVER_NAMESPACE::dynamic_config::updater::ComponentList())
2526
.Append<chaos::HttpClientHandler>()
2627
.Append<chaos::StreamHandler>()
2728
.Append<chaos::HttpServerHandler>()
2829
.Append<chaos::HttpServerHandler>("handler-chaos-httpserver-parse-body-args")
2930
.Append<chaos::ResolverHandler>()
3031
.Append<chaos::HttpServerWithExceptionHandler>()
3132
.Append<components::LoggingConfigurator>()
32-
.Append<components::HttpClientCore>()
33-
.Append<components::HttpClient>()
33+
.AppendComponentList(clients::http::ComponentList())
3434
.Append<components::TestsuiteSupport>()
3535
.Append<server::handlers::DynamicDebugLog>()
3636
.Append<server::handlers::TestsControl>()
3737
.Append<server::handlers::ServerMonitor>()
3838
.Append<server::handlers::Ping>()
3939
.Append<server::handlers::Restart>()
4040
.Append<clients::dns::Component>()
41-
.Append<components::DynamicConfigClient>()
42-
.Append<components::DynamicConfigClientUpdater>()
4341
.Append<server::handlers::OnLogRotate>();
4442

4543
return utils::DaemonMain(argc, argv, component_list);

core/functional_tests/http2server/service.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#include <userver/clients/dns/component.hpp>
2-
#include <userver/clients/http/component.hpp>
2+
#include <userver/clients/http/component_list.hpp>
33
#include <userver/components/minimal_server_component_list.hpp>
4-
#include <userver/dynamic_config/client/component.hpp>
5-
#include <userver/dynamic_config/updater/component.hpp>
4+
#include <userver/dynamic_config/updater/component_list.hpp>
65
#include <userver/engine/sleep.hpp>
76
#include <userver/server/handlers/ping.hpp>
87
#include <userver/server/handlers/server_monitor.hpp>
@@ -86,14 +85,12 @@ class HandlerHttp2Stream final : public server::handlers::HttpHandlerBase {
8685
int main(int argc, char* argv[]) {
8786
auto component_list =
8887
components::MinimalServerComponentList()
88+
.AppendComponentList(USERVER_NAMESPACE::dynamic_config::updater::ComponentList())
8989
.Append<components::TestsuiteSupport>()
90-
.Append<components::HttpClientCore>()
91-
.Append<components::HttpClient>()
90+
.AppendComponentList(clients::http::ComponentList())
9291
.Append<clients::dns::Component>()
9392
.Append<server::handlers::ServerMonitor>()
9493
.Append<server::handlers::TestsControl>()
95-
.Append<components::DynamicConfigClientUpdater>()
96-
.Append<components::DynamicConfigClient>()
9794
.Append<HandlerHttp2>()
9895
.Append<HandlerHttp2Stream>()
9996
.Append<server::handlers::Ping>();

core/functional_tests/http_client_plugins/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <userver/clients/dns/component.hpp>
2-
#include <userver/clients/http/component.hpp>
2+
#include <userver/clients/http/component_list.hpp>
33
#include <userver/components/minimal_server_component_list.hpp>
44
#include <userver/server/handlers/tests_control.hpp>
55
#include <userver/testsuite/testsuite_support.hpp>
@@ -20,7 +20,6 @@ int main(int argc, char* argv[]) {
2020
.Append<server::handlers::TestsControl>()
2121
.Append<clients::dns::Component>()
2222
.Append<PluginComponent>()
23-
.Append<components::HttpClientCore>()
24-
.Append<components::HttpClient>();
23+
.AppendComponentList(clients::http::ComponentList());
2524
return utils::DaemonMain(argc, argv, component_list);
2625
}

core/functional_tests/https/service.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <userver/storages/secdist/provider_component.hpp>
44
#include <userver/testsuite/testsuite_support.hpp>
55

6-
#include <userver/clients/http/component.hpp>
6+
#include <userver/clients/http/component_list.hpp>
77
#include <userver/components/logging_configurator.hpp>
88
#include <userver/components/minimal_server_component_list.hpp>
99
#include <userver/dynamic_config/client/component.hpp>
@@ -24,8 +24,7 @@ int main(int argc, char* argv[]) {
2424
.Append<components::DefaultSecdistProvider>()
2525
.Append<components::Secdist>()
2626
.Append<components::LoggingConfigurator>()
27-
.Append<components::HttpClientCore>()
28-
.Append<components::HttpClient>()
27+
.AppendComponentList(clients::http::ComponentList())
2928
.Append<components::TestsuiteSupport>()
3029
.Append<server::handlers::TestsControl>()
3130
.Append<server::handlers::ServerMonitor>()

core/functional_tests/https_no_passphrase/service.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <userver/storages/secdist/provider_component.hpp>
44
#include <userver/testsuite/testsuite_support.hpp>
55

6-
#include <userver/clients/http/component.hpp>
6+
#include <userver/clients/http/component_list.hpp>
77
#include <userver/components/logging_configurator.hpp>
88
#include <userver/components/minimal_server_component_list.hpp>
99
#include <userver/dynamic_config/client/component.hpp>
@@ -21,8 +21,7 @@ int main(int argc, char* argv[]) {
2121
components::MinimalServerComponentList()
2222
.Append<https::HttpServerHandler>()
2323
.Append<components::LoggingConfigurator>()
24-
.Append<components::HttpClientCore>()
25-
.Append<components::HttpClient>()
24+
.AppendComponentList(clients::http::ComponentList())
2625
.Append<components::TestsuiteSupport>()
2726
.Append<server::handlers::TestsControl>()
2827
.Append<server::handlers::ServerMonitor>()

core/functional_tests/tracing/echo_no_body.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <userver/clients/dns/component.hpp>
44
#include <userver/clients/http/component.hpp>
5+
#include <userver/clients/http/component_list.hpp>
56
#include <userver/components/component.hpp>
67
#include <userver/components/minimal_server_component_list.hpp>
78
#include <userver/http/url.hpp>
@@ -53,7 +54,6 @@ int main(int argc, char* argv[]) {
5354
.Append<components::TestsuiteSupport>()
5455
.Append<server::handlers::TestsControl>()
5556
.Append<clients::dns::Component>()
56-
.Append<components::HttpClientCore>()
57-
.Append<components::HttpClient>();
57+
.AppendComponentList(clients::http::ComponentList());
5858
return utils::DaemonMain(argc, argv, component_list);
5959
}

core/functional_tests/trx_tracker/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <userver/clients/dns/component.hpp>
2-
#include <userver/clients/http/component.hpp>
2+
#include <userver/clients/http/component_list.hpp>
33
#include <userver/components/minimal_server_component_list.hpp>
44
#include <userver/server/handlers/server_monitor.hpp>
55
#include <userver/server/handlers/tests_control.hpp>
@@ -15,8 +15,7 @@ int main(int argc, char* argv[]) {
1515
.Append<handlers::Handler>()
1616
.Append<server::handlers::ServerMonitor>()
1717
.Append<clients::dns::Component>()
18-
.Append<components::HttpClientCore>()
19-
.Append<components::HttpClient>()
18+
.AppendComponentList(clients::http::ComponentList())
2019
.Append<components::TestsuiteSupport>()
2120
.Append<server::handlers::TestsControl>();
2221
return utils::DaemonMain(argc, argv, component_list);

core/functional_tests/websocket/service.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <userver/clients/dns/component.hpp>
22
#include <userver/testsuite/testsuite_support.hpp>
33

4-
#include <userver/clients/http/component.hpp>
4+
#include <userver/clients/http/component_list.hpp>
55
#include <userver/components/minimal_server_component_list.hpp>
66
#include <userver/concurrent/queue.hpp>
77
#include <userver/engine/sleep.hpp>
@@ -152,8 +152,7 @@ int main(int argc, char* argv[]) {
152152
.Append<WebsocketsFullDuplexHandler>()
153153
.Append<WebsocketsPingPongHandler>()
154154
.Append<clients::dns::Component>()
155-
.Append<components::HttpClientCore>()
156-
.Append<components::HttpClient>()
155+
.AppendComponentList(clients::http::ComponentList())
157156
.Append<components::TestsuiteSupport>()
158157
.Append<server::handlers::TestsControl>();
159158
return utils::DaemonMain(argc, argv, component_list);

0 commit comments

Comments
 (0)