Sha256: b14d0381c94c08eb096b45d01304300ba00a73cfb4ef7fe079dfc2c705f5b798

Contents?: true

Size: 977 Bytes

Versions: 49

Compression:

Stored size: 977 Bytes

Contents

# frozen_string_literal: true

module Kafka
  module Protocol
    class MemberAssignment
      attr_reader :topics

      def initialize(version: 0, topics: {}, user_data: nil)
        @version = version
        @topics = topics
        @user_data = user_data
      end

      def assign(topic, partitions)
        @topics[topic] ||= []
        @topics[topic].concat(partitions)
      end

      def encode(encoder)
        encoder.write_int16(@version)

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

          encoder.write_array(partitions) do |partition|
            encoder.write_int32(partition)
          end
        end

        encoder.write_bytes(@user_data)
      end

      def self.decode(decoder)
        new(
          version: decoder.int16,
          topics: Hash[decoder.array { [decoder.string, decoder.array { decoder.int32 }] }],
          user_data: decoder.bytes,
        )
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
ruby-kafka-1.5.0 lib/kafka/protocol/member_assignment.rb
ruby-kafka-aws-iam-1.4.5 lib/kafka/protocol/member_assignment.rb
ruby-kafka-aws-iam-1.4.4 lib/kafka/protocol/member_assignment.rb
ruby-kafka-aws-iam-1.4.3 lib/kafka/protocol/member_assignment.rb
ruby-kafka-aws-iam-1.4.2 lib/kafka/protocol/member_assignment.rb
ruby-kafka-aws-iam-1.4.1 lib/kafka/protocol/member_assignment.rb
ruby-kafka-1.4.0 lib/kafka/protocol/member_assignment.rb
ruby-kafka-temp-fork-0.0.2 lib/kafka/protocol/member_assignment.rb
ruby-kafka-temp-fork-0.0.1 lib/kafka/protocol/member_assignment.rb
ruby-kafka-1.3.0 lib/kafka/protocol/member_assignment.rb
ruby-kafka-1.2.0 lib/kafka/protocol/member_assignment.rb
ruby-kafka-1.1.0 lib/kafka/protocol/member_assignment.rb
ruby-kafka-1.1.0.beta1 lib/kafka/protocol/member_assignment.rb
ruby-kafka-1.0.0 lib/kafka/protocol/member_assignment.rb
ruby-kafka-0.7.10 lib/kafka/protocol/member_assignment.rb
ruby-kafka-0.7.9 lib/kafka/protocol/member_assignment.rb
ruby-kafka-0.7.8 lib/kafka/protocol/member_assignment.rb
ruby-kafka-0.7.7 lib/kafka/protocol/member_assignment.rb
ruby-kafka-custom-0.7.7.26 lib/kafka/protocol/member_assignment.rb
ruby-kafka-0.7.6 lib/kafka/protocol/member_assignment.rb