Allow setting background event callback on configuration handles

This commit is contained in:
Matias Fontanini
2018-10-27 09:46:13 -07:00
parent 19baa03cea
commit b242e2c35c
2 changed files with 36 additions and 1 deletions

View File

@@ -42,6 +42,7 @@
#include "clonable_ptr.h"
#include "configuration_base.h"
#include "macros.h"
#include "event.h"
namespace cppkafka {
@@ -78,6 +79,7 @@ public:
const std::string& message)>;
using StatsCallback = std::function<void(KafkaHandleBase& handle, const std::string& json)>;
using SocketCallback = std::function<int(int domain, int type, int protocol)>;
using BackgroundEventCallback = std::function<void(KafkaHandleBase& handle, Event)>;
using ConfigurationBase<Configuration>::set;
using ConfigurationBase<Configuration>::get;
@@ -142,6 +144,13 @@ public:
*/
Configuration& set_socket_callback(SocketCallback callback);
#if RD_KAFKA_VERSION >= RD_KAFKA_ADMIN_API_SUPPORT_VERSION
/**
* Sets the background event callback (invokes rd_kafka_conf_set_background_event_cb)
*/
Configuration& set_background_event_callback(BackgroundEventCallback callback);
#endif
/**
* Sets the default topic configuration
*/
@@ -204,6 +213,11 @@ public:
*/
const SocketCallback& get_socket_callback() const;
/**
* Gets the background event callback
*/
const BackgroundEventCallback& get_background_event_callback() const;
/**
* Gets the default topic configuration
*/
@@ -229,6 +243,7 @@ private:
LogCallback log_callback_;
StatsCallback stats_callback_;
SocketCallback socket_callback_;
BackgroundEventCallback background_event_callback_;
};
} // cppkafka