userver: userver/ydb/dist_lock/component_base.hpp Source File
Loading...
Searching...
No Matches
component_base.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <optional>
7#include <string>
8
11
12USERVER_NAMESPACE_BEGIN
13
14namespace testsuite {
15class TestsuiteTasks;
16} // namespace testsuite
17
18namespace ydb {
19
41class DistLockComponentBase : public components::ComponentBase {
42public:
43 DistLockComponentBase(const components::ComponentConfig&, const components::ComponentContext&);
44
55 bool OwnsLock() const noexcept;
56
57 static yaml_config::Schema GetStaticConfigSchema();
58
59protected:
73 virtual void DoWork() = 0;
74
84 virtual void DoWorkTestsuite() { DoWork(); }
85
87 void Start();
88
90 void Stop() noexcept;
91
92private:
93 testsuite::TestsuiteTasks& testsuite_tasks_;
94 const std::string testsuite_task_name_;
95
96 // Worker contains a task that may refer to other fields, so it must be right
97 // before subscriptions. Add new fields above this comment.
98 std::optional<DistLockedWorker> worker_;
99};
100
101} // namespace ydb
102
103USERVER_NAMESPACE_END