Modern C++ Kafka API
ConsumerCommon.h
1 #pragma once
2 
3 #include <kafka/Project.h>
4 
5 #include <kafka/Error.h>
6 #include <kafka/RdKafkaHelper.h>
7 #include <kafka/Types.h>
8 
9 #include <librdkafka/rdkafka.h>
10 
11 #include <functional>
12 
13 
14 namespace KAFKA_API { namespace clients { namespace consumer {
15 
20  enum class RebalanceEventType { PartitionsAssigned, PartitionsRevoked };
21 
25  using RebalanceCallback = std::function<void(RebalanceEventType eventType, const TopicPartitions& topicPartitions)>;
26 
30 #if COMPILER_SUPPORTS_CPP_17
31  const inline RebalanceCallback NullRebalanceCallback = RebalanceCallback{};
32 #else
33  const static RebalanceCallback NullRebalanceCallback = RebalanceCallback{};
34 #endif
35 
39  using OffsetCommitCallback = std::function<void(const TopicPartitionOffsets& topicPartitionOffsets, const Error& error)>;
40 
44 #if COMPILER_SUPPORTS_CPP_17
45  const inline OffsetCommitCallback NullOffsetCommitCallback = OffsetCommitCallback{};
46 #else
47  const static OffsetCommitCallback NullOffsetCommitCallback = OffsetCommitCallback{};
48 #endif
49 
54  {
55  public:
56  explicit ConsumerGroupMetadata(rd_kafka_consumer_group_metadata_t* p): _rkConsumerGroupMetadata(p) {}
57 
58  const rd_kafka_consumer_group_metadata_t* rawHandle() const { return _rkConsumerGroupMetadata.get(); }
59 
60  private:
61  rd_kafka_consumer_group_metadata_unique_ptr _rkConsumerGroupMetadata;
62  };
63 
64 } } } // end of KAFKA_API::clients::consumer
65 
A metadata struct containing the consumer group information.
Definition: ConsumerCommon.h:54