Skip to content

Commit 4713600

Browse files
committed
feat databases: move schemas to separate files
Tests: протестировано CI commit_hash:7aef4db1b139797a1ee2e57d1b4da89f9e705ad0
1 parent 1c07dce commit 4713600

File tree

15 files changed

+198
-165
lines changed

15 files changed

+198
-165
lines changed

.mapping.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,6 +3109,7 @@
31093109
"mysql/src/storages/mysql/cluster.cpp":"taxi/uservices/userver/mysql/src/storages/mysql/cluster.cpp",
31103110
"mysql/src/storages/mysql/command_result_set.cpp":"taxi/uservices/userver/mysql/src/storages/mysql/command_result_set.cpp",
31113111
"mysql/src/storages/mysql/component.cpp":"taxi/uservices/userver/mysql/src/storages/mysql/component.cpp",
3112+
"mysql/src/storages/mysql/component.yaml":"taxi/uservices/userver/mysql/src/storages/mysql/component.yaml",
31123113
"mysql/src/storages/mysql/dates.cpp":"taxi/uservices/userver/mysql/src/storages/mysql/dates.cpp",
31133114
"mysql/src/storages/mysql/exceptions.cpp":"taxi/uservices/userver/mysql/src/storages/mysql/exceptions.cpp",
31143115
"mysql/src/storages/mysql/impl/bindings/input_bindings.cpp":"taxi/uservices/userver/mysql/src/storages/mysql/impl/bindings/input_bindings.cpp",
@@ -3550,6 +3551,7 @@
35503551
"rabbitmq/src/urabbitmq/client_impl.hpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/client_impl.hpp",
35513552
"rabbitmq/src/urabbitmq/client_settings.cpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/client_settings.cpp",
35523553
"rabbitmq/src/urabbitmq/component.cpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/component.cpp",
3554+
"rabbitmq/src/urabbitmq/component.yaml":"taxi/uservices/userver/rabbitmq/src/urabbitmq/component.yaml",
35533555
"rabbitmq/src/urabbitmq/connection.cpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/connection.cpp",
35543556
"rabbitmq/src/urabbitmq/connection.hpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/connection.hpp",
35553557
"rabbitmq/src/urabbitmq/connection_helper.cpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/connection_helper.cpp",
@@ -3562,6 +3564,7 @@
35623564
"rabbitmq/src/urabbitmq/consumer_base_impl.cpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/consumer_base_impl.cpp",
35633565
"rabbitmq/src/urabbitmq/consumer_base_impl.hpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/consumer_base_impl.hpp",
35643566
"rabbitmq/src/urabbitmq/consumer_component_base.cpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/consumer_component_base.cpp",
3567+
"rabbitmq/src/urabbitmq/consumer_component_base.yaml":"taxi/uservices/userver/rabbitmq/src/urabbitmq/consumer_component_base.yaml",
35653568
"rabbitmq/src/urabbitmq/impl/amqp_channel.cpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/impl/amqp_channel.cpp",
35663569
"rabbitmq/src/urabbitmq/impl/amqp_channel.hpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/impl/amqp_channel.hpp",
35673570
"rabbitmq/src/urabbitmq/impl/amqp_connection.cpp":"taxi/uservices/userver/rabbitmq/src/urabbitmq/impl/amqp_connection.cpp",
@@ -3819,6 +3822,7 @@
38193822
"rocks/src/storages/rocks/client.cpp":"taxi/uservices/userver/rocks/src/storages/rocks/client.cpp",
38203823
"rocks/src/storages/rocks/client_test.cpp":"taxi/uservices/userver/rocks/src/storages/rocks/client_test.cpp",
38213824
"rocks/src/storages/rocks/component.cpp":"taxi/uservices/userver/rocks/src/storages/rocks/component.cpp",
3825+
"rocks/src/storages/rocks/component.yaml":"taxi/uservices/userver/rocks/src/storages/rocks/component.yaml",
38223826
"rocks/src/storages/rocks/exception.cpp":"taxi/uservices/userver/rocks/src/storages/rocks/exception.cpp",
38233827
"samples/CMakeLists.txt":"taxi/uservices/userver/samples/CMakeLists.txt",
38243828
"samples/README.md":"taxi/uservices/userver/samples/README.md",
@@ -4629,6 +4633,7 @@
46294633
"sqlite/library.yaml":"taxi/uservices/userver/sqlite/library.yaml",
46304634
"sqlite/src/storages/sqlite/client.cpp":"taxi/uservices/userver/sqlite/src/storages/sqlite/client.cpp",
46314635
"sqlite/src/storages/sqlite/component.cpp":"taxi/uservices/userver/sqlite/src/storages/sqlite/component.cpp",
4636+
"sqlite/src/storages/sqlite/component.yaml":"taxi/uservices/userver/sqlite/src/storages/sqlite/component.yaml",
46324637
"sqlite/src/storages/sqlite/exceptions.cpp":"taxi/uservices/userver/sqlite/src/storages/sqlite/exceptions.cpp",
46334638
"sqlite/src/storages/sqlite/impl/client_impl.cpp":"taxi/uservices/userver/sqlite/src/storages/sqlite/impl/client_impl.cpp",
46344639
"sqlite/src/storages/sqlite/impl/connection.cpp":"taxi/uservices/userver/sqlite/src/storages/sqlite/impl/connection.cpp",

