mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-28 08:03:38 +00:00
Allow setting default topic config
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
#include "consumer.h"
|
||||
|
||||
using std::string;
|
||||
using std::move;
|
||||
|
||||
using boost::optional;
|
||||
|
||||
using std::chrono::milliseconds;
|
||||
|
||||
@@ -135,6 +138,10 @@ void Configuration::set_socket_callback(SocketCallback callback) {
|
||||
rd_kafka_conf_set_socket_cb(handle_.get(), &socket_callback_proxy);
|
||||
}
|
||||
|
||||
void Configuration::set_default_topic_configuration(optional<TopicConfiguration> config) {
|
||||
default_topic_config_ = move(config);
|
||||
}
|
||||
|
||||
rd_kafka_conf_t* Configuration::get_handle() const {
|
||||
return handle_.get();
|
||||
}
|
||||
@@ -167,6 +174,14 @@ const Configuration::SocketCallback& Configuration::get_socket_callback() const
|
||||
return socket_callback_;
|
||||
}
|
||||
|
||||
const optional<TopicConfiguration>& Configuration::get_default_topic_configuration() const {
|
||||
return default_topic_config_;
|
||||
}
|
||||
|
||||
optional<TopicConfiguration>& Configuration::get_default_topic_configuration() {
|
||||
return default_topic_config_;
|
||||
}
|
||||
|
||||
Configuration::HandlePtr Configuration::make_handle(rd_kafka_conf_t* ptr) {
|
||||
return HandlePtr(ptr, &rd_kafka_conf_destroy, &rd_kafka_conf_dup);
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ const milliseconds KafkaHandleBase::DEFAULT_TIMEOUT{1000};
|
||||
|
||||
KafkaHandleBase::KafkaHandleBase(Configuration config)
|
||||
: handle_(nullptr, nullptr), timeout_ms_(DEFAULT_TIMEOUT), config_(move(config)) {
|
||||
|
||||
}
|
||||
|
||||
KafkaHandleBase::KafkaHandleBase(rd_kafka_t* handle)
|
||||
: handle_(handle, &rd_kafka_destroy), timeout_ms_(DEFAULT_TIMEOUT) {
|
||||
|
||||
auto& maybe_config = config_.get_default_topic_configuration();
|
||||
if (maybe_config) {
|
||||
maybe_config->set_as_opaque();
|
||||
auto conf_handle = rd_kafka_topic_conf_dup(maybe_config->get_handle());
|
||||
rd_kafka_conf_set_default_topic_conf(config_.get_handle(), conf_handle);
|
||||
}
|
||||
}
|
||||
|
||||
void KafkaHandleBase::pause_partitions(const TopicPartitionList& topic_partitions) {
|
||||
|
||||
Reference in New Issue
Block a user