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