Module: Karafka::Pro::Routing::Features::Swarm::Topic
- Defined in:
 - lib/karafka/pro/routing/features/swarm/topic.rb
 
Overview
Topic swarm API extensions
Instance Method Summary collapse
- 
  
    
      #active?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Should this topic be active.
 - 
  
    
      #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
Returns should this topic be active. In the context of swarm it is only active when swarm routing setup does not limit nodes on which it should operate.
      58 59 60 61 62 63 64  | 
    
      # File 'lib/karafka/pro/routing/features/swarm/topic.rb', line 58 def active? node = Karafka::App.config.swarm.node return super unless node super && swarm.nodes.include?(node.id) end  | 
  
#swarm(nodes: (0...Karafka::App.config.swarm.nodes)) ⇒ Object
Allows defining swarm routing topic settings
      47 48 49  | 
    
      # File 'lib/karafka/pro/routing/features/swarm/topic.rb', line 47 def swarm(nodes: (0...Karafka::App.config.swarm.nodes)) @swarm ||= Config.new(active: true, nodes: nodes) end  | 
  
#swarm? ⇒ true
Returns swarm setup is always true. May not be in use but is active.
      52 53 54  | 
    
      # File 'lib/karafka/pro/routing/features/swarm/topic.rb', line 52 def swarm? swarm.active? end  | 
  
#to_h ⇒ Hash
Returns topic with all its native configuration options plus swarm.
      67 68 69 70 71  | 
    
      # File 'lib/karafka/pro/routing/features/swarm/topic.rb', line 67 def to_h super.merge( swarm: swarm.to_h ).freeze end  |