mysql/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ userver_module(
1515
UBENCH_LINK_LIBRARIES libmariadb
1616
UBENCH_DATABASES mysql
1717
DEPENDS core
18+
EMBED_FILES
19+
src/storages/mysql/component.yaml
1820
)
1921

2022
if(USERVER_MYSQL_ALLOW_BUGGY_LIBMARIADB)

mysql/src/storages/mysql/component.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include <userver/storages/secdist/component.hpp>
1111
#include <userver/yaml_config/merge_schemas.hpp>
1212

13+
#ifndef ARCADIA_ROOT
14+
#include "generated/src/storages/mysql/component.yaml.hpp" // Y_IGNORE
15+
#endif
16+
1317
USERVER_NAMESPACE_BEGIN
1418

1519
namespace storages::mysql {
@@ -47,20 +51,7 @@ Component::~Component() { statistics_holder_.Unregister(); }
4751
std::shared_ptr<storages::mysql::Cluster> Component::GetCluster() const { return cluster_; }
4852

4953
yaml_config::Schema Component::GetStaticConfigSchema() {
50-
return yaml_config::MergeSchemas<ComponentBase>(R"(
51-
type: object
52-
description: MySQL client component
53-
additionalProperties: false
54-
properties:
55-
initial_pool_size:
56-
type: integer
57-
description: number of connections created initially
58-
defaultDescription: 1
59-
max_pool_size:
60-
type: integer
61-
description: maximum number of created connections
62-
defaultDescription: 10
63-
)");
54+
return yaml_config::MergeSchemasFromResource<ComponentBase>("src/storages/mysql/component.yaml");
6455
}
6556

6657
} // namespace storages::mysql
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type: object
2+
description: MySQL client component
3+
additionalProperties: false
4+
properties:
5+
initial_pool_size:
6+
type: integer
7+
description: number of connections created initially
8+
defaultDescription: 1
9+
max_pool_size:
10+
type: integer
11+
description: maximum number of created connections
12+
defaultDescription: 10

rabbitmq/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ userver_module(
1313
DBTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_rmqtest.cpp"
1414
DBTEST_DATABASES rabbitmq
1515
DEPENDS core
16+
EMBED_FILES
17+
src/urabbitmq/component.yaml
18+
src/urabbitmq/consumer_component_base.yaml
1619
)
1720

1821
_userver_directory_install(

rabbitmq/src/urabbitmq/component.cpp

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
#include <userver/urabbitmq/client.hpp>
1111

12+
#ifndef ARCADIA_ROOT
13+
#include "generated/src/urabbitmq/component.yaml.hpp" // Y_IGNORE
14+
#endif
15+
1216
USERVER_NAMESPACE_BEGIN
1317

1418
namespace components {
@@ -45,34 +49,7 @@ RabbitMQ::~RabbitMQ() { statistics_holder_.Unregister(); }
4549
std::shared_ptr<urabbitmq::Client> RabbitMQ::GetClient() const { return client_; }
4650

4751
yaml_config::Schema RabbitMQ::GetStaticConfigSchema() {
48-
return yaml_config::MergeSchemas<ComponentBase>(R"(
49-
# yaml
50-
type: object
51-
description: RabbitMQ client component
52-
additionalProperties: false
53-
properties:
54-
secdist_alias:
55-
type: string
56-
description: name of the key in secdist config
57-
min_pool_size:
58-
type: integer
59-
description: minimum connections pool size (per host)
60-
defaultDescription: 5
61-
max_pool_size:
62-
type: integer
63-
description: |
64-
maximum connections pool size (per host, consumers excluded)
65-
defaultDescription: 10
66-
max_in_flight_requests:
67-
type: integer
68-
description: |
69-
per-connection limit for requests awaiting response from the broker
70-
defaultDescription: 5
71-
use_secure_connection:
72-
type: boolean
73-
description: whether to use TLS for connections
74-
defaultDescription: true
75-
)");
52+
return yaml_config::MergeSchemasFromResource<ComponentBase>("src/urabbitmq/component.yaml");
7653
}
7754

7855
} // namespace components
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# yaml
2+
type: object
3+
description: RabbitMQ client component
4+
additionalProperties: false
5+
properties:
6+
secdist_alias:
7+
type: string
8+
description: name of the key in secdist config
9+
min_pool_size:
10+
type: integer
11+
description: minimum connections pool size (per host)
12+
defaultDescription: 5
13+
max_pool_size:
14+
type: integer
15+
description: |
16+
maximum connections pool size (per host, consumers excluded)
17+
defaultDescription: 10
18+
max_in_flight_requests:
19+
type: integer
20+
description: |
21+
per-connection limit for requests awaiting response from the broker
22+
defaultDescription: 5
23+
use_secure_connection:
24+
type: boolean
25+
description: whether to use TLS for connections
26+
defaultDescription: true

rabbitmq/src/urabbitmq/consumer_component_base.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include <userver/urabbitmq/component.hpp>
1010
#include <userver/urabbitmq/consumer_base.hpp>
1111

12+
#ifndef ARCADIA_ROOT
13+
#include "generated/src/urabbitmq/consumer_component_base.yaml.hpp" // Y_IGNORE
14+
#endif
15+
1216
USERVER_NAMESPACE_BEGIN
1317

1418
namespace urabbitmq {
@@ -69,21 +73,8 @@ void ConsumerComponentBase::OnAllComponentsLoaded() { impl_->Start(this); }
6973
void ConsumerComponentBase::OnAllComponentsAreStopping() { impl_->Stop(); }
7074

7175
yaml_config::Schema ConsumerComponentBase::GetStaticConfigSchema() {
72-
return yaml_config::MergeSchemas<components::ComponentBase>(R"(
73-
type: object
74-
description: RabbitMQ consumer component
75-
additionalProperties: false
76-
properties:
77-
rabbit_name:
78-
type: string
79-
description: name of the RabbitMQ component to use
80-
queue:
81-
type: string
82-
description: a queue to consume from
83-
prefetch_count:
84-
type: integer
85-
description: prefetch_count for the consumer
86-
)");
76+
return yaml_config::MergeSchemasFromResource<components::ComponentBase>("src/urabbitmq/consumer_component_base.yaml"
77+
);
8778
}
8879

8980
} // namespace urabbitmq
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type: object
2+
description: RabbitMQ consumer component
3+
additionalProperties: false
4+
properties:
5+
rabbit_name:
6+
type: string
7+
description: name of the RabbitMQ component to use
8+
queue:
9+
type: string
10+
description: a queue to consume from
11+
prefetch_count:
12+
type: integer
13+
description: prefetch_count for the consumer

rocks/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ userver_module(
88
LINK_LIBRARIES RocksDB::rocksdb
99
UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp"
1010
DEPENDS core
11+
EMBED_FILES
12+
src/storages/rocks/component.yaml
1113
)

0 commit comments

Comments
 (0)