lib/kafka/round_robin_assignment_strategy.rb
# Assign the topic partitions to the group members.
#
# @param cluster [Kafka::Cluster]
# @param members [Hash<String, Kafka::Protocol::JoinGroupResponse::Metadata>] a hash
#   mapping member ids to metadata
# @param partitions [Array<Kafka::ConsumerGroup::Assignor::Partition>] a list of
#   partitions the consumer group processes
# @return [Hash<String, Array<Kafka::ConsumerGroup::Assignor::Partition>] a hash
#   mapping member ids to partitions.
Assign the topic partitions to the group members.
Assign the topic partitions to the group members .
def call(cluster:, members:, partitions:)
      partitions_per_member = Hash.new {|h, k| h[k] = [] }
      relevant_partitions = valid_sorted_partitions(members, partitions)
      members_ids = members.keys
      iterator = (0...members.size).cycle
      idx = iterator.next
      relevant_partitions.each do |partition|
        topic = partition.topic
        while !members[members_ids[idx]].topics.include?(topic)
          idx = iterator.next
        end
        partitions_per_member[members_ids[idx]] << partition
        idx = iterator.next
      end
      partitions_per_member
    end
def call ( cluster : , members : , partitions : ) partitions_per_member = Hash . new { | h , k | h [ k ] = [ ] } relevant_partitions = valid_sorted_partitions ( members , partitions ) members_ids = members . keys iterator = ( 0 ... members . size ) . cycle idx = iterator . next relevant_partitions . each do | partition | topic = partition . topic while ! members [ members_ids [ idx ] ] . topics . include? ( topic ) idx = iterator . next end partitions_per_member [ members_ids [ idx ] ] << partition idx = iterator . next end partitions_per_member end
Assign the topic partitions to the group members.
Assign the topic partitions to the group members .
a hash mapping member ids to partitions.
a hash mapping member ids to partitions .
Hash<String, Array<Kafka::ConsumerGroup::Assignor::Partition>
cluster
<not_specific>
members
a hash mapping member ids to metadata
a hash mapping member ids to metadata
partitions
a list of partitions the consumer group processes
a list of partitions the consumer group processes
<not_specific>
None