Add Message class

This commit is contained in:
Matias Fontanini
2016-05-17 19:25:49 -07:00
parent 5848bccdb8
commit 61253e4f42
3 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
#ifndef CPPKAFKA_MESSAGE_H
#define CPPKAFKA_MESSAGE_H
#include <memory>
#include <cstdint>
#include <librdkafka/rdkafka.h>
#include "buffer.h"
#include "topic.h"
namespace cppkafka {
class Message {
public:
Message(rd_kafka_message_t* handle);
bool has_error() const;
rd_kafka_resp_err_t get_error() const;
std::string get_topic() const;
int get_partition() const;
const Buffer& get_payload() const;
const Buffer& get_key() const;
int64_t get_offset() const;
void* private_data();
rd_kafka_message_t* get_handle() const;
private:
using HandlePtr = std::unique_ptr<rd_kafka_message_t, decltype(&rd_kafka_message_destroy)>;
HandlePtr handle_;
Buffer payload_;
Buffer key_;
};
} // cppkafka
#endif // CPPKAFKA_MESSAGE_H