mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-02 11:37:50 +00:00
Add more producer stuff
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef CPPKAFKA_BUFFER_H
|
||||
#define CPPKAFKA_BUFFER_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
class Buffer {
|
||||
@@ -8,7 +10,6 @@ public:
|
||||
using DataType = unsigned char;
|
||||
|
||||
Buffer();
|
||||
Buffer(const std::string& data);
|
||||
Buffer(const DataType* data, size_t size);
|
||||
|
||||
Buffer(const Buffer&) = delete;
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
|
||||
rd_kafka_t* get_handle();
|
||||
Topic get_topic(const std::string& name);
|
||||
Topic get_topic(const std::string& name, const TopicConfiguration& config);
|
||||
Topic get_topic(const std::string& name, TopicConfiguration config);
|
||||
protected:
|
||||
KafkaHandleBase();
|
||||
KafkaHandleBase(rd_kafka_t* handle);
|
||||
@@ -25,6 +25,8 @@ protected:
|
||||
private:
|
||||
using HandlePtr = std::unique_ptr<rd_kafka_t, decltype(&rd_kafka_destroy)>;
|
||||
|
||||
Topic get_topic(const std::string& name, rd_kafka_topic_conf_t* conf);
|
||||
|
||||
HandlePtr handle_;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,11 +10,20 @@ namespace cppkafka {
|
||||
class Topic;
|
||||
class Buffer;
|
||||
class Partition;
|
||||
class TopicConfiguration;
|
||||
|
||||
class Producer : public KafkaHandleBase {
|
||||
public:
|
||||
enum PayloadPolicy {
|
||||
COPY_PAYLOAD = RD_KAFKA_MSG_F_COPY, ///< Means RD_KAFKA_MSG_F_COPY
|
||||
FREE_PAYLOAD = RD_KAFKA_MSG_F_FREE ///< Means RD_KAFKA_MSG_F_FREE
|
||||
};
|
||||
|
||||
Producer(Configuration config);
|
||||
|
||||
void set_payload_policy(PayloadPolicy policy);
|
||||
PayloadPolicy get_payload_policy() const;
|
||||
|
||||
void produce(const Topic& topic, const Partition& partition, const Buffer& payload);
|
||||
void produce(const Topic& topic, const Partition& partition, const Buffer& payload,
|
||||
const Buffer& key);
|
||||
@@ -22,7 +31,7 @@ public:
|
||||
const Buffer& key, void* user_data);
|
||||
private:
|
||||
Configuration config_;
|
||||
int message_payload_policy_;
|
||||
PayloadPolicy message_payload_policy_;
|
||||
};
|
||||
|
||||
} // cppkafka
|
||||
|
||||
Reference in New Issue
Block a user