Module: Karafka::Pro::Routing::Features::ConsumerGroups::Swarm::Topic
- Defined in:
- lib/karafka/pro/routing/features/consumer_groups/swarm/topic.rb
Overview
Topic swarm API extensions
Instance Method Summary collapse
-
#active? ⇒ Boolean
Should this topic be active.
-
#initialize ⇒ Object
This method sets up the extra instance variable to nil before calling the parent class initializer.
-
#swarm(nodes: (0...Karafka::App.config.swarm.nodes)) ⇒ Object
Allows defining swarm routing topic settings.
-
#swarm? ⇒ true
Swarm setup is always true.
-
#to_h ⇒ Hash
Topic with all its native configuration options plus swarm.
Instance Method Details
#active? ⇒ Boolean
85 86 87 88 89 90 91 |
# File 'lib/karafka/pro/routing/features/consumer_groups/swarm/topic.rb', line 85 def active? node = Karafka::App.config.swarm.node return super unless node super && swarm.nodes.include?(node.id) end |
#initialize ⇒ Object
This method sets up the extra instance variable to nil before calling the parent class initializer. The explicit initialization to nil is included as an optimization for Ruby's object shapes system, which improves memory layout and access performance.
43 44 45 46 |
# File 'lib/karafka/pro/routing/features/consumer_groups/swarm/topic.rb', line 43 def initialize(...) @swarm = nil super end |
#swarm(nodes: (0...Karafka::App.config.swarm.nodes)) ⇒ Object
Allows defining swarm routing topic settings
74 75 76 |
# File 'lib/karafka/pro/routing/features/consumer_groups/swarm/topic.rb', line 74 def swarm(nodes: (0...Karafka::App.config.swarm.nodes)) @swarm ||= Config.new(active: true, nodes: nodes) end |
#swarm? ⇒ true
79 80 81 |
# File 'lib/karafka/pro/routing/features/consumer_groups/swarm/topic.rb', line 79 def swarm? swarm.active? end |
#to_h ⇒ Hash
94 95 96 97 98 |
# File 'lib/karafka/pro/routing/features/consumer_groups/swarm/topic.rb', line 94 def to_h super.merge( swarm: swarm.to_h ).freeze end |