mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-07 22:13:29 +00:00
Add more producer stuff
This commit is contained in:
@@ -17,27 +17,26 @@ KafkaHandleBase::KafkaHandleBase(rd_kafka_t* handle)
|
||||
|
||||
}
|
||||
|
||||
void KafkaHandleBase::set_handle(rd_kafka_t* handle) {
|
||||
handle_ = HandlePtr(handle, &rd_kafka_destroy);
|
||||
}
|
||||
|
||||
rd_kafka_t* KafkaHandleBase::get_handle() {
|
||||
return handle_.get();
|
||||
}
|
||||
|
||||
Topic KafkaHandleBase::get_topic(const string& name) {
|
||||
rd_kafka_topic_t* topic = rd_kafka_topic_new(handle_.get(), name.data(), nullptr);
|
||||
if (!topic) {
|
||||
throw Exception("Failed to create topic handle");
|
||||
}
|
||||
return Topic(topic);
|
||||
return get_topic(name, nullptr);
|
||||
}
|
||||
|
||||
Topic KafkaHandleBase::get_topic(const string& name, const TopicConfiguration& config) {
|
||||
rd_kafka_topic_t* topic = rd_kafka_topic_new(handle_.get(), name.data(),
|
||||
config.get_handle());
|
||||
Topic KafkaHandleBase::get_topic(const string& name, TopicConfiguration topicConfig) {
|
||||
return get_topic(name, topicConfig.get_handle());
|
||||
}
|
||||
|
||||
void KafkaHandleBase::set_handle(rd_kafka_t* handle) {
|
||||
handle_ = HandlePtr(handle, &rd_kafka_destroy);
|
||||
}
|
||||
|
||||
Topic KafkaHandleBase::get_topic(const string& name, rd_kafka_topic_conf_t* conf) {
|
||||
rd_kafka_topic_t* topic = rd_kafka_topic_new(get_handle(), name.data(), conf);
|
||||
if (!topic) {
|
||||
throw Exception("Failed to create topic handle");
|
||||
throw HandleException(rd_kafka_errno2err(errno));
|
||||
}
|
||||
return Topic(topic);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user