Class: KafkaSyrup::Protocol::ProduceResponse::Topic

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



28
29
30
# File 'lib/kafka_syrup/protocol/produce_response.rb', line 28

def name
  @name
end

#partitionsObject

Returns the value of attribute partitions

Returns:

  • (Object)

    the current value of partitions



28
29
30
# File 'lib/kafka_syrup/protocol/produce_response.rb', line 28

def partitions
  @partitions
end

Class Method Details

.decode(io) ⇒ Object



42
43
44
45
46
47
# File 'lib/kafka_syrup/protocol/produce_response.rb', line 42

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

Instance Method Details

#add_partition(id, code, offset) ⇒ Object



29
30
31
32
33
# File 'lib/kafka_syrup/protocol/produce_response.rb', line 29

def add_partition(id, code, offset)
  partition = Partition.new(id, code, offset)
  partitions << partition
  partition
end

#encodeObject



35
36
37
38
39
40
# File 'lib/kafka_syrup/protocol/produce_response.rb', line 35

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