userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
dist_lock_strategy.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/mongo/dist_lock_strategy.hpp
4
/// @brief @copybrief storages::mongo::DistLockStrategy
5
6
#
include
<
chrono
>
7
#
include
<
string
>
8
9
#
include
<
userver
/
dist_lock
/
dist_lock_strategy
.
hpp
>
10
#
include
<
userver
/
storages
/
mongo
/
collection
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
storages::mongo {
15
16
/// @brief Strategy for MongoDB-based distributed locking
17
class
DistLockStrategy
final
:
public
dist_lock
::
DistLockStrategyBase
{
18
public
:
19
/// Targets a distributed lock in a specified collection as a host.
20
DistLockStrategy
(
Collection
collection, std::string lock_name);
21
22
DistLockStrategy(
Collection
collection, std::string lock_name, std::string owner);
23
24
void
Acquire
(std::chrono::milliseconds lock_ttl,
const
std::string& locker_id)
override
;
25
26
void
Prolong
(std::chrono::milliseconds lock_ttl,
const
std::string& locker_id)
override
;
27
28
void
Release
(
const
std::string& locker_id)
override
;
29
30
private
:
31
storages::mongo::
Collection
collection_;
32
std::string lock_name_;
33
std::string owner_prefix_;
34
};
35
36
}
// namespace storages::mongo
37
38
USERVER_NAMESPACE_END
userver
storages
mongo
dist_lock_strategy.hpp
Generated on
for userver by
Doxygen
1.17.0