Class: Kafka::Heartbeat
- Inherits:
-
Object
- Object
- Kafka::Heartbeat
- Defined in:
- lib/kafka/heartbeat.rb
Instance Method Summary collapse
-
#initialize(group:, interval:, instrumenter:) ⇒ Heartbeat
constructor
A new instance of Heartbeat.
- #trigger ⇒ Object
- #trigger! ⇒ Object
Constructor Details
#initialize(group:, interval:, instrumenter:) ⇒ Heartbeat
Returns a new instance of Heartbeat.
5 6 7 8 9 10 |
# File 'lib/kafka/heartbeat.rb', line 5 def initialize(group:, interval:, instrumenter:) @group = group @interval = interval @last_heartbeat = Time.now @instrumenter = instrumenter end |
Instance Method Details
#trigger ⇒ Object
21 22 23 |
# File 'lib/kafka/heartbeat.rb', line 21 def trigger trigger! if Time.now > @last_heartbeat + @interval end |
#trigger! ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/kafka/heartbeat.rb', line 12 def trigger! @instrumenter.instrument('heartbeat.consumer', group_id: @group.group_id, topic_partitions: @group.assigned_partitions) do @group.heartbeat @last_heartbeat = Time.now end end |