Class: Kafka::RoundRobinAssignmentStrategy
- Inherits:
-
Object
- Object
- Kafka::RoundRobinAssignmentStrategy
- Defined in:
- lib/kafka/round_robin_assignment_strategy.rb
Overview
A consumer group partition assignment strategy that assigns partitions to consumers in a round-robin fashion.
Instance Method Summary collapse
-
#call(cluster:, members:, partitions:) ⇒ Hash<String, Array<Kafka::ConsumerGroup::Assignor::Partition>] a hash mapping member ids to partitions.
Assign the topic partitions to the group members.
- #protocol_name ⇒ Object
Instance Method Details
#call(cluster:, members:, partitions:) ⇒ Hash<String, Array<Kafka::ConsumerGroup::Assignor::Partition>] a hash mapping member ids to partitions.
Assign the topic partitions to the group members.
21 22 23 24 25 26 27 28 29 |
# File 'lib/kafka/round_robin_assignment_strategy.rb', line 21 def call(cluster:, members:, partitions:) member_ids = members.keys partitions_per_member = Hash.new {|h, k| h[k] = [] } partitions.each_with_index do |partition, index| partitions_per_member[member_ids[index % member_ids.count]] << partition end partitions_per_member end |
#protocol_name ⇒ Object
8 9 10 |
# File 'lib/kafka/round_robin_assignment_strategy.rb', line 8 def protocol_name "roundrobin" end |