-
Notifications
You must be signed in to change notification settings - Fork 0
/
consumer.hpp
52 lines (38 loc) · 1.41 KB
/
consumer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef CONSUMER_HPP
#define CONSUMER_HPP
#include <memory>
#include <vector>
/* --- TODO: Check if constructor parameters are reasonable --- */
class Consumer
{
public:
Consumer();
Consumer(std::string _username, std::string _password, std::string _group_id,
std::string _security_protocol, std::string _sasl_mechanism,
std::string _ssl_ca_location, std::string _brokers);
~Consumer();
int init_consumer_default();
int add_topics(const std::vector<std::string>& input);
int subscribe();
std::shared_ptr<RdKafka::Message> consume(int timeout_ms) const;
int close();
private:
class CRebalanceCb : public RdKafka::RebalanceCb {
void rebalance_cb (RdKafka::KafkaConsumer *consumer, RdKafka::ErrorCode err,
std::vector<RdKafka::TopicPartition*> &partitions);
};
std::string errstr;
std::shared_ptr<RdKafka::Conf> global_conf;
std::shared_ptr<RdKafka::Conf> topic_conf;
std::shared_ptr<RdKafka::KafkaConsumer> consumer;
std::shared_ptr<CRebalanceCb> reb_cb_obj;
std::string username;
std::string password;
std::string group_id;
std::string security_protocol;
std::string sasl_mechanism;
std::string ssl_ca_location;
std::string brokers;
std::vector<std::string> topics;
};
#endif