Class: Rdkafka::Producer::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/out_rdkafka2.rb

Overview

This is required for ‘rdkafka` version >= 0.12.0 Overriding the close method in order to provide a time limit for when it should be forcibly closed

Instance Method Summary collapse

Instance Method Details

#close(timeout = nil) ⇒ Object

return false if producer is forcefully closed, otherwise return true



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fluent/plugin/out_rdkafka2.rb', line 12

def close(timeout=nil)
  return unless @native

  # Indicate to polling thread that we're closing
  @polling_thread[:closing] = true
  # Wait for the polling thread to finish up
  thread = @polling_thread.join(timeout)

  Rdkafka::Bindings.rd_kafka_destroy(@native)

  @native = nil

  return !thread.nil?
end