Class: Kafka::FFI::TopicMetadata

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/kafka/ffi/topic_metadata.rb

Instance Method Summary collapse

Instance Method Details

#errornil, Kafka::ResponseError

Returns any Broker reported errors.

Returns:

  • (nil)

    Broker reported no errors for the topic

  • (Kafka::ResponseError)

    Error reported by Broker



24
25
26
27
28
# File 'lib/kafka/ffi/topic_metadata.rb', line 24

def error
  if self[:err] != :ok
    return ::Kafka::ResponseError.new(self[:err])
  end
end

#partitionsArray<PartitionMetadata>

Returns the set of PartitionMetadata for the Topic

Returns:



34
35
36
37
38
39
40
# File 'lib/kafka/ffi/topic_metadata.rb', line 34

def partitions
  ptr = self[:partitions]

  self[:partition_cnt].times.map do |i|
    PartitionMetadata.new(ptr + (i * PartitionMetadata.size))
  end
end

#topicString Also known as: name

Returns the name of the topic

Returns:

  • (String)

    Name of the topic



15
16
17
# File 'lib/kafka/ffi/topic_metadata.rb', line 15

def topic
  self[:topic]
end