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: [], throttle_time_ms: 0) ⇒ ProduceResponse

Returns a new instance of ProduceResponse.



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

def initialize(topics: [], throttle_time_ms: 0)
  @topics = topics
  @throttle_time_ms = throttle_time_ms
end

Instance Attribute Details

#throttle_time_msObject (readonly)

Returns the value of attribute throttle_time_ms.



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

def throttle_time_ms
  @throttle_time_ms
end

#topicsObject (readonly)

Returns the value of attribute topics.



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

def topics
  @topics
end

Class Method Details

.decode(decoder) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/kafka/protocol/produce_response.rb', line 39

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,
        timestamp: Time.at(decoder.int64 / 1000.0),
      )
    end

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

  throttle_time_ms = decoder.int32

  new(topics: topics, throttle_time_ms: throttle_time_ms)
end

Instance Method Details

#each_partitionObject



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

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