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


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

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


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

def throttle_time_ms
  @throttle_time_ms
end

#topicsObject (readonly)

Returns the value of attribute topics


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

def topics
  @topics
end

Class Method Details

.decode(decoder) ⇒ Object


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

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


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

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