Class: KafkaSyrup::Protocol::MetadataResponse::Topic

Inherits:
Struct
  • Object
show all
Defined in:
lib/kafka_syrup/protocol/metadata_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



58
59
60
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 58

def code
  @code
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



58
59
60
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 58

def name
  @name
end

#partitionsObject

Returns the value of attribute partitions

Returns:

  • (Object)

    the current value of partitions



58
59
60
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 58

def partitions
  @partitions
end

Class Method Details

.decode(io) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 73

def self.decode(io)
  new(
    E.read_int16(io),                            # Error Code
    E.read_string(io),                           # Name
    E.read_array(io, &Partition.method(:decode)) # Partitions
  )
end

Instance Method Details

#add_partition(p_code, id, leader, replicas, isr) ⇒ Object



59
60
61
62
63
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 59

def add_partition(p_code, id, leader, replicas, isr)
  partition = Partition.new(p_code, id, leader, replicas, isr)
  partitions << partition
  partition
end

#encodeObject



65
66
67
68
69
70
71
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 65

def encode
  [
    E.write_int16(code),
    E.write_string(name),
    E.write_array(partitions)
  ].join
end