Class: Rdkafka::Producer

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/rdkafka_patch/0_16_0.rb,
lib/fluent/plugin/rdkafka_patch/0_14_0.rb,
lib/fluent/plugin/rdkafka_patch/0_12_0.rb,
lib/fluent/plugin/rdkafka_patch/0_11_0.rb,
lib/fluent/plugin/out_rdkafka.rb

Instance Method Summary collapse

Instance Method Details

#close(timeout = nil) ⇒ Object

return false if producer is forcefully closed, otherwise return true



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fluent/plugin/rdkafka_patch/0_11_0.rb', line 3

def close(timeout = nil)
  return true if closed?
  ObjectSpace.undefine_finalizer(self)

  @native_kafka.close(timeout) do
    # We need to remove the topics references objects before we destroy the producer,
    # otherwise they would leak out
    @topics_refs_map.each_value do |refs|
      refs.each_value do |ref|
        Rdkafka::Bindings.rd_kafka_topic_destroy(ref)
      end
    end
  end

  @topics_refs_map.clear
end