userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
channel.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/urabbitmq/channel.hpp
4
/// @brief Publisher interface for the broker.
5
6
#
include
<
memory
>
7
8
#
include
<
userver
/
utils
/
fast_pimpl
.
hpp
>
9
10
#
include
<
userver
/
urabbitmq
/
broker_interface
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
urabbitmq {
15
16
class
ConnectionPtr;
17
18
/// @brief Publisher interface for the broker.
19
/// You may use this class to publish your messages.
20
///
21
/// You may as well use `Client` itself instead, this class just gives you
22
/// some order guaranties.
23
///
24
/// You are not expected to store this class for a long time, because it takes
25
/// a connection from the underlying connections pool.
26
///
27
/// Usually retrieved from `Client`.
28
class
Channel
final
:
IChannelInterface
{
29
public
:
30
Channel(ConnectionPtr&& channel);
31
~Channel();
32
33
Channel(Channel&& other)
noexcept
;
34
35
void
Publish
(
36
const
Exchange& exchange,
37
const
std::string& routing_key,
38
const
std::string& message,
39
MessageType
type,
40
engine::Deadline deadline
41
)
override
{
42
Publish
(
exchange
,
routing_key
,
Envelope
{message, type, {}, {}, {}}
,
deadline
)
;
43
}
44
45
void
Publish
(
46
const
Exchange& exchange,
47
const
std::string& routing_key,
48
const
std::string& message,
49
engine::Deadline deadline
50
)
override
{
51
Publish
(
exchange
,
routing_key
,
message
,
MessageType
::kTransient
,
deadline
)
;
52
};
53
54
void
Publish
(
55
const
Exchange& exchange,
56
const
std::string& routing_key,
57
const
Envelope
& envelope,
58
engine::Deadline deadline
59
)
override
;
60
61
std::string
Get
(
const
Queue& queue,
utils
::Flags<Queue::
Flags
> flags, engine::Deadline deadline)
override
;
62
63
private
:
64
utils
::FastPimpl<ConnectionPtr, 32, 8> impl_;
65
};
66
67
/// @brief Reliable publisher interface for the broker.
68
/// You may use this class to reliably publish your messages
69
/// (publisher-confirms).
70
///
71
/// You may as well use `Client` itself instead, this class gives no additional
72
/// benefits and is present merely for convenience.
73
///
74
/// You are not expected to store this class for a long time, because it takes
75
/// a connection from the underlying connections pool.
76
///
77
/// Usually retrieved from `Client`.
78
class
ReliableChannel
final
:
IReliableChannelInterface
{
79
public
:
80
ReliableChannel(ConnectionPtr&& channel);
81
~ReliableChannel();
82
83
ReliableChannel(ReliableChannel&& other)
noexcept
;
84
85
void
PublishReliable
(
86
const
Exchange& exchange,
87
const
std::string& routing_key,
88
const
std::string& message,
89
MessageType
type,
90
engine::Deadline deadline
91
)
override
{
92
PublishReliable
(
exchange
,
routing_key
,
Envelope
{message, type, {}, {}, {}}
,
deadline
)
;
93
}
94
95
void
PublishReliable
(
96
const
Exchange& exchange,
97
const
std::string& routing_key,
98
const
std::string& message,
99
engine::Deadline deadline
100
)
override
{
101
PublishReliable
(
exchange
,
routing_key
,
message
,
MessageType
::kTransient
,
deadline
)
;
102
}
103
104
virtual
void
PublishReliable
(
105
const
Exchange& exchange,
106
const
std::string& routing_key,
107
const
Envelope
& envelope,
108
engine::Deadline deadline
109
)
override
;
110
111
private
:
112
utils
::FastPimpl<ConnectionPtr, 32, 8> impl_;
113
};
114
115
}
// namespace urabbitmq
116
117
USERVER_NAMESPACE_END
userver
urabbitmq
channel.hpp
Generated on
for userver by
Doxygen
1.17.0