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