class Poseidon::TopicMetadata
@api private
Attributes
struct[RW]
Public Class Methods
new(struct=nil)
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 16 def initialize(struct=nil) self.struct = struct end
read(buffer)
click to toggle source
Build a new TopicMetadata
object from its binary representation
@param [ResponseBuffer] buffer @return [TopicMetadata]
# File lib/poseidon/topic_metadata.rb, line 9 def self.read(buffer) tm = TopicMetadata.new tm.struct = Protocol::TopicMetadataStruct.read(buffer) tm end
Public Instance Methods
==(o)
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 33 def ==(o) eql?(o) end
available_partition_count()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 63 def available_partition_count available_partitions.count end
available_partitions()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 57 def available_partitions @available_partitions ||= struct.partitions.select do |partition| partition.error == 0 && partition.leader != -1 end end
eql?(o)
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 41 def eql?(o) struct.eql?(o.struct) end
exists?()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 37 def exists? struct.error == 0 end
leader_available?()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 49 def leader_available? struct.error_class != Errors::LeaderNotAvailable end
name()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 29 def name struct.name end
objects_with_errors()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 45 def objects_with_errors struct.objects_with_errors end
partition_count()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 53 def partition_count @partition_count ||= struct.partitions.count end
partition_leader(partition_id)
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 67 def partition_leader(partition_id) partition = partitions_by_id[partition_id] if partition partition.leader else nil end end
to_s()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 76 def to_s struct.partitions.map { |p| p.inspect }.join("\n") end
write(buffer)
click to toggle source
Write a binary representation of the TopicMetadata
to buffer
@param [RequestBuffer] buffer @return [nil]
# File lib/poseidon/topic_metadata.rb, line 24 def write(buffer) struct.write(buffer) nil end
Private Instance Methods
partitions()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 85 def partitions struct.partitions end
partitions_by_id()
click to toggle source
# File lib/poseidon/topic_metadata.rb, line 81 def partitions_by_id @partitions_by_id ||= Hash[partitions.map { |p| [p.id, p] }] end