userver: userver/urabbitmq/admin_channel.hpp Source File
Loading...
Searching...
No Matches
admin_channel.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/urabbitmq/admin_channel.hpp
4/// @brief Administrative 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
12USERVER_NAMESPACE_BEGIN
13
14namespace urabbitmq {
15
16class ConnectionPtr;
17
18/// @brief Administrative interface for the broker.
19/// You may use this class to setup your exchanges/queues/bindings.
20/// You may as well use `Client` itself instead.
21///
22/// You are not expected to store this class for a long time, because it takes
23/// a connection from the underlying connections pool.
24///
25/// Usually retrieved from `Client`
26class AdminChannel final : IAdminInterface {
27 public:
28 AdminChannel(ConnectionPtr&& channel);
29 ~AdminChannel();
30
31 AdminChannel(AdminChannel&& other) noexcept;
32
33 void DeclareExchange(const Exchange& exchange, Exchange::Type type,
34 utils::Flags<Exchange::Flags> flags,
35 engine::Deadline deadline) override;
36
37 void DeclareExchange(const Exchange& exchange, Exchange::Type type,
38 engine::Deadline deadline) override {
39 DeclareExchange(exchange, type, {}, deadline);
40 }
41
42 void DeclareExchange(const Exchange& exchange,
43 engine::Deadline deadline) override {
44 DeclareExchange(exchange, Exchange::Type::kFanOut, {}, deadline);
45 }
46
47 void DeclareQueue(const Queue& queue, utils::Flags<Queue::Flags> flags,
48 engine::Deadline deadline) override;
49
50 void DeclareQueue(const Queue& queue, engine::Deadline deadline) override {
51 DeclareQueue(queue, {}, deadline);
52 }
53
54 void BindQueue(const Exchange& exchange, const Queue& queue,
55 const std::string& routing_key,
56 engine::Deadline deadline) override;
57
58 void RemoveExchange(const Exchange& exchange,
59 engine::Deadline deadline) override;
60
61 void RemoveQueue(const Queue& queue, engine::Deadline deadline) override;
62
63 private:
64 utils::FastPimpl<ConnectionPtr, 32, 8> impl_;
65};
66
67} // namespace urabbitmq
68
69USERVER_NAMESPACE_END