Class: Karafka::Web::Tracking::Consumers::Listeners::Connections
- Defined in:
- lib/karafka/web/tracking/consumers/listeners/connections.rb
Overview
Listener for listening on connections related events like polling, etc
Instance Method Summary collapse
-
#on_connection_listener_after_fetch_loop(event) ⇒ Object
When fetch loop is done it means this subscription group is no longer active and we should stop reporting.
-
#on_connection_listener_before_fetch_loop(event) ⇒ Object
Initializes the subscription group with defaults so it is always available.
-
#on_connection_listener_fetch_loop_received(event) ⇒ Object
Tracks the moment a poll happened on a given subscription group.
Instance Method Details
#on_connection_listener_after_fetch_loop(event) ⇒ Object
When fetch loop is done it means this subscription group is no longer active and we should stop reporting. The listener was stopped.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/karafka/web/tracking/consumers/listeners/connections.rb', line 25 def on_connection_listener_after_fetch_loop(event) subscription_group = event[:subscription_group] sg_id = subscription_group.id cg_id = subscription_group.consumer_group.id track do |sampler| sampler.consumer_groups[cg_id][:subscription_groups].delete(sg_id) sampler.subscription_groups.delete(sg_id) end end |
#on_connection_listener_before_fetch_loop(event) ⇒ Object
Initializes the subscription group with defaults so it is always available
12 13 14 15 16 17 18 19 |
# File 'lib/karafka/web/tracking/consumers/listeners/connections.rb', line 12 def on_connection_listener_before_fetch_loop(event) sg_id = event[:subscription_group].id track do |sampler| # This will initialize the hash upon first request sampler.subscription_groups[sg_id] end end |
#on_connection_listener_fetch_loop_received(event) ⇒ Object
Tracks the moment a poll happened on a given subscription group
39 40 41 42 43 44 45 |
# File 'lib/karafka/web/tracking/consumers/listeners/connections.rb', line 39 def on_connection_listener_fetch_loop_received(event) sg_id = event[:subscription_group].id track do |sampler| sampler.subscription_groups[sg_id][:polled_at] = monotonic_now end end |