Sha256: 913fc604414999cb0446e5d69c6d884518619a2560c856aef1df5446889b571d

Contents?: true

Size: 1.01 KB

Versions: 26

Compression:

Stored size: 1.01 KB

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

26 entries across 26 versions & 1 rubygems

Version Path
ruby-kafka-0.6.0.beta4 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.6.0.beta3 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.6.0.beta2 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.6.0.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.5 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.4 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.4.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.3 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.2 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.2.beta3 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.2.beta2 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.2.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.1.beta2 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.1.beta1 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.4.4 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.0 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.0.beta6 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.0.beta5 lib/kafka/protocol/join_group_request.rb
ruby-kafka-0.5.0.beta4 lib/kafka/protocol/join_group_request.rb