Skip to content

Commit 874f908

Browse files
committed
feat ydb: move schemas to separate files
Tests: протестировано CI commit_hash:5e4b6bba1ace321766105a90d09f8332b3efc8b7
1 parent 66543f1 commit 874f908

File tree

5 files changed

+179
-108
lines changed

5 files changed

+179
-108
lines changed

.mapping.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5617,8 +5617,10 @@
56175617
"ydb/include/userver/ydb/types.hpp":"taxi/uservices/userver/ydb/include/userver/ydb/types.hpp",
56185618
"ydb/library.yaml":"taxi/uservices/userver/ydb/library.yaml",
56195619
"ydb/src/ydb/component.cpp":"taxi/uservices/userver/ydb/src/ydb/component.cpp",
5620+
"ydb/src/ydb/component.yaml":"taxi/uservices/userver/ydb/src/ydb/component.yaml",
56205621
"ydb/src/ydb/coordination.cpp":"taxi/uservices/userver/ydb/src/ydb/coordination.cpp",
56215622
"ydb/src/ydb/dist_lock/component_base.cpp":"taxi/uservices/userver/ydb/src/ydb/dist_lock/component_base.cpp",
5623+
"ydb/src/ydb/dist_lock/component_base.yaml":"taxi/uservices/userver/ydb/src/ydb/dist_lock/component_base.yaml",
56225624
"ydb/src/ydb/dist_lock/settings.cpp":"taxi/uservices/userver/ydb/src/ydb/dist_lock/settings.cpp",
56235625
"ydb/src/ydb/dist_lock/worker.cpp":"taxi/uservices/userver/ydb/src/ydb/dist_lock/worker.cpp",
56245626
"ydb/src/ydb/exceptions.cpp":"taxi/uservices/userver/ydb/src/ydb/exceptions.cpp",

ydb/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ userver_module(
2424
UTEST_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests"
2525
GENERATE_DYNAMIC_CONFIGS
2626
DEPENDS core
27+
EMBED_FILES
28+
src/ydb/component.yaml
29+
src/ydb/dist_lock/component_base.yaml
2730
)
2831

2932
# Enforce that userver-ydb requires C++20

ydb/src/ydb/component.cpp

Lines changed: 5 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
#include <dynamic_config/variables/YDB_RETRY_BUDGET.hpp>
3131

32+
#ifndef ARCADIA_ROOT
33+
#include "generated/src/ydb/component.yaml.hpp" // Y_IGNORE
34+
#endif
35+
3236
USERVER_NAMESPACE_BEGIN
3337

3438
namespace ydb {
@@ -190,114 +194,7 @@ void YdbComponent::OnConfigUpdate(const dynamic_config::Snapshot& cfg) {
190194
}
191195

192196
yaml_config::Schema YdbComponent::GetStaticConfigSchema() {
193-
// TODO remove blocking_task_processor
194-
return yaml_config::MergeSchemas<components::ComponentBase>(R"(
195-
type: object
196-
description: component for YDB
197-
additionalProperties: false
198-
properties:
199-
blocking_task_processor:
200-
type: string
201-
description: deprecated, unused property
202-
credentials-provider:
203-
type: string
204-
description: name of credentials provider component
205-
operation-settings:
206-
type: object
207-
description: default operation settings for requests to the database
208-
additionalProperties: false
209-
properties:
210-
retries:
211-
type: integer
212-
description: default retries count for an operation
213-
defaultDescription: 3
214-
operation-timeout:
215-
type: string
216-
description: |
217-
default operation timeout in utils::StringToDuration() format
218-
defaultDescription: 1s
219-
cancel-after:
220-
type: string
221-
description: |
222-
cancel operation after specified string in
223-
utils::StringToDuration() format
224-
defaultDescription: 1s
225-
client-timeout:
226-
type: string
227-
description: default client timeout in utils::StringToDuration format
228-
defaultDescription: 1s
229-
get-session-timeout:
230-
type: string
231-
defaultDescription: 5s
232-
description: default session timeout
233-
databases:
234-
type: object
235-
description: per-databases settings
236-
properties: {}
237-
additionalProperties:
238-
type: object
239-
additionalProperties: false
240-
description: single database settings
241-
properties:
242-
endpoint:
243-
type: string
244-
description: gRPC endpoint URL, e.g. grpc://localhost:1234
245-
database:
246-
type: string
247-
description: full database path, e.g. /ru/service/production/database
248-
credentials:
249-
type: object
250-
properties: {}
251-
additionalProperties: true
252-
description: credentials config passed to credentials provider component
253-
max_pool_size:
254-
type: integer
255-
minimum: 1
256-
defaultDescription: 50
257-
description: maximum connection pool size
258-
min_pool_size:
259-
type: integer
260-
minimum: 1
261-
defaultDescription: 10
262-
description: minimum connection pool size
263-
get_session_retry_limit:
264-
type: integer
265-
minimum: 0
266-
defaultDescription: 5
267-
description: retries count to get session, every attempt with a get-session-timeout
268-
keep-in-query-cache:
269-
type: boolean
270-
defaultDescription: true
271-
description: whether to use query cache
272-
prefer_local_dc:
273-
type: boolean
274-
defaultDescription: true
275-
description: prefer making requests to local data center
276-
sync_start:
277-
type: boolean
278-
defaultDescription: true
279-
description: fail to boot if YDB is not available
280-
aliases:
281-
description: list of aliases for this database
282-
type: array
283-
items:
284-
type: string
285-
description: alias name
286-
by-database-timings-buckets-ms:
287-
type: array
288-
description: histogram bounds for by-database timing metrics
289-
defaultDescription: 40 buckets with +20% increment per step
290-
items:
291-
type: number
292-
description: upper bound for an individual bucket
293-
by-query-timings-buckets-ms:
294-
type: array
295-
description: histogram bounds for by-query timing metrics
296-
defaultDescription: 15 buckets with +100% increment per step
297-
items:
298-
type: number
299-
description: upper bound for an individual bucket
300-
)");
197+
return yaml_config::MergeSchemasFromResource<components::ComponentBase>("src/ydb/component.yaml");
301198
}
302199

303200
void YdbComponent::WriteStatistics(utils::statistics::Writer& writer) const {

ydb/src/ydb/component.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
type: object
2+
description: component for YDB
3+
additionalProperties: false
4+
properties:
5+
blocking_task_processor:
6+
type: string
7+
description: deprecated, unused property
8+
credentials-provider:
9+
type: string
10+
description: name of credentials provider component
11+
operation-settings:
12+
type: object
13+
description: default operation settings for requests to the database
14+
additionalProperties: false
15+
properties:
16+
retries:
17+
type: integer
18+
description: default retries count for an operation
19+
defaultDescription: 3
20+
operation-timeout:
21+
type: string
22+
description: |
23+
default operation timeout in utils::StringToDuration() format
24+
defaultDescription: 1s
25+
cancel-after:
26+
type: string
27+
description: |
28+
cancel operation after specified string in
29+
utils::StringToDuration() format
30+
defaultDescription: 1s
31+
client-timeout:
32+
type: string
33+
description: default client timeout in utils::StringToDuration format
34+
defaultDescription: 1s
35+
get-session-timeout:
36+
type: string
37+
defaultDescription: 5s
38+
description: default session timeout
39+
databases:
40+
type: object
41+
description: per-databases settings
42+
properties: {}
43+
additionalProperties:
44+
type: object
45+
additionalProperties: false
46+
description: single database settings
47+
properties:
48+
endpoint:
49+
type: string
50+
description: gRPC endpoint URL, e.g. grpc://localhost:1234
51+
database:
52+
type: string
53+
description: full database path, e.g. /ru/service/production/database
54+
credentials:
55+
type: object
56+
properties: {}
57+
additionalProperties: true
58+
description: credentials config passed to credentials provider
59+
component
60+
max_pool_size:
61+
type: integer
62+
minimum: 1
63+
defaultDescription: 50
64+
description: maximum connection pool size
65+
min_pool_size:
66+
type: integer
67+
minimum: 1
68+
defaultDescription: 10
69+
description: minimum connection pool size
70+
get_session_retry_limit:
71+
type: integer
72+
minimum: 0
73+
defaultDescription: 5
74+
description: retries count to get session, every attempt with
75+
a get-session-timeout
76+
keep-in-query-cache:
77+
type: boolean
78+
defaultDescription: true
79+
description: whether to use query cache
80+
prefer_local_dc:
81+
type: boolean
82+
defaultDescription: true
83+
description: prefer making requests to local data center
84+
sync_start:
85+
type: boolean
86+
defaultDescription: true
87+
description: fail to boot if YDB is not available
88+
aliases:
89+
description: list of aliases for this database
90+
type: array
91+
items:
92+
type: string
93+
description: alias name
94+
by-database-timings-buckets-ms:
95+
type: array
96+
description: histogram bounds for by-database timing metrics
97+
defaultDescription: 40 buckets with +20% increment per step
98+
items:
99+
type: number
100+
description: upper bound for an individual bucket
101+
by-query-timings-buckets-ms:
102+
type: array
103+
description: histogram bounds for by-query timing metrics
104+
defaultDescription: 15 buckets with +100% increment per step
105+
items:
106+
type: number
107+
description: upper bound for an individual bucket
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
type: object
2+
description: YDB distlock component
3+
additionalProperties: false
4+
properties:
5+
semaphore-name:
6+
type: string
7+
description: name of the semaphore within the coordination node
8+
database-settings:
9+
type: object
10+
description: settings that might be used for a group of related distlock instances
11+
additionalProperties: false
12+
properties:
13+
dbname:
14+
type: string
15+
description: the key of the database within ydb component (NOT the
16+
actual database path)
17+
coordination-node:
18+
type: string
19+
description: name of the coordination node within the database
20+
initial-setup:
21+
type: boolean
22+
description: if true, then create the coordination node and the semaphore
23+
unless they already exist
24+
defaultDescription: true
25+
task-processor:
26+
type: string
27+
description: the name of the TaskProcessor for running DoWork
28+
defaultDescription: the default TaskProcessor, typically main-task-processor
29+
node-settings:
30+
type: object
31+
description: settings for coordination node creation
32+
additionalProperties: false
33+
properties:
34+
session-grace-period:
35+
type: string
36+
description: |
37+
the time after which the lock will be given to another host
38+
after a network failure; this timer starts
39+
on the coordination node conceptually at the same time
40+
as 'session-timeout' timer starts on the service instance
41+
session-timeout:
42+
type: string
43+
description: for how long we will try to restore session after a network failure
44+
before dropping it
45+
defaultDescription: 5s
46+
restart-session-delay:
47+
type: string
48+
description: backoff before attempting to reconnect session after it returns
49+
"permanent failure"
50+
defaultDescription: 1s
51+
acquire-interval:
52+
type: string
53+
description: backoff before repeating a failed Acquire call
54+
defaultDescription: 100ms
55+
restart-delay:
56+
type: string
57+
description: backoff before calling DoWork again after it returns or throws
58+
defaultDescription: 100ms
59+
cancel-task-time-limit:
60+
type: string
61+
description: time, within which a cancelled DoWork is expected to finish
62+
defaultDescription: 5s

0 commit comments

Comments
 (0)