7#include <unordered_map>
10#include <userver/components/component_fwd.hpp>
11#include <userver/concurrent/variable.hpp>
12#include <userver/dump/dumper.hpp>
13#include <userver/utils/not_null.hpp>
15USERVER_NAMESPACE_BEGIN
21class DumpControl
final {
23 enum class PeriodicsMode { kDisabled, kEnabled };
25 explicit DumpControl(PeriodicsMode periodics_mode);
27 PeriodicsMode GetPeriodicsMode()
const;
29 void WriteCacheDumps(
const std::vector<std::string>& dumper_names);
31 void ReadCacheDumps(
const std::vector<std::string>& dumper_names);
34 friend class DumperRegistrationHolder;
36 void RegisterDumper(
dump::Dumper& dumper);
38 void UnregisterDumper(
dump::Dumper& dumper);
40 dump::Dumper& FindDumper(
const std::string& name)
const;
42 PeriodicsMode periodics_mode_;
43 concurrent::Variable<std::unordered_map<std::string, utils::NotNull<dump::Dumper*>>> dumpers_;
47class DumperRegistrationHolder
final {
49 DumperRegistrationHolder(DumpControl&,
dump::Dumper&);
51 DumperRegistrationHolder(DumperRegistrationHolder&&) =
delete;
52 DumperRegistrationHolder& operator=(DumperRegistrationHolder&&) =
delete;
53 ~DumperRegistrationHolder();
56 DumpControl& control_;
57 dump::Dumper& dumper_;