userver: userver/urabbitmq/broker_interface.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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
13USERVER_NAMESPACE_BEGIN
14
15namespace 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).
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(const Exchange& exchange, Exchange::Type type,
29 utils::Flags<Exchange::Flags> flags,
30 engine::Deadline deadline) = 0;
31
32 /// @brief overload of DeclareExchange
33 virtual void DeclareExchange(const Exchange& exchange, Exchange::Type type,
34 engine::Deadline deadline) = 0;
35
36 /// @brief overload of DeclareExchange
37 virtual void DeclareExchange(const Exchange& exchange,
38 engine::Deadline deadline) = 0;
39
40 /// @brief Declare a queue.
41 ///
42 /// @param queue name of the queue
43 /// @param flags queue flags
44 /// @param deadline execution deadline
45 virtual void DeclareQueue(const Queue& queue,
46 utils::Flags<Queue::Flags> flags,
47 engine::Deadline deadline) = 0;
48
49 /// @brief overload of DeclareQueue
50 virtual void DeclareQueue(const Queue& queue, engine::Deadline deadline) = 0;
51
52 /// @brief Bind a queue to an exchange.
53 ///
54 /// @param exchange the source exchange
55 /// @param queue the target queue
56 /// @param routing_key the routing key
57 /// @param deadline execution deadline
58 virtual void BindQueue(const Exchange& exchange, const Queue& queue,
59 const std::string& routing_key,
60 engine::Deadline deadline) = 0;
61
62 /// @brief Remove an exchange.
63 ///
64 /// @param exchange name of the exchange to remove
65 /// @param deadline execution deadline
66 virtual void RemoveExchange(const Exchange& exchange,
67 engine::Deadline deadline) = 0;
68
69 /// @brief Remove a queue.
70 ///
71 /// @param queue name of the queue to remove
72 /// @param deadline execution deadline
73 virtual void RemoveQueue(const Queue& queue, engine::Deadline deadline) = 0;
74
75 protected:
76 ~IAdminInterface();
77};
78
79/// @brief Publisher interface for the broker.
80/// This class is merely an interface for convenience and you are not expected
81/// to use it directly (use `Client`/`Channel` instead).
83 public:
84 /// @brief Publish a message to an exchange
85 ///
86 /// You have to supply the name of the exchange and a routing key. RabbitMQ
87 /// will then try to send the message to one or more queues.
88 /// By default unroutable messages are silently discarded
89 ///
90 /// @param exchange the exchange to publish to
91 /// @param routing_key the routing key
92 /// @param message the message to send
93 /// @param deadline execution deadline
94 ///
95 /// @note This method is `fire and forget` (no delivery guarantees),
96 /// use `PublishReliable` for delivery guarantees.
97 virtual void Publish(const Exchange& exchange, const std::string& routing_key,
98 const std::string& message, MessageType type,
99 engine::Deadline deadline) = 0;
100
101 /// @brief overload of Publish
102 virtual void Publish(const Exchange& exchange, const std::string& routing_key,
103 const std::string& message,
104 engine::Deadline deadline) = 0;
105
106 protected:
107 ~IChannelInterface();
108};
109
110/// @brief Reliable publisher interface for the broker.
111/// This class is merely an interface for convenience and you are not expected
112/// to use it directly (use `Client`/`ReliableChannel` instead).
114 public:
115 /// @brief Publish a message to an exchange and
116 /// await confirmation from the broker
117 ///
118 /// You have to supply the name of the exchange and a routing key. RabbitMQ
119 /// will then try to send the message to one or more queues.
120 /// By default unroutable messages are silently discarded
121 ///
122 /// @param exchange the exchange to publish to
123 /// @param routing_key the routing key
124 /// @param message the message to send
125 /// @param deadline execution deadline
126 virtual void PublishReliable(const Exchange& exchange,
127 const std::string& routing_key,
128 const std::string& message, MessageType type,
129 engine::Deadline deadline) = 0;
130
131 /// @brief overload of PublishReliable
132 virtual void PublishReliable(const Exchange& exchange,
133 const std::string& routing_key,
134 const std::string& message,
135 engine::Deadline deadline) = 0;
136
137 protected:
138 ~IReliableChannelInterface();
139};
140
141} // namespace urabbitmq
142
143USERVER_NAMESPACE_END