Skip to content

Commit 997a9c4

Browse files
committed
feat redis: move schemas to separate files
Tests: протестировано CI commit_hash:d9bc0614346fd1bd0086789031d75f13616cbd1f
1 parent 874f908 commit 997a9c4

File tree

4 files changed

+87
-79
lines changed

4 files changed

+87
-79
lines changed

.mapping.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3667,6 +3667,7 @@
36673667
"redis/src/storages/redis/command_control.cpp":"taxi/uservices/userver/redis/src/storages/redis/command_control.cpp",
36683668
"redis/src/storages/redis/command_control_test.cpp":"taxi/uservices/userver/redis/src/storages/redis/command_control_test.cpp",
36693669
"redis/src/storages/redis/component.cpp":"taxi/uservices/userver/redis/src/storages/redis/component.cpp",
3670+
"redis/src/storages/redis/component.yaml":"taxi/uservices/userver/redis/src/storages/redis/component.yaml",
36703671
"redis/src/storages/redis/component_start_diagnostics_test.cpp":"taxi/uservices/userver/redis/src/storages/redis/component_start_diagnostics_test.cpp",
36713672
"redis/src/storages/redis/exception.cpp":"taxi/uservices/userver/redis/src/storages/redis/exception.cpp",
36723673
"redis/src/storages/redis/expire_reply.cpp":"taxi/uservices/userver/redis/src/storages/redis/expire_reply.cpp",

redis/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ userver_module(
1414
UBENCH_DATABASES redis
1515
DEPENDS core
1616
GENERATE_DYNAMIC_CONFIGS
17+
EMBED_FILES
18+
src/storages/redis/component.yaml
1719
)
1820

1921
# for libev

redis/src/storages/redis/component.cpp

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737

3838
#include <boost/range/adaptor/map.hpp>
3939

40+
#ifndef ARCADIA_ROOT
41+
#include "generated/src/storages/redis/component.yaml.hpp" // Y_IGNORE
42+
#endif
43+
4044
USERVER_NAMESPACE_BEGIN
4145

4246
namespace {
@@ -353,85 +357,7 @@ void Redis::OnSecdistUpdate(const storages::secdist::SecdistConfig& cfg) {
353357
}
354358

355359
yaml_config::Schema Redis::GetStaticConfigSchema() {
356-
return yaml_config::MergeSchemas<ComponentBase>(R"(
357-
type: object
358-
description: Redis client component
359-
additionalProperties: false
360-
properties:
361-
thread_pools:
362-
type: object
363-
description: thread pools options
364-
additionalProperties: false
365-
properties:
366-
redis_thread_pool_size:
367-
type: integer
368-
description: thread count to serve Redis requests
369-
sentinel_thread_pool_size:
370-
type: integer
371-
description: thread count to serve sentinel requests
372-
groups:
373-
type: array
374-
description: array of redis clusters to work with excluding subscribers
375-
items:
376-
type: object
377-
description: redis cluster to work with excluding subscribers
378-
additionalProperties: false
379-
properties:
380-
config_name:
381-
type: string
382-
description: key name in secdist with options for this cluster
383-
db:
384-
type: string
385-
description: name to refer to the cluster in components::Redis::GetClient()
386-
sharding_strategy:
387-
type: string
388-
description: one of RedisStandalone, RedisCluster, KeyShardCrc32, KeyShardTaximeterCrc32 or KeyShardGpsStorageDriver
389-
defaultDescription: "KeyShardTaximeterCrc32"
390-
enum:
391-
- RedisCluster
392-
- KeyShardCrc32
393-
- KeyShardTaximeterCrc32
394-
- KeyShardGpsStorageDriver
395-
- RedisStandalone
396-
allow_reads_from_master:
397-
type: boolean
398-
description: allows read requests from master instance
399-
defaultDescription: false
400-
metrics_level:
401-
type: string
402-
description: set metrics detail level
403-
defaultDescription: "Instance"
404-
enum:
405-
- cluster
406-
- shard
407-
- instance
408-
subscribe_groups:
409-
type: array
410-
description: array of redis clusters to work with in subscribe mode
411-
items:
412-
type: object
413-
description: redis cluster to work with in subscribe mode
414-
additionalProperties: false
415-
properties:
416-
config_name:
417-
type: string
418-
description: key name in secdist with options for this cluster
419-
db:
420-
type: string
421-
description: name to refer to the cluster in components::Redis::GetSubscribeClient()
422-
sharding_strategy:
423-
type: string
424-
description: either RedisCluster or KeyShardTaximeterCrc32
425-
defaultDescription: "KeyShardTaximeterCrc32"
426-
enum:
427-
- RedisCluster
428-
- KeyShardTaximeterCrc32
429-
- RedisStandalone
430-
allow_reads_from_master:
431-
type: boolean
432-
description: allows subscriptions to master instance to distribute load
433-
defaultDescription: false
434-
)");
360+
return yaml_config::MergeSchemasFromResource<ComponentBase>("src/storages/redis/component.yaml");
435361
}
436362

437363
} // namespace components
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
type: object
2+
description: Redis client component
3+
additionalProperties: false
4+
properties:
5+
thread_pools:
6+
type: object
7+
description: thread pools options
8+
additionalProperties: false
9+
properties:
10+
redis_thread_pool_size:
11+
type: integer
12+
description: thread count to serve Redis requests
13+
sentinel_thread_pool_size:
14+
type: integer
15+
description: thread count to serve sentinel requests
16+
groups:
17+
type: array
18+
description: array of redis clusters to work with excluding subscribers
19+
items:
20+
type: object
21+
description: redis cluster to work with excluding subscribers
22+
additionalProperties: false
23+
properties:
24+
config_name:
25+
type: string
26+
description: key name in secdist with options for this cluster
27+
db:
28+
type: string
29+
description: name to refer to the cluster in components::Redis::GetClient()
30+
sharding_strategy:
31+
type: string
32+
description: one of RedisStandalone, RedisCluster, KeyShardCrc32,
33+
KeyShardTaximeterCrc32 or KeyShardGpsStorageDriver
34+
defaultDescription: "KeyShardTaximeterCrc32"
35+
enum:
36+
- RedisCluster
37+
- KeyShardCrc32
38+
- KeyShardTaximeterCrc32
39+
- KeyShardGpsStorageDriver
40+
- RedisStandalone
41+
allow_reads_from_master:
42+
type: boolean
43+
description: allows read requests from master instance
44+
defaultDescription: false
45+
metrics_level:
46+
type: string
47+
description: set metrics detail level
48+
defaultDescription: "Instance"
49+
enum:
50+
- cluster
51+
- shard
52+
- instance
53+
subscribe_groups:
54+
type: array
55+
description: array of redis clusters to work with in subscribe mode
56+
items:
57+
type: object
58+
description: redis cluster to work with in subscribe mode
59+
additionalProperties: false
60+
properties:
61+
config_name:
62+
type: string
63+
description: key name in secdist with options for this cluster
64+
db:
65+
type: string
66+
description: name to refer to the cluster in components::Redis::GetSubscribeClient()
67+
sharding_strategy:
68+
type: string
69+
description: either RedisCluster or KeyShardTaximeterCrc32
70+
defaultDescription: "KeyShardTaximeterCrc32"
71+
enum:
72+
- RedisCluster
73+
- KeyShardTaximeterCrc32
74+
- RedisStandalone
75+
allow_reads_from_master:
76+
type: boolean
77+
description: allows subscriptions to master instance to distribute
78+
load
79+
defaultDescription: false

0 commit comments

Comments
 (0)