Add pause/resume partitions wrappers

This commit is contained in:
Matias Fontanini
2016-05-22 09:52:42 -07:00
parent 83c1d304c6
commit 58258750df
4 changed files with 23 additions and 9 deletions

View File

@@ -5,7 +5,6 @@
#include <string>
#include <chrono>
#include "kafka_handle_base.h"
#include "topic_partition_list.h"
#include "message.h"
namespace cppkafka {
@@ -35,14 +34,12 @@ public:
TopicPartitionList get_subscription();
TopicPartitionList get_assignment();
Message poll();
private:
static const std::chrono::milliseconds DEFAULT_TIMEOUT;
void commit(const Message& msg, bool async);
void commit(const TopicPartitionList& topic_partitions, bool async);
void check_error(rd_kafka_resp_err_t error);
std::chrono::milliseconds timeout_ms_;
};

View File

@@ -4,6 +4,7 @@
#include <string>
#include <memory>
#include <librdkafka/rdkafka.h>
#include "topic_partition_list.h"
namespace cppkafka {
@@ -18,6 +19,9 @@ public:
KafkaHandleBase& operator=(const KafkaHandleBase&) = delete;
KafkaHandleBase& operator=(KafkaHandleBase&&) = delete;
void pause_partitions(const TopicPartitionList& topic_partitions);
void resume_partitions(const TopicPartitionList& topic_partitions);
rd_kafka_t* get_handle();
Topic get_topic(const std::string& name);
Topic get_topic(const std::string& name, TopicConfiguration config);
@@ -26,6 +30,7 @@ protected:
KafkaHandleBase(rd_kafka_t* handle);
void set_handle(rd_kafka_t* handle);
void check_error(rd_kafka_resp_err_t error);
private:
using HandlePtr = std::unique_ptr<rd_kafka_t, decltype(&rd_kafka_destroy)>;