Class: Karafka::Swarm::LivenessListener
- Inherits:
 - 
      Object
      
        
- Object
 - Karafka::Swarm::LivenessListener
 
 
- Includes:
 - Core::Helpers::Time
 
- Defined in:
 - lib/karafka/swarm/liveness_listener.rb
 
Overview
Simple listener for swarm nodes that:
- reports once in a while to make sure that supervisor is aware we do not hang
- makes sure we did not become an orphan and if so, exits
  Direct Known Subclasses
Instance Method Summary collapse
- 
  
    
      #initialize  ⇒ LivenessListener 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of LivenessListener.
 - 
  
    
      #on_statistics_emitted(_event)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Since there may be many statistics emitted from multiple listeners, we do not want to write statuses that often.
 
Constructor Details
#initialize ⇒ LivenessListener
Returns a new instance of LivenessListener.
      16 17 18 19  | 
    
      # File 'lib/karafka/swarm/liveness_listener.rb', line 16 def initialize @last_checked_at = 0 @mutex = Mutex.new end  | 
  
Instance Method Details
#on_statistics_emitted(_event) ⇒ Object
Since there may be many statistics emitted from multiple listeners, we do not want to write statuses that often. Instead we do it only once in a while which should be enough
While this may provide a small lag in the orphaned detection, it does not really matter as it will be picked up fast enough.
      27 28 29 30 31 32 33  | 
    
      # File 'lib/karafka/swarm/liveness_listener.rb', line 27 def on_statistics_emitted(_event) periodically do Kernel.exit!(orphaned_exit_code) if node.orphaned? node.healthy end end  |