userver: userver/urabbitmq/typedefs.hpp Source File
Loading...
Searching...
No Matches
typedefs.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/urabbitmq/typedefs.hpp
4/// @brief Convenient typedefs for RabbitMQ entities.
5
6#include <userver/utils/strong_typedef.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace urabbitmq {
11
12/// @brief StrongTypedef alias for a queue name.
13class Queue final : public utils::StrongTypedef<class QueueTag, std::string> {
14public:
15 using utils::StrongTypedef<QueueTag, std::string>::StrongTypedef;
16
17 /// @brief Queue options, consult RabbitMQ docs for better understanding
18 enum class Flags {
19 kNone = 0,
20 kPassive = 1 << 0,
21 kDurable = 1 << 1,
22 kExclusive = 1 << 2,
23 kAutoDelete = 1 << 3,
24 kNoAck = 1 << 4
25 };
26};
27
28/// @brief StrongTypedef alias for an exchange name.
29class Exchange final : public utils::StrongTypedef<class ExchangeTag, std::string> {
30public:
31 using utils::StrongTypedef<ExchangeTag, std::string>::StrongTypedef;
32
33 /// @brief Type of an exchange.
34 ///
35 /// Consult RabbitMQ docs for better understanding.
36 enum class Type {
37 kFanOut,
38 kDirect,
39 kTopic,
40 kHeaders,
41 // plugin required
42 kConsistentHash,
43 // plugin required
44 kMessageDeduplication
45 };
46
47 /// @brief Exchange options, consult RabbitMQ docs for better understanding
48 enum class Flags {
49 kNone = 0,
50 kPassive = 1 << 0,
51 kDurable = 1 << 1,
52 kAutoDelete = 1 << 2,
53 kInternal = 1 << 3,
54 kNoWait = 1 << 4
55 };
56};
57
58/// @brief Message storage type, consult RabbitMQ docs for better understanding
59enum class MessageType {
60 kPersistent,
61 kTransient,
62};
63
64/// @brief Structure holding an AMQP message body along with some of its
65/// metadata fields. This struct is used to pass messages to the end user,
66/// hiding the actual AMQP message object implementation.
68 struct Metadata {
69 std::string exchange;
70 std::string routingKey;
71 };
72 std::string message;
73 Metadata metadata;
74};
75
76} // namespace urabbitmq
77
78USERVER_NAMESPACE_END