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
Initializes the liveness listener.
-
#on_client_events_poll(_event) ⇒ Object
Report from events poll so liveness works during long processing.
-
#on_connection_listener_before_fetch_loop(_event) ⇒ Object
Report liveness before the first fetch loop iteration so the supervisor gets an initial healthy report even if the first consumption takes longer than the report timeout.
-
#on_connection_listener_fetch_loop(_event) ⇒ Object
Report from the fetch loop at the top of each iteration.
Constructor Details
#initialize ⇒ LivenessListener
Initializes the liveness listener
17 18 19 20 |
# File 'lib/karafka/swarm/liveness_listener.rb', line 17 def initialize @last_checked_at = 0 @mutex = Mutex.new end |
Instance Method Details
#on_client_events_poll(_event) ⇒ Object
Report from events poll so liveness works during long processing. This event fires periodically during wait even when the listener is blocked on consumer jobs, preventing the supervisor from killing the node.
39 40 41 |
# File 'lib/karafka/swarm/liveness_listener.rb', line 39 def on_client_events_poll(_event) report_liveness end |
#on_connection_listener_before_fetch_loop(_event) ⇒ Object
Report liveness before the first fetch loop iteration so the supervisor gets an initial healthy report even if the first consumption takes longer than the report timeout.
25 26 27 |
# File 'lib/karafka/swarm/liveness_listener.rb', line 25 def on_connection_listener_before_fetch_loop(_event) report_liveness end |
#on_connection_listener_fetch_loop(_event) ⇒ Object
Report from the fetch loop at the top of each iteration
31 32 33 |
# File 'lib/karafka/swarm/liveness_listener.rb', line 31 def on_connection_listener_fetch_loop(_event) report_liveness end |