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
19ParseMs(const formats::json::Value& value, std::optional<std::chrono::milliseconds> default_value = {});
20}
21
22extern const std::string_view kDump;
23extern const std::string_view kMaxDumpAge;
24extern const std::string_view kMinDumpInterval;
25
26struct ConfigPatch final {
27 std::optional<bool> dumps_enabled;
28 std::optional<std::chrono::milliseconds> min_dump_interval;
29};
30
31ConfigPatch Parse(const formats::json::Value& value, formats::parse::To<ConfigPatch>);
32
33struct Config final {
34 Config(std::string name, const yaml_config::YamlConfig& config, std::string_view dump_root);
35
36 std::string name;
37 uint64_t dump_format_version;
38 bool world_readable;
39 std::string dump_directory;
40 std::string fs_task_processor;
41 uint64_t max_dump_count;
42 std::optional<std::chrono::milliseconds> max_dump_age;
43 bool max_dump_age_set;
44 bool dump_is_encrypted;
45
46 bool static_dumps_enabled;
47 std::chrono::milliseconds static_min_dump_interval;
48};
49
50struct DynamicConfig final {
51 explicit DynamicConfig(const Config& config, ConfigPatch&& patch);
52
53 bool operator==(const DynamicConfig& other) const noexcept;
54 bool operator!=(const DynamicConfig& other) const noexcept;
55
56 bool dumps_enabled;
57 std::chrono::milliseconds min_dump_interval;
58};
59
60extern const dynamic_config::Key<std::unordered_map<std::string, ConfigPatch>> kConfigSet;
61
62} // namespace dump
63
64USERVER_NAMESPACE_END