10#include <unordered_set>
12#include <userver/cache/cache_statistics.hpp>
13#include <userver/cache/caching_component_base.hpp>
14#include <userver/cache/update_type.hpp>
15#include <userver/components/component_fwd.hpp>
16#include <userver/concurrent/variable.hpp>
17#include <userver/dynamic_config/client/client.hpp>
18#include <userver/dynamic_config/snapshot.hpp>
19#include <userver/dynamic_config/storage/component.hpp>
20#include <userver/dynamic_config/updater/additional_keys_token.hpp>
21#include <userver/dynamic_config/updates_sink/component.hpp>
22#include <userver/engine/mutex.hpp>
23#include <userver/utils/impl/transparent_hash.hpp>
25USERVER_NAMESPACE_BEGIN
75class DynamicConfigClientUpdater
final
76 :
public CachingComponentBase<dynamic_config::DocsMap> {
82 DynamicConfigClientUpdater(
const ComponentConfig&,
const ComponentContext&);
84 ~DynamicConfigClientUpdater() override;
89 std::vector<std::string> keys);
95 const std::chrono::system_clock::time_point& last_update,
96 const std::chrono::system_clock::time_point& now,
97 cache::UpdateStatisticsScope&) override;
99 void UpdateFull(
const std::vector<std::string>& docs_map_keys,
100 cache::UpdateStatisticsScope&);
102 void UpdateIncremental(
const std::vector<std::string>& docs_map_keys,
103 cache::UpdateStatisticsScope&);
105 dynamic_config::DocsMap MergeDocsMap(
const dynamic_config::DocsMap& current,
106 dynamic_config::DocsMap&& update,
107 const std::vector<std::string>& removed);
108 void StoreIfEnabled(
const dynamic_config::DocsMap& value);
110 using DocsMapKeys = utils::impl::TransparentSet<std::string>;
111 using AdditionalDocsMapKeys =
112 std::unordered_set<std::shared_ptr<std::vector<std::string>>>;
114 std::vector<std::string> GetDocsMapKeysToFetch(
115 AdditionalDocsMapKeys& additional_docs_map_keys);
117 void UpdateAdditionalKeys(
const std::vector<std::string>& keys);
120 const dynamic_config::DocsMap& new_value)
const;
123 const bool load_only_my_values_;
124 const bool store_enabled_;
126 dynamic_config::Client& config_client_;
128 dynamic_config::Client::Timestamp server_timestamp_;
130 engine::Mutex update_config_mutex_;
131 DocsMapKeys docs_map_keys_;
132 concurrent::Variable<AdditionalDocsMapKeys> additional_docs_map_keys_;
136inline constexpr bool kHasValidate<DynamicConfigClientUpdater> =
true;