userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
broker_interface.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/urabbitmq/broker_interface.hpp
4
/// @brief A bunch of interface classes
5
6
#
include
<
string
>
7
8
#
include
<
userver
/
engine
/
deadline
.
hpp
>
9
#
include
<
userver
/
utils
/
flags
.
hpp
>
10
11
#
include
<
userver
/
urabbitmq
/
typedefs
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
urabbitmq {
16
17
/// @brief Administrative interface for the broker.
18
/// This class is merely an interface for convenience and you are not expected
19
/// to use it directly (use `Client`/`AdminChannel` instead).
20
class
IAdminInterface
{
21
public
:
22
/// @brief Declare an exchange.
23
///
24
/// @param exchange name of the exchange
25
/// @param type exchange type
26
/// @param flags exchange flags
27
/// @param deadline execution deadline
28
virtual
void
DeclareExchange
(
29
const
Exchange& exchange,
30
Exchange::
Type
type,
31
utils
::Flags<Exchange::
Flags
> flags,
32
engine::Deadline deadline
33
) = 0;
34
35
/// @brief overload of DeclareExchange
36
virtual
void
DeclareExchange
(
const
Exchange& exchange, Exchange::
Type
type, engine::Deadline deadline) = 0;
37
38
/// @brief overload of DeclareExchange
39
virtual
void
DeclareExchange
(
const
Exchange& exchange, engine::Deadline deadline) = 0;
40
41
/// @brief Declare a queue.
42
///
43
/// @param queue name of the queue
44
/// @param flags queue flags
45
/// @param headers metadata table of the queue
46
/// @param deadline execution deadline
47
/// @returns the broker's `queue.declare-ok` reply (queue name, message and
48
/// consumer counts)
49
virtual
QueueDeclareResponse
DeclareQueue
(
50
const
Queue& queue,
51
utils
::Flags<Queue::
Flags
> flags,
52
const
std::unordered_map<std::string,
HeaderValue
>& headers,
53
engine::Deadline deadline) = 0;
54
55
/// @brief overload of DeclareQueue
56
virtual
QueueDeclareResponse
57
DeclareQueue
(
const
Queue& queue,
utils
::Flags<Queue::
Flags
> flags, engine::Deadline deadline) = 0;
58
59
/// @brief overload of DeclareQueue
60
virtual
QueueDeclareResponse
DeclareQueue
(
const
Queue& queue, engine::Deadline deadline) = 0;
61
62
/// @brief Bind a queue to an exchange.
63
///
64
/// @param exchange the source exchange
65
/// @param queue the target queue
66
/// @param routing_key the routing key
67
/// @param deadline execution deadline
68
virtual
void
BindQueue
(
69
const
Exchange& exchange,
70
const
Queue& queue,
71
const
std::string& routing_key,
72
engine::Deadline deadline
73
) = 0;
74
75
/// @brief Remove an exchange.
76
///
77
/// @param exchange name of the exchange to remove
78
/// @param deadline execution deadline
79
virtual
void
RemoveExchange
(
const
Exchange& exchange, engine::Deadline deadline) = 0;
80
81
/// @brief Remove a queue.
82
///
83
/// @param queue name of the queue to remove
84
/// @param deadline execution deadline
85
virtual
void
RemoveQueue
(
const
Queue& queue, engine::Deadline deadline) = 0;
86
87
protected
:
88
~IAdminInterface();
89
};
90
91
/// @brief Publisher interface for the broker.
92
/// This class is merely an interface for convenience and you are not expected
93
/// to use it directly (use `Client`/`Channel` instead).
94
class
IChannelInterface
{
95
public
:
96
/// @brief Publish a message to an exchange
97
///
98
/// You have to supply the name of the exchange and a routing key. RabbitMQ
99
/// will then try to send the message to one or more queues.
100
/// By default, unroutable messages are silently discarded
101
///
102
/// @param exchange the exchange to publish to
103
/// @param routing_key the routing key
104
/// @param message the message to send
105
/// @param type see @ref MessageType
106
/// @param deadline execution deadline
107
///
108
/// @note This method is `fire and forget` (no delivery guarantees),
109
/// use `PublishReliable` for delivery guarantees.
110
virtual
void
Publish
(
111
const
Exchange& exchange,
112
const
std::string& routing_key,
113
const
std::string& message,
114
MessageType
type,
115
engine::Deadline deadline
116
) = 0;
117
118
/// @brief overload of Publish
119
virtual
void
Publish
(
120
const
Exchange& exchange,
121
const
std::string& routing_key,
122
const
std::string& message,
123
engine::Deadline deadline
124
) = 0;
125
126
/// @brief overload of Publish
127
virtual
void
Publish
(
128
const
Exchange& exchange,
129
const
std::string& routing_key,
130
const
Envelope
& envelope,
131
engine::Deadline deadline
132
) = 0;
133
134
/// @brief Gets a single message.
135
///
136
/// You should to set `kNoAck` flag in order for server to implicitly
137
/// acknowledge gathered message.
138
/// By default, the gathered message has to be explicitly acknowledged
139
/// or rejected, however there's no functionality for that yet, so the flag is
140
/// basically mandatory.
141
/// This API is a subject to change.
142
///
143
/// @note This method uses a polling model for retrieving a message, which is
144
/// comparatively expensive and might lead to a connection reset in case of a
145
/// timeout. This method could come in handy in some cases, but in general we
146
/// recommend to set up a `Consumer` instead.
147
///
148
/// @param queue name of the queue
149
/// @param flags queue flags
150
/// @param deadline execution deadline
151
virtual
std::string
Get
(
const
Queue& queue,
utils
::Flags<Queue::
Flags
> flags, engine::Deadline deadline) = 0;
152
153
protected
:
154
~IChannelInterface();
155
};
156
157
/// @brief Reliable publisher interface for the broker.
158
/// This class is merely an interface for convenience and you are not expected
159
/// to use it directly (use `Client`/`ReliableChannel` instead).
160
class
IReliableChannelInterface
{
161
public
:
162
/// @brief Publish a message to an exchange and
163
/// await confirmation from the broker
164
///
165
/// You have to supply the name of the exchange and a routing key. RabbitMQ
166
/// will then try to send the message to one or more queues.
167
/// By default, unroutable messages are silently discarded
168
///
169
/// @param exchange the exchange to publish to
170
/// @param routing_key the routing key
171
/// @param message the message to send
172
/// @param type see @ref MessageType
173
/// @param deadline execution deadline
174
virtual
void
PublishReliable
(
175
const
Exchange& exchange,
176
const
std::string& routing_key,
177
const
std::string& message,
178
MessageType
type,
179
engine::Deadline deadline
180
) = 0;
181
182
/// @brief overload of PublishReliable
183
virtual
void
PublishReliable
(
184
const
Exchange& exchange,
185
const
std::string& routing_key,
186
const
std::string& message,
187
engine::Deadline deadline
188
) = 0;
189
190
/// @brief overload of PublishReliable
191
virtual
void
PublishReliable
(
192
const
Exchange& exchange,
193
const
std::string& routing_key,
194
const
Envelope
& envelope,
195
engine::Deadline deadline
196
) = 0;
197
198
protected
:
199
~IReliableChannelInterface();
200
};
201
202
}
// namespace urabbitmq
203
204
USERVER_NAMESPACE_END
userver
urabbitmq
broker_interface.hpp
Generated on
for userver by
Doxygen
1.17.0