]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_amqp.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / rgw / rgw_amqp.h
CommitLineData
11fdf7f2 1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
9f95a23c 2// vim: ts=8 sw=2 smarttab ft=cpp
11fdf7f2
TL
3
4#pragma once
5
6#include <string>
7#include <functional>
8#include <boost/smart_ptr/intrusive_ptr.hpp>
9
9f95a23c 10#include "include/common_fwd.h"
eafe8130 11
11fdf7f2
TL
12namespace rgw::amqp {
13// forward declaration of connection object
14struct connection_t;
15
16typedef boost::intrusive_ptr<connection_t> connection_ptr_t;
17
18// required interfaces needed so that connection_t could be used inside boost::intrusive_ptr
19void intrusive_ptr_add_ref(const connection_t* p);
20void 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
24typedef std::function<void(int)> reply_callback_t;
25
eafe8130
TL
26// initialize the amqp manager
27bool init(CephContext* cct);
28
29// shutdown the amqp manager
30void shutdown();
31
11fdf7f2
TL
32// connect to an amqp endpoint
33connection_ptr_t connect(const std::string& url, const std::string& exchange);
34
35// publish a message over a connection that was already created
36int 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
43int 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
49std::string status_to_string(int s);
50
51// number of connections
52size_t get_connection_count();
53
54// return the number of messages that were sent
55// to broker, but were not yet acked/nacked/timedout
56size_t get_inflight();
57
58// running counter of successfully queued messages
59size_t get_queued();
60
61// running counter of dequeued messages
62size_t get_dequeued();
63
64// number of maximum allowed connections
65size_t get_max_connections();
66
67// number of maximum allowed inflight messages
68size_t get_max_inflight();
69
70// maximum number of messages in the queue
71size_t get_max_queue();
72
73// disconnect from an amqp broker
74bool disconnect(connection_ptr_t& conn);
75
76}
77