#include <userver/dump/dumper.hpp>
Manages dumps of a cache-like component.
The class is thread-safe.
Used in components::CachingComponentBase
.
Automatically subscribes to:
USERVER_DUMPS
under dumper_name
cache.{dumper_name}.dump
Dumps will be stored in {dump-root}/{dumper_name}
, where dump-root
is taken from components::DumpConfigurator
.
Here, dumper_name
is the name of the parent component.
Name | Type | Description | Default value |
---|---|---|---|
enable | boolean | Whether this Dumper should actually read and write dumps | (required) |
world-readable | boolean | If true , dumps are created with access 0444 , otherwise with access 0400 | (required) |
format-version | integer | Allows to ignore dumps written with an obsolete format-version | (required) |
max-age | optional string (duration) | Overdue dumps are ignored | null |
max-count | optional integer | Old dumps over the limit are removed from disk | 1 |
min-interval | string (duration) | WriteDumpAsync calls performed in a fast succession are ignored | 0s |
fs-task-processor | string | TaskProcessor for blocking disk IO | fs-task-processor |
encrypted | boolean | Whether to encrypt the dump | false |
Definition at line 94 of file dumper.hpp.
Public Member Functions | |
Dumper (const components::ComponentConfig &config, const components::ComponentContext &context, DumpableEntity &dumpable) | |
The primary constructor for when Dumper is stored in a component. | |
Dumper (const Config &initial_config, std::unique_ptr< OperationsFactory > rw_factory, engine::TaskProcessor &fs_task_processor, dynamic_config::Source config_source, utils::statistics::Storage &statistics_storage, testsuite::DumpControl &dump_control, DumpableEntity &dumpable) | |
For internal use only. | |
Dumper (Dumper &&)=delete | |
Dumper & | operator= (Dumper &&)=delete |
const std::string & | Name () const |
std::optional< TimePoint > | ReadDump () |
Read data from a dump, if any. | |
void | WriteDumpSyncDebug () |
Forces the Dumper to write a dump synchronously. | |
void | ReadDumpDebug () |
Forces the Dumper to read from a dump synchronously. | |
void | OnUpdateCompleted () |
Notifies the Dumper of an update in the DumpableEntity | |
void | OnUpdateCompleted (TimePoint update_time, UpdateType update_type) |
void | CancelWriteTaskAndWait () |
Cancel and wait for the task running background writes. Also disables operations via testsuite dump control. | |
Static Public Member Functions | |
static yaml_config::Schema | GetStaticConfigSchema () |
Returns the static config schema for a components::LoggableComponentBase with an added dump sub-section. | |
dump::Dumper::Dumper | ( | const components::ComponentConfig & | config, |
const components::ComponentContext & | context, | ||
DumpableEntity & | dumpable ) |
void dump::Dumper::CancelWriteTaskAndWait | ( | ) |
Cancel and wait for the task running background writes. Also disables operations via testsuite dump control.
CancelWriteTaskAndWait is automatically called in the destructor. This method must be called explicitly if the DumpableEntity
may start its destruction before the Dumper
is destroyed.
After calling this method, OnUpdateCompleted calls have no effect.
void dump::Dumper::OnUpdateCompleted | ( | ) |
Notifies the Dumper
of an update in the DumpableEntity
A dump will be written asynchronously as soon as:
OnUpdateCompleted
since the last written dump,enabled
in the dynamic config, andmin-interval
time has passedThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
update_time | The time at which the data has been guaranteed to be up-to-date |
update_type | Whether the update modified the data or confirmed its actuality, UpdateType::kModified by default |
std::optional< TimePoint > dump::Dumper::ReadDump | ( | ) |
Read data from a dump, if any.
update_time
of the loaded dump on success, null
otherwise void dump::Dumper::ReadDumpDebug | ( | ) |
void dump::Dumper::WriteDumpSyncDebug | ( | ) |