userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
coordination.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <memory>
7
#include <string_view>
8
9
#include <ydb-cpp-sdk/client/coordination/coordination.h>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
ydb {
14
15
namespace
impl {
16
class
Driver;
17
}
// namespace impl
18
22
class
CoordinationSession
final {
23
public
:
25
// For internal use only.
26
explicit
CoordinationSession
(NYdb::NCoordination::TSession&& session);
28
30
std::uint64_t
GetSessionId
();
31
33
NYdb::NCoordination::ESessionState
GetSessionState
();
34
36
NYdb::NCoordination::EConnectionState
GetConnectionState
();
37
39
void
Close
();
40
42
void
Ping
();
43
45
void
Reconnect
();
46
50
bool
AcquireSemaphore
(std::string_view name,
const
NYdb::NCoordination::TAcquireSemaphoreSettings& settings);
51
53
bool
ReleaseSemaphore
(std::string_view name);
54
58
NYdb::NCoordination::TSemaphoreDescription
DescribeSemaphore
(
59
std::string_view name,
60
const
NYdb::NCoordination::TDescribeSemaphoreSettings& settings
61
);
62
67
void
CreateSemaphore
(std::string_view name, std::uint64_t limit, std::string_view data = {});
68
70
void
UpdateSemaphore
(std::string_view name, std::string_view data);
71
73
enum class
Mode
{
74
kNormal
,
75
kForce
,
76
};
77
81
void
DeleteSemaphore
(std::string_view name,
Mode
mode =
Mode::kNormal
);
82
83
private
:
84
NYdb::NCoordination::TSession session_;
85
};
86
93
class
CoordinationClient
final {
94
public
:
96
// For internal use only.
97
explicit
CoordinationClient
(std::shared_ptr<impl::Driver> driver);
99
104
CoordinationSession
StartSession
(std::string_view path,
const
NYdb::NCoordination::TSessionSettings& settings);
105
107
void
CreateNode
(std::string_view path,
const
NYdb::NCoordination::TCreateNodeSettings& settings);
108
110
void
AlterNode
(std::string_view path,
const
NYdb::NCoordination::TAlterNodeSettings& settings);
111
113
void
DropNode
(std::string_view path);
114
116
NYdb::NCoordination::TNodeDescription
DescribeNode
(std::string_view path);
117
122
NYdb::NCoordination::TClient&
GetNativeCoordinationClient
();
123
124
private
:
125
std::shared_ptr<impl::Driver> driver_;
126
NYdb::NCoordination::TClient client_;
127
};
128
129
}
// namespace ydb
130
131
USERVER_NAMESPACE_END
userver
ydb
coordination.hpp
Generated on
for userver by
Doxygen
1.17.0