mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-02 11:37:50 +00:00
Add initial config classes
This commit is contained in:
30
include/cppkafka/configuration.h
Normal file
30
include/cppkafka/configuration.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef CPPKAFKA_CONFIGURATION_H
|
||||
#define CPPKAFKA_CONFIGURATION_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <librdkafka/rdkafka.h>
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
class Configuration {
|
||||
public:
|
||||
Configuration();
|
||||
Configuration(const Configuration& rhs);
|
||||
Configuration(Configuration&& rhs) noexcept = default;
|
||||
Configuration& operator=(const Configuration& rhs);
|
||||
Configuration& operator=(Configuration&& rhs) noexcept = default;
|
||||
|
||||
void set(const std::string& name, const std::string& value);
|
||||
private:
|
||||
using HandlePtr = std::unique_ptr<rd_kafka_conf_t, decltype(&rd_kafka_conf_destroy)>;
|
||||
|
||||
Configuration(rd_kafka_conf_t* ptr);
|
||||
static HandlePtr make_handle(rd_kafka_conf_t* ptr);
|
||||
|
||||
HandlePtr handle_;
|
||||
};
|
||||
|
||||
} // cppkafka
|
||||
|
||||
#endif // CPPKAFKA_CONFIGURATION_H
|
24
include/cppkafka/exceptions.h
Normal file
24
include/cppkafka/exceptions.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef CPPKAFKA_EXCEPTIONS_H
|
||||
#define CPPKAFKA_EXCEPTIONS_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
class KafkaException : public std::exception {
|
||||
|
||||
};
|
||||
|
||||
class KafkaConfigException : public KafkaException {
|
||||
public:
|
||||
KafkaConfigException(const std::string& config_name, const std::string& error);
|
||||
|
||||
const char* what() const noexcept;
|
||||
private:
|
||||
std::string message_;
|
||||
};
|
||||
|
||||
} // cppkafka
|
||||
|
||||
#endif // CPPKAFKA_EXCEPTIONS_H
|
31
include/cppkafka/topic_configuration.h
Normal file
31
include/cppkafka/topic_configuration.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef CPPKAFKA_TOPIC_CONFIGURATION_H
|
||||
#define CPPKAFKA_TOPIC_CONFIGURATION_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <librdkafka/rdkafka.h>
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
class TopicConfiguration {
|
||||
public:
|
||||
TopicConfiguration();
|
||||
TopicConfiguration(const TopicConfiguration& rhs);
|
||||
TopicConfiguration(TopicConfiguration&& rhs) noexcept = default;
|
||||
TopicConfiguration& operator=(const TopicConfiguration& rhs);
|
||||
TopicConfiguration& operator=(TopicConfiguration&& rhs) noexcept = default;
|
||||
|
||||
void set(const std::string& name, const std::string& value);
|
||||
private:
|
||||
using HandlePtr = std::unique_ptr<rd_kafka_topic_conf_t,
|
||||
decltype(&rd_kafka_topic_conf_destroy)>;
|
||||
|
||||
TopicConfiguration(rd_kafka_topic_conf_t* ptr);
|
||||
static HandlePtr make_handle(rd_kafka_topic_conf_t* ptr);
|
||||
|
||||
HandlePtr handle_;
|
||||
};
|
||||
|
||||
} // cppkafka
|
||||
|
||||
#endif // CPPKAFKA_TOPIC_CONFIGURATION_H
|
Reference in New Issue
Block a user