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