Class: Rdkafka::Metadata
- Inherits:
-
Object
- Object
- Rdkafka::Metadata
- Defined in:
- lib/rdkafka/metadata.rb
Defined Under Namespace
Classes: BrokerMetadata, CustomFFIStruct, Metadata, PartitionMetadata, TopicMetadata
Instance Attribute Summary collapse
-
#brokers ⇒ Object
readonly
Returns the value of attribute brokers.
-
#topics ⇒ Object
readonly
Returns the value of attribute topics.
Instance Method Summary collapse
-
#initialize(native_client, topic_name = nil) ⇒ Metadata
constructor
A new instance of Metadata.
Constructor Details
#initialize(native_client, topic_name = nil) ⇒ Metadata
Returns a new instance of Metadata.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rdkafka/metadata.rb', line 5 def initialize(native_client, topic_name = nil) native_topic = if topic_name Rdkafka::Bindings.rd_kafka_topic_new(native_client, topic_name, nil) end ptr = FFI::MemoryPointer.new(:pointer) # If topic_flag is 1, we request info about *all* topics in the cluster. If topic_flag is 0, # we only request info about locally known topics (or a single topic if one is passed in). topic_flag = topic_name.nil? ? 1 : 0 # Retrieve the Metadata result = Rdkafka::Bindings.(native_client, topic_flag, native_topic, ptr, 250) # Error Handling raise Rdkafka::RdkafkaError.new(result) unless result.zero? (ptr.read_pointer) ensure Rdkafka::Bindings.rd_kafka_topic_destroy(native_topic) if topic_name Rdkafka::Bindings.(ptr.read_pointer) end |
Instance Attribute Details
#brokers ⇒ Object (readonly)
Returns the value of attribute brokers.
3 4 5 |
# File 'lib/rdkafka/metadata.rb', line 3 def brokers @brokers end |
#topics ⇒ Object (readonly)
Returns the value of attribute topics.
3 4 5 |
# File 'lib/rdkafka/metadata.rb', line 3 def topics @topics end |