userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
notify.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/postgres/notify.hpp
4
/// @brief Asynchronous notifications
5
6
#
include
<
userver
/
engine
/
deadline
.
hpp
>
7
#
include
<
userver
/
storages
/
postgres
/
options
.
hpp
>
8
#
include
<
userver
/
utils
/
fast_pimpl
.
hpp
>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
storages::
postgres
{
13
14
namespace
detail {
15
class
ConnectionPtr;
16
}
17
18
struct
Notification
{
19
std::string channel;
20
std::optional<std::string> payload;
21
};
22
23
/// @brief RAII scope for receiving notifications.
24
///
25
/// Used for waiting for notifications on PostgreSQL connections. Created by
26
/// calling storages::postgres::Cluster::Listen(). Exclusively holds a
27
/// connection from a pool.
28
///
29
/// Non-copyable.
30
///
31
/// @par Usage synopsis
32
/// @code
33
/// auto scope = cluster.Listen("channel");
34
/// cluster.Execute(pg::ClusterHostType::kMaster,
35
/// "select pg_notify('channel', NULL)");
36
/// auto ntf = scope.WaitNotify(engine::Deadline::FromDuration(100ms));
37
/// @endcode
38
class
[[nodiscard]] NotifyScope
final
{
39
public
:
40
NotifyScope(detail::ConnectionPtr conn, std::string_view channel,
OptionalCommandControl
cmd_ctl);
41
42
~NotifyScope();
43
44
NotifyScope(NotifyScope&&)
noexcept
;
45
NotifyScope& operator=(NotifyScope&&)
noexcept
;
46
47
NotifyScope(
const
NotifyScope&) =
delete
;
48
NotifyScope& operator=(
const
NotifyScope&) =
delete
;
49
50
/// Wait for notification on connection
51
Notification
WaitNotify
(engine::Deadline deadline);
52
53
private
:
54
struct
Impl;
55
USERVER_NAMESPACE::
utils
::FastPimpl<Impl, 88, 8> pimpl_;
56
};
57
58
}
// namespace storages::postgres
59
60
USERVER_NAMESPACE_END
userver
storages
postgres
notify.hpp
Generated on
for userver by
Doxygen
1.17.0