lib/rdkafka/config.rb in rdkafka-0.8.0 vs lib/rdkafka/config.rb in rdkafka-0.8.1
- old
+ new
@@ -135,14 +135,27 @@
# Create opaque
opaque = Opaque.new
# Create Kafka config
config = native_config(opaque)
# Set callback to receive delivery reports on config
- Rdkafka::Bindings.rd_kafka_conf_set_dr_msg_cb(config, Rdkafka::Bindings::DeliveryCallback)
+ Rdkafka::Bindings.rd_kafka_conf_set_dr_msg_cb(config, Rdkafka::Callbacks::DeliveryCallbackFunction)
# Return producer with Kafka client
Rdkafka::Producer.new(native_kafka(config, :rd_kafka_producer)).tap do |producer|
opaque.producer = producer
end
+ end
+
+ # Create an admin instance with this configuration.
+ #
+ # @raise [ConfigError] When the configuration contains invalid options
+ # @raise [ClientCreationError] When the native client cannot be created
+ #
+ # @return [Admin] The created admin instance
+ def admin
+ opaque = Opaque.new
+ config = native_config(opaque)
+ Rdkafka::Bindings.rd_kafka_conf_set_background_event_cb(config, Rdkafka::Callbacks::BackgroundEventCallbackFunction)
+ Rdkafka::Admin.new(native_kafka(config, :rd_kafka_producer))
end
# Error that is returned by the underlying rdkafka error if an invalid configuration option is present.
class ConfigError < RuntimeError; end