Sha256: 69dcc25b6458713bb693e77f92706ffaa44c05824d5b297a337d61ef9042be56

Contents?: true

Size: 1.22 KB

Versions: 47

Compression:

Stored size: 1.22 KB

Contents

module Kafka
  module Protocol
    class ProduceResponse
      class TopicInfo
        attr_reader :topic, :partitions

        def initialize(topic:, partitions:)
          @topic = topic
          @partitions = partitions
        end
      end

      class PartitionInfo
        attr_reader :partition, :error_code, :offset

        def initialize(partition:, error_code:, offset:)
          @partition = partition
          @error_code = error_code
          @offset = offset
        end
      end

      attr_reader :topics

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

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

      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
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
ruby-kafka-0.4.4 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.4.3 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.4.2 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.4.1 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.4.0 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.4.0.beta1 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.18.beta2 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.18.beta1 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.17 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.16 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.16.beta2 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.16.beta1 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.15 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.15.beta3 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.15.beta2 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.15.beta1 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.14 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.13.beta4 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.13.beta3 lib/kafka/protocol/produce_response.rb
ruby-kafka-0.3.13.beta2 lib/kafka/protocol/produce_response.rb