userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
cache_config.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/cache/cache_config.hpp
4
/// @brief Cache component configuration, update modes and dynamic config patches
5
6
#
include
<
chrono
>
7
#
include
<
optional
>
8
#
include
<
stdexcept
>
9
#
include
<
string
>
10
#
include
<
unordered_map
>
11
12
#
include
<
userver
/
cache
/
update_type
.
hpp
>
13
#
include
<
userver
/
dynamic_config
/
snapshot
.
hpp
>
14
#
include
<
userver
/
formats
/
json_fwd
.
hpp
>
15
#
include
<
userver
/
yaml_config
/
fwd
.
hpp
>
16
17
USERVER_NAMESPACE_BEGIN
18
19
namespace
dump
{
20
struct
Config;
21
}
// namespace dump
22
23
namespace
cache
{
24
25
class
ConfigError
:
public
std::logic_error {
26
public
:
27
using
std::logic_error::logic_error;
28
};
29
30
enum
class
FirstUpdateMode {
31
kRequired,
32
kBestEffort,
33
kSkip,
34
};
35
36
FirstUpdateMode Parse(
const
yaml_config::
YamlConfig
& config, formats::
parse
::
To
<FirstUpdateMode>);
37
38
std::string_view ToString(FirstUpdateMode);
39
40
enum
class
FirstUpdateType {
41
kFull,
42
kIncremental,
43
kIncrementalThenAsyncFull,
44
};
45
46
FirstUpdateType Parse(
const
yaml_config::
YamlConfig
& config, formats::
parse
::
To
<FirstUpdateType>);
47
48
std::string_view ToString(FirstUpdateType);
49
50
struct
ConfigPatch
final
{
51
std::chrono::milliseconds update_interval{};
52
std::chrono::milliseconds update_jitter{};
53
std::chrono::milliseconds full_update_interval{};
54
std::chrono::milliseconds full_update_jitter{};
55
std::optional<std::chrono::milliseconds> exception_interval{};
56
bool
updates_enabled{
true
};
57
std::optional<std::uint64_t> alert_on_failing_to_update_times{0};
58
};
59
60
ConfigPatch Parse(
const
formats::
json
::
Value
& value, formats::
parse
::
To
<ConfigPatch>);
61
62
struct
Config
final
{
63
Config() =
default
;
64
explicit
Config(
const
yaml_config::
YamlConfig
& config,
const
std::optional<
dump
::Config>& dump_config);
65
66
Config MergeWith(
const
ConfigPatch& patch)
const
;
67
68
AllowedUpdateTypes
allowed_update_types{};
69
bool
allow_first_update_failure{};
70
std::optional<
bool
> force_periodic_update;
71
bool
config_updates_enabled{};
72
bool
has_pre_assign_check{};
73
std::optional<std::string> task_processor_name;
74
std::chrono::milliseconds cleanup_interval{};
75
bool
is_strong_period{};
76
std::optional<std::uint64_t> failed_updates_before_expiration;
77
bool
is_safe_data_lifetime{};
78
79
FirstUpdateMode first_update_mode{};
80
FirstUpdateType first_update_type{};
81
82
std::chrono::milliseconds update_interval{};
83
std::chrono::milliseconds update_jitter{};
84
std::chrono::milliseconds full_update_interval{};
85
std::chrono::milliseconds full_update_jitter{};
86
std::optional<std::chrono::milliseconds> exception_interval;
87
bool
updates_enabled{};
88
std::uint64_t alert_on_failing_to_update_times{};
89
};
90
91
extern
const
dynamic_config::
Key
<std::unordered_map<std::string, ConfigPatch>> kCacheConfigSet;
92
93
}
// namespace cache
94
95
USERVER_NAMESPACE_END
userver
cache
cache_config.hpp
Generated on
for userver by
Doxygen
1.17.0