Sha256: cf282dd25419ddce734a2e30296d288ab7318d0984768cc791611149748eaeec

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Kafka
  module Protocol
    # A request to list the available offsets for a set of topics/partitions.
    #
    # ## API Specification
    #
    #     OffsetRequest => ReplicaId [TopicName [Partition Time MaxNumberOfOffsets]]
    #       ReplicaId => int32
    #       TopicName => string
    #       Partition => int32
    #       Time => int64
    #       MaxNumberOfOffsets => int32
    #
    class ListOffsetRequest

      # @param topics [Hash]
      def initialize(topics:)
        @replica_id = REPLICA_ID
        @topics = topics
      end

      def api_key
        LIST_OFFSET_API
      end

      def response_class
        Protocol::ListOffsetResponse
      end

      def encode(encoder)
        encoder.write_int32(@replica_id)

        encoder.write_array(@topics) do |topic, partitions|
          encoder.write_string(topic)

          encoder.write_array(partitions) do |partition|
            encoder.write_int32(partition.fetch(:partition))
            encoder.write_int64(partition.fetch(:time))
            encoder.write_int32(partition.fetch(:max_offsets))
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby-kafka-0.7.0 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.8 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.7.0.beta2 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.7.0.beta1 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.7.0.alpha4 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.7 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.6 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.5 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.4 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.7.0.alpha3 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.7.0.alpha2 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.7.0.alpha1 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.3 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.2 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.1 lib/kafka/protocol/list_offset_request.rb
ruby-kafka-0.6.0 lib/kafka/protocol/list_offset_request.rb