]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_amqp.h
bbfce2d5dcd66a293699233131ba7dd3e97fcf0b
[ceph.git] / ceph / src / rgw / rgw_amqp.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #pragma once
5
6 #include <string>
7 #include <functional>
8 #include <boost/smart_ptr/intrusive_ptr.hpp>
9
10 #include "include/common_fwd.h"
11
12 namespace rgw::amqp {
13 // forward declaration of connection object
14 struct connection_t;
15
16 typedef boost::intrusive_ptr<connection_t> connection_ptr_t;
17
18 // required interfaces needed so that connection_t could be used inside boost::intrusive_ptr
19 void intrusive_ptr_add_ref(const connection_t* p);
20 void intrusive_ptr_release(const connection_t* p);
21
22 // the reply callback is expected to get an integer parameter
23 // indicating the result, and not to return anything
24 typedef std::function<void(int)> reply_callback_t;
25
26 // initialize the amqp manager
27 bool init(CephContext* cct);
28
29 // shutdown the amqp manager
30 void shutdown();
31
32 // connect to an amqp endpoint
33 connection_ptr_t connect(const std::string& url, const std::string& exchange);
34
35 // publish a message over a connection that was already created
36 int publish(connection_ptr_t& conn,
37 const std::string& topic,
38 const std::string& message);
39
40 // publish a message over a connection that was already created
41 // and pass a callback that will be invoked (async) when broker confirms
42 // receiving the message
43 int publish_with_confirm(connection_ptr_t& conn,
44 const std::string& topic,
45 const std::string& message,
46 reply_callback_t cb);
47
48 // convert the integer status returned from the "publish" function to a string
49 std::string status_to_string(int s);
50
51 // number of connections
52 size_t get_connection_count();
53
54 // return the number of messages that were sent
55 // to broker, but were not yet acked/nacked/timedout
56 size_t get_inflight();
57
58 // running counter of successfully queued messages
59 size_t get_queued();
60
61 // running counter of dequeued messages
62 size_t get_dequeued();
63
64 // number of maximum allowed connections
65 size_t get_max_connections();
66
67 // number of maximum allowed inflight messages
68 size_t get_max_inflight();
69
70 // maximum number of messages in the queue
71 size_t get_max_queue();
72
73 // disconnect from an amqp broker
74 bool disconnect(connection_ptr_t& conn);
75
76 }
77