userver: userver/dump/config.hpp Source File
Loading...
Searching...
No Matches
config.hpp
1#pragma once
2
3#include <chrono>
4#include <optional>
5#include <string>
6#include <string_view>
7#include <unordered_map>
8
9#include <userver/dynamic_config/snapshot.hpp>
10#include <userver/formats/json/value.hpp>
11#include <userver/yaml_config/yaml_config.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace dump {
16
17namespace impl {
18std::chrono::milliseconds ParseMs(
19 const formats::json::Value& value,
20 std::optional<std::chrono::milliseconds> default_value = {});
21}
22
23extern const std::string_view kDump;
24extern const std::string_view kMaxDumpAge;
25extern const std::string_view kMinDumpInterval;
26
27struct ConfigPatch final {
28 std::optional<bool> dumps_enabled;
29 std::optional<std::chrono::milliseconds> min_dump_interval;
30};
31
32ConfigPatch Parse(const formats::json::Value& value,
33 formats::parse::To<ConfigPatch>);
34
35struct Config final {
36 Config(std::string name, const yaml_config::YamlConfig& config,
37 std::string_view dump_root);
38
39 std::string name;
40 uint64_t dump_format_version;
41 bool world_readable;
42 std::string dump_directory;
43 std::string fs_task_processor;
44 uint64_t max_dump_count;
45 std::optional<std::chrono::milliseconds> max_dump_age;
46 bool max_dump_age_set;
47 bool dump_is_encrypted;
48
49 bool static_dumps_enabled;
50 std::chrono::milliseconds static_min_dump_interval;
51};
52
53struct DynamicConfig final {
54 explicit DynamicConfig(const Config& config, ConfigPatch&& patch);
55
56 bool operator==(const DynamicConfig& other) const noexcept;
57 bool operator!=(const DynamicConfig& other) const noexcept;
58
59 bool dumps_enabled;
60 std::chrono::milliseconds min_dump_interval;
61};
62
63extern const dynamic_config::Key<std::unordered_map<std::string, ConfigPatch>>
64 kConfigSet;
65
66} // namespace dump
67
68USERVER_NAMESPACE_END