Class: Kafka::Protocol::ProduceResponse

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

Defined Under Namespace

Classes: PartitionInfo, TopicInfo

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topics: []) ⇒ ProduceResponse

Returns a new instance of ProduceResponse.


25
26
27
# File 'lib/kafka/protocol/produce_response.rb', line 25

def initialize(topics: [])
  @topics = topics
end

Instance Attribute Details

#topicsObject (readonly)

Returns the value of attribute topics


23
24
25
# File 'lib/kafka/protocol/produce_response.rb', line 23

def topics
  @topics
end

Class Method Details

.decode(decoder) ⇒ Object


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/kafka/protocol/produce_response.rb', line 37

def self.decode(decoder)
  topics = decoder.array do
    topic = decoder.string

    partitions = decoder.array do
      PartitionInfo.new(
        partition: decoder.int32,
        error_code: decoder.int16,
        offset: decoder.int64,
      )
    end

    TopicInfo.new(topic: topic, partitions: partitions)
  end

  new(topics: topics)
end

Instance Method Details

#each_partitionObject


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

def each_partition
  @topics.each do |topic_info|
    topic_info.partitions.each do |partition_info|
      yield topic_info, partition_info
    end
  end
end