Class: Rdkafka::Producer::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/rdkafka_patch/0_12_0.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



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

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