6#include <initializer_list>
10#include <userver/dynamic_config/snapshot.hpp>
11#include <userver/dynamic_config/source.hpp>
12#include <userver/dynamic_config/value.hpp>
13#include <userver/formats/json/value.hpp>
15USERVER_NAMESPACE_BEGIN
17namespace dynamic_config {
21using IsJson = std::enable_if_t<std::is_same_v<T, formats::json::Value>>;
37 template <
typename VariableType,
typename Value = VariableType>
38 KeyValue(
const Key<VariableType>& key, Value&& value)
39 : id_(impl::ConfigIdGetter::Get(key)),
43 impl::ConfigId
GetId()
const {
return id_; }
49 template <
typename VariableType,
typename Value>
50 static VariableType Convert(Value&& value) {
51 if constexpr (std::is_same_v<std::decay_t<Value>, formats::json::Value>) {
52 return value.
template As<VariableType>();
54 return static_cast<VariableType>(std::forward<Value>(value));
68class StorageMock
final {
75 StorageMock(std::initializer_list<KeyValue> config_variables);
78 explicit StorageMock(
const std::vector<KeyValue>& config_variables);
83 StorageMock(
const DocsMap& defaults,
const std::vector<KeyValue>& overrides);
85 StorageMock(StorageMock&&)
noexcept;
86 StorageMock& operator=(StorageMock&&)
noexcept;
90 void Extend(
const std::vector<KeyValue>& overrides);
92 Source GetSource()
const&;
93 Snapshot GetSnapshot()
const&;
96 Snapshot GetSource() && =
delete;
97 Snapshot GetSnapshot() && =
delete;
100 std::unique_ptr<impl::StorageData> storage_;