Sha256: 75a81d73c1f7f4f5fe7c2bc93b2ac0db1985a9cc9ade5528ee6a325859c649a3

Contents?: true

Size: 1022 Bytes

Versions: 30

Compression:

Stored size: 1022 Bytes

Contents

require "kafka/protocol/consumer_group_protocol"

module Kafka
  module Protocol
    class JoinGroupRequest
      PROTOCOL_TYPE = "consumer"

      def initialize(group_id:, session_timeout:, member_id:, topics: [])
        @group_id = group_id
        @session_timeout = session_timeout * 1000 # Kafka wants ms.
        @member_id = member_id || ""
        @protocol_type = PROTOCOL_TYPE
        @group_protocols = {
          "standard" => ConsumerGroupProtocol.new(topics: ["test-messages"]),
        }
      end

      def api_key
        11
      end

      def response_class
        JoinGroupResponse
      end

      def encode(encoder)
        encoder.write_string(@group_id)
        encoder.write_int32(@session_timeout)
        encoder.write_string(@member_id)
        encoder.write_string(@protocol_type)

        encoder.write_array(@group_protocols) do |name, metadata|
          encoder.write_string(name)
          encoder.write_bytes(Encoder.encode_with(metadata))
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
ruby-kafka-0.4.0.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.18.beta2 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.18.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.17 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.16 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.16.beta2 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.16.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.15 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.15.beta3 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.15.beta2 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.15.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.14 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.13.beta4 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.13.beta3 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.13.beta2 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.13.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.12 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.11 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.10 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.3.9 lib/kafka/protocol/join_group_request.rb