Skip to content

Commit b7a0cbd

Browse files
committed
feat grpc: move schemas to separate files
Tests: протестировано CI commit_hash:0f1bbd9c1042818fcc993f4ba7a389696882b55a
1 parent 63e7760 commit b7a0cbd

26 files changed

+410
-323
lines changed

.mapping.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,10 +2395,12 @@
23952395
"grpc/src/ugrpc/client/channels.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/channels.cpp",
23962396
"grpc/src/ugrpc/client/client_factory.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/client_factory.cpp",
23972397
"grpc/src/ugrpc/client/client_factory_component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/client_factory_component.cpp",
2398+
"grpc/src/ugrpc/client/client_factory_component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/client/client_factory_component.yaml",
23982399
"grpc/src/ugrpc/client/client_factory_settings.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/client_factory_settings.cpp",
23992400
"grpc/src/ugrpc/client/client_qos.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/client_qos.cpp",
24002401
"grpc/src/ugrpc/client/client_settings.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/client_settings.cpp",
24012402
"grpc/src/ugrpc/client/common_component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/common_component.cpp",
2403+
"grpc/src/ugrpc/client/common_component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/client/common_component.yaml",
24022404
"grpc/src/ugrpc/client/component_list.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/component_list.cpp",
24032405
"grpc/src/ugrpc/client/exceptions.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/exceptions.cpp",
24042406
"grpc/src/ugrpc/client/generic_client.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/generic_client.cpp",
@@ -2430,12 +2432,15 @@
24302432
"grpc/src/ugrpc/client/middlewares/base.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/base.cpp",
24312433
"grpc/src/ugrpc/client/middlewares/deadline_propagation/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/deadline_propagation/middleware.cpp",
24322434
"grpc/src/ugrpc/client/middlewares/headers_propagator/component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/headers_propagator/component.cpp",
2435+
"grpc/src/ugrpc/client/middlewares/headers_propagator/component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/headers_propagator/component.yaml",
24332436
"grpc/src/ugrpc/client/middlewares/headers_propagator/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/headers_propagator/middleware.cpp",
24342437
"grpc/src/ugrpc/client/middlewares/headers_propagator/middleware.hpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/headers_propagator/middleware.hpp",
24352438
"grpc/src/ugrpc/client/middlewares/log/component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/log/component.cpp",
2439+
"grpc/src/ugrpc/client/middlewares/log/component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/log/component.yaml",
24362440
"grpc/src/ugrpc/client/middlewares/log/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/log/middleware.cpp",
24372441
"grpc/src/ugrpc/client/middlewares/log/middleware.hpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/log/middleware.hpp",
24382442
"grpc/src/ugrpc/client/middlewares/origin/component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/origin/component.cpp",
2443+
"grpc/src/ugrpc/client/middlewares/origin/component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/origin/component.yaml",
24392444
"grpc/src/ugrpc/client/middlewares/origin/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/origin/middleware.cpp",
24402445
"grpc/src/ugrpc/client/middlewares/origin/middleware.hpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/origin/middleware.hpp",
24412446
"grpc/src/ugrpc/client/middlewares/pipeline.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/middlewares/pipeline.cpp",
@@ -2445,6 +2450,7 @@
24452450
"grpc/src/ugrpc/client/retry_config.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/retry_config.cpp",
24462451
"grpc/src/ugrpc/client/secdist.hpp":"taxi/uservices/userver/grpc/src/ugrpc/client/secdist.hpp",
24472452
"grpc/src/ugrpc/client/simple_client_component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/client/simple_client_component.cpp",
2453+
"grpc/src/ugrpc/client/simple_client_component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/client/simple_client_component.yaml",
24482454
"grpc/src/ugrpc/datetime_utils.cpp":"taxi/uservices/userver/grpc/src/ugrpc/datetime_utils.cpp",
24492455
"grpc/src/ugrpc/impl/async_method_invocation.cpp":"taxi/uservices/userver/grpc/src/ugrpc/impl/async_method_invocation.cpp",
24502456
"grpc/src/ugrpc/impl/code_statistics.cpp":"taxi/uservices/userver/grpc/src/ugrpc/impl/code_statistics.cpp",
@@ -2490,26 +2496,32 @@
24902496
"grpc/src/ugrpc/server/impl/service_worker_impl.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/impl/service_worker_impl.cpp",
24912497
"grpc/src/ugrpc/server/impl/status_utils.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/impl/status_utils.cpp",
24922498
"grpc/src/ugrpc/server/middlewares/access_log/component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/access_log/component.cpp",
2499+
"grpc/src/ugrpc/server/middlewares/access_log/component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/access_log/component.yaml",
24932500
"grpc/src/ugrpc/server/middlewares/access_log/log_extra.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/access_log/log_extra.cpp",
24942501
"grpc/src/ugrpc/server/middlewares/access_log/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/access_log/middleware.cpp",
24952502
"grpc/src/ugrpc/server/middlewares/access_log/middleware.hpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/access_log/middleware.hpp",
24962503
"grpc/src/ugrpc/server/middlewares/baggage/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/baggage/middleware.cpp",
24972504
"grpc/src/ugrpc/server/middlewares/base.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/base.cpp",
24982505
"grpc/src/ugrpc/server/middlewares/congestion_control/component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/congestion_control/component.cpp",
2506+
"grpc/src/ugrpc/server/middlewares/congestion_control/component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/congestion_control/component.yaml",
24992507
"grpc/src/ugrpc/server/middlewares/congestion_control/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/congestion_control/middleware.cpp",
25002508
"grpc/src/ugrpc/server/middlewares/congestion_control/middleware.hpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/congestion_control/middleware.hpp",
25012509
"grpc/src/ugrpc/server/middlewares/deadline_propagation/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/deadline_propagation/middleware.cpp",
25022510
"grpc/src/ugrpc/server/middlewares/headers_propagator/component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/headers_propagator/component.cpp",
2511+
"grpc/src/ugrpc/server/middlewares/headers_propagator/component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/headers_propagator/component.yaml",
25032512
"grpc/src/ugrpc/server/middlewares/headers_propagator/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/headers_propagator/middleware.cpp",
25042513
"grpc/src/ugrpc/server/middlewares/headers_propagator/middleware.hpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/headers_propagator/middleware.hpp",
25052514
"grpc/src/ugrpc/server/middlewares/log/component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/log/component.cpp",
2515+
"grpc/src/ugrpc/server/middlewares/log/component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/log/component.yaml",
25062516
"grpc/src/ugrpc/server/middlewares/log/middleware.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/log/middleware.cpp",
25072517
"grpc/src/ugrpc/server/middlewares/log/middleware.hpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/log/middleware.hpp",
25082518
"grpc/src/ugrpc/server/middlewares/pipeline.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/middlewares/pipeline.cpp",
25092519
"grpc/src/ugrpc/server/server.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/server.cpp",
25102520
"grpc/src/ugrpc/server/server_component.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/server_component.cpp",
2521+
"grpc/src/ugrpc/server/server_component.yaml":"taxi/uservices/userver/grpc/src/ugrpc/server/server_component.yaml",
25112522
"grpc/src/ugrpc/server/service_base.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/service_base.cpp",
25122523
"grpc/src/ugrpc/server/service_component_base.cpp":"taxi/uservices/userver/grpc/src/ugrpc/server/service_component_base.cpp",
2524+
"grpc/src/ugrpc/server/service_component_base.yaml":"taxi/uservices/userver/grpc/src/ugrpc/server/service_component_base.yaml",
25132525
"grpc/src/ugrpc/status_codes.cpp":"taxi/uservices/userver/grpc/src/ugrpc/status_codes.cpp",
25142526
"grpc/src/ugrpc/status_utils.cpp":"taxi/uservices/userver/grpc/src/ugrpc/status_utils.cpp",
25152527
"grpc/src/ugrpc/tests/service.cpp":"taxi/uservices/userver/grpc/src/ugrpc/tests/service.cpp",

grpc/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ endif()
3636

3737
add_library(${PROJECT_NAME}-internal STATIC ${SOURCES})
3838

39+
list(APPEND EMBED_FILES
40+
src/ugrpc/client/client_factory_component.yaml
41+
src/ugrpc/client/common_component.yaml
42+
src/ugrpc/client/middlewares/headers_propagator/component.yaml
43+
src/ugrpc/client/middlewares/log/component.yaml
44+
src/ugrpc/client/middlewares/origin/component.yaml
45+
src/ugrpc/client/simple_client_component.yaml
46+
src/ugrpc/server/middlewares/access_log/component.yaml
47+
src/ugrpc/server/middlewares/congestion_control/component.yaml
48+
src/ugrpc/server/middlewares/headers_propagator/component.yaml
49+
src/ugrpc/server/middlewares/log/component.yaml
50+
src/ugrpc/server/server_component.yaml
51+
src/ugrpc/server/service_component_base.yaml
52+
)
53+
54+
foreach(FILE ${EMBED_FILES})
55+
string(MAKE_C_IDENTIFIER "${PROJECT_NAME}-internal-embed_${FILE}" EMBED_TARGET_NAME)
56+
userver_embed_file(${EMBED_TARGET_NAME} FILEPATH "${FILE}" HPP_FILENAME "${FILE}")
57+
target_link_libraries(${PROJECT_NAME}-internal PRIVATE "$<BUILD_INTERFACE:${EMBED_TARGET_NAME}>")
58+
endforeach()
59+
3960
if("${gRPC_VERSION}" VERSION_LESS "1.66")
4061
target_compile_definitions(${PROJECT_NAME}-internal PRIVATE USERVER_IMPL_FEATURE_OLD_GRPC_NATIVE_LOGGING)
4162
endif()

grpc/src/ugrpc/client/client_factory_component.cpp

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include <ugrpc/client/impl/client_factory_config.hpp>
1616
#include <ugrpc/client/secdist.hpp>
1717

18+
#ifndef ARCADIA_ROOT
19+
#include "generated/src/ugrpc/client/client_factory_component.yaml.hpp" // Y_IGNORE
20+
#endif
21+
1822
USERVER_NAMESPACE_BEGIN
1923

2024
namespace ugrpc::client {
@@ -107,69 +111,8 @@ ClientFactoryComponent::ClientFactoryComponent(
107111
ClientFactory& ClientFactoryComponent::GetFactory() { return *factory_; }
108112

109113
yaml_config::Schema ClientFactoryComponent::GetStaticConfigSchema() {
110-
return yaml_config::MergeSchemas<impl::MiddlewareRunnerComponentBase>(R"(
111-
type: object
112-
description: Provides a ClientFactory in the component system
113-
additionalProperties: false
114-
properties:
115-
auth-type:
116-
type: string
117-
description: an optional authentication method
118-
defaultDescription: insecure
119-
enum:
120-
- insecure
121-
- ssl
122-
ssl-credentials-options:
123-
type: object
124-
description: SSL options for cases when `auth-type` is `ssl`
125-
defaultDescription: '{}'
126-
additionalProperties: false
127-
properties:
128-
pem-root-certs:
129-
type: string
130-
description: The path to file containing the PEM encoding of the server root certificates
131-
defaultDescription: absent
132-
pem-private-key:
133-
type: string
134-
description: The path to file containing the PEM encoding of the client's private key
135-
defaultDescription: absent
136-
pem-cert-chain:
137-
type: string
138-
description: The path to file containing the PEM encoding of the client's certificate chain
139-
defaultDescription: absent
140-
retry-config:
141-
type: object
142-
description: Retry configuration for outgoing RPCs
143-
defaultDescription: '{}'
144-
additionalProperties: false
145-
properties:
146-
attempts:
147-
type: integer
148-
description: The maximum number of RPC attempts, including the original attempt
149-
defaultDescription: 1
150-
minimum: 1
151-
channel-args:
152-
type: object
153-
description: a map of channel arguments, see gRPC Core docs
154-
defaultDescription: '{}'
155-
additionalProperties:
156-
type: string
157-
description: value of channel argument, must be string or integer
158-
properties: {}
159-
default-service-config:
160-
type: string
161-
description: |
162-
Default value for gRPC `service config`. See
163-
https://github.com/grpc/grpc/blob/master/doc/service_config.md
164-
This value is used if the name resolution process can't get value
165-
from DNS
166-
defaultDescription: absent
167-
channel-count:
168-
type: integer
169-
description: |
170-
Number of channels created for each endpoint.
171-
defaultDescription: 1
172-
)");
114+
return yaml_config::MergeSchemasFromResource<
115+
impl::MiddlewareRunnerComponentBase>("src/ugrpc/client/client_factory_component.yaml");
173116
}
174117

175118
} // namespace ugrpc::client
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
type: object
2+
description: Provides a ClientFactory in the component system
3+
additionalProperties: false
4+
properties:
5+
auth-type:
6+
type: string
7+
description: an optional authentication method
8+
defaultDescription: insecure
9+
enum:
10+
- insecure
11+
- ssl
12+
ssl-credentials-options:
13+
type: object
14+
description: SSL options for cases when `auth-type` is `ssl`
15+
defaultDescription: '{}'
16+
additionalProperties: false
17+
properties:
18+
pem-root-certs:
19+
type: string
20+
description: The path to file containing the PEM encoding of the server
21+
root certificates
22+
defaultDescription: absent
23+
pem-private-key:
24+
type: string
25+
description: The path to file containing the PEM encoding of the client's
26+
private key
27+
defaultDescription: absent
28+
pem-cert-chain:
29+
type: string
30+
description: The path to file containing the PEM encoding of the client's
31+
certificate chain
32+
defaultDescription: absent
33+
retry-config:
34+
type: object
35+
description: Retry configuration for outgoing RPCs
36+
defaultDescription: '{}'
37+
additionalProperties: false
38+
properties:
39+
attempts:
40+
type: integer
41+
description: The maximum number of RPC attempts, including the original
42+
attempt
43+
defaultDescription: 1
44+
minimum: 1
45+
channel-args:
46+
type: object
47+
description: a map of channel arguments, see gRPC Core docs
48+
defaultDescription: '{}'
49+
additionalProperties:
50+
type: string
51+
description: value of channel argument, must be string or integer
52+
properties: {}
53+
default-service-config:
54+
type: string
55+
description: |
56+
Default value for gRPC `service config`. See
57+
https://github.com/grpc/grpc/blob/master/doc/service_config.md
58+
This value is used if the name resolution process can't get value
59+
from DNS
60+
defaultDescription: absent
61+
channel-count:
62+
type: integer
63+
description: |
64+
Number of channels created for each endpoint.
65+
defaultDescription: 1

grpc/src/ugrpc/client/common_component.cpp

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include <ugrpc/impl/grpc_native_logging.hpp>
99
#include <userver/ugrpc/server/server_component.hpp>
1010

11+
#ifndef ARCADIA_ROOT
12+
#include "generated/src/ugrpc/client/common_component.yaml.hpp" // Y_IGNORE
13+
#endif
14+
1115
USERVER_NAMESPACE_BEGIN
1216

1317
namespace ugrpc::client {
@@ -60,52 +64,7 @@ CommonComponent::CommonComponent(const components::ComponentConfig& config, cons
6064
CommonComponent::~CommonComponent() = default;
6165

6266
yaml_config::Schema CommonComponent::GetStaticConfigSchema() {
63-
return yaml_config::MergeSchemas<components::ComponentBase>(R"(
64-
type: object
65-
description: Provides a ClientFactory in the component system
66-
additionalProperties: false
67-
properties:
68-
blocking-task-processor:
69-
type: string
70-
description: the task processor for blocking channel creation
71-
native-log-level:
72-
type: string
73-
description: min log level for the native gRPC library
74-
defaultDescription: error
75-
enum:
76-
- debug
77-
- info
78-
- error
79-
completion-queue-count:
80-
type: integer
81-
description: |
82-
completion queue count to create. Should be ~2 times less than worker
83-
threads for best RPS.
84-
minimum: 1
85-
proxy-address:
86-
type: string
87-
description: |
88-
proxy server address. No proxy if address is empty
89-
Example: localhost:84
90-
servicemesh-settings:
91-
type: object
92-
description: service settings from separate file for service mesh integration
93-
additionalProperties: false
94-
properties:
95-
egress:
96-
type: object
97-
description: egress settings
98-
additionalProperties: false
99-
properties:
100-
disable_proxy:
101-
description: list of addresses that should be accessed directly, bypassing proxy server
102-
type: array
103-
items:
104-
description: |
105-
address that should be accessed directly.
106-
Example: some.grpc.service.net:11080
107-
type: string
108-
)");
67+
return yaml_config::MergeSchemasFromResource<components::ComponentBase>("src/ugrpc/client/common_component.yaml");
10968
}
11069

11170
} // namespace ugrpc::client
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
type: object
2+
description: Provides a ClientFactory in the component system
3+
additionalProperties: false
4+
properties:
5+
blocking-task-processor:
6+
type: string
7+
description: the task processor for blocking channel creation
8+
native-log-level:
9+
type: string
10+
description: min log level for the native gRPC library
11+
defaultDescription: error
12+
enum:
13+
- debug
14+
- info
15+
- error
16+
completion-queue-count:
17+
type: integer
18+
description: |
19+
completion queue count to create. Should be ~2 times less than worker
20+
threads for best RPS.
21+
minimum: 1
22+
proxy-address:
23+
type: string
24+
description: |
25+
proxy server address. No proxy if address is empty
26+
Example: localhost:84
27+
servicemesh-settings:
28+
type: object
29+
description: service settings from separate file for service mesh integration
30+
additionalProperties: false
31+
properties:
32+
egress:
33+
type: object
34+
description: egress settings
35+
additionalProperties: false
36+
properties:
37+
disable_proxy:
38+
description: list of addresses that should be accessed directly,
39+
bypassing proxy server
40+
type: array
41+
items:
42+
description: |
43+
address that should be accessed directly.
44+
Example: some.grpc.service.net:11080
45+
type: string

0 commit comments

Comments
 (0)