Module: Rdkafka::Helpers::Metadata

Included in:
Admin, Consumer, Producer
Defined in:
lib/rdkafka/helpers/metadata.rb

Overview

Shared #metadata implementation for Admin, Consumer and Producer.

rd_kafka_metadata() is handle-agnostic in librdkafka - it works on any rd_kafka_t (consumer, producer or admin) - so this Ruby-level implementation is identical across all three client types. Includers must provide a private #closed_check(method) that raises their own Closed*Error.

Instance Method Summary collapse

Instance Method Details

#metadata(topic_name = nil, timeout_ms = Defaults::METADATA_TIMEOUT_MS) ⇒ Rdkafka::Metadata

Performs the metadata request using this client

Parameters:

  • topic_name (String, nil) (defaults to: nil)

    metadata about particular topic or all if nil

  • timeout_ms (Integer) (defaults to: Defaults::METADATA_TIMEOUT_MS)

    metadata request timeout

Returns:



17
18
19
20
21
22
23
24
25
26
# File 'lib/rdkafka/helpers/metadata.rb', line 17

def (topic_name = nil, timeout_ms = Defaults::METADATA_TIMEOUT_MS)
  closed_check(__method__)

  @native_kafka.with_inner do |inner|
    # Must stay fully qualified: this module is itself named `Metadata`, so a bare
    # `Metadata.new` here would resolve to `Rdkafka::Helpers::Metadata` (no `.new`) instead
    # of this class.
    Rdkafka::Metadata.new(inner, topic_name, timeout_ms)
  end
end