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)
42 impl::ConfigId
GetId()
const {
return id_; }
48 template <
typename VariableType,
typename Value>
49 static VariableType Convert(Value&& value) {
50 if constexpr (std::is_same_v<std::decay_t<Value>, formats::json::Value>) {
51 return value.
template As<VariableType>();
53 return static_cast<VariableType>(std::forward<Value>(value));
67class StorageMock
final {
74 StorageMock(std::initializer_list<KeyValue> config_variables);
77 explicit StorageMock(
const std::vector<KeyValue>& config_variables);
82 StorageMock(
const DocsMap& defaults,
const std::vector<KeyValue>& overrides);
84 StorageMock(StorageMock&&)
noexcept;
85 StorageMock& operator=(StorageMock&&)
noexcept;
89 void Extend(
const std::vector<KeyValue>& overrides);
91 Source GetSource()
const&;
92 Snapshot GetSnapshot()
const&;
95 Snapshot GetSource() && =
delete;
96 Snapshot GetSnapshot() && =
delete;
99 std::unique_ptr<impl::StorageData> storage_;