Class: Kafka::Heartbeat

Inherits:
Object
  • Object
show all
Defined in:
lib/kafka/heartbeat.rb

Instance Method Summary collapse

Constructor Details

#initialize(group:, interval:) ⇒ Heartbeat

Returns a new instance of Heartbeat.


3
4
5
6
7
# File 'lib/kafka/heartbeat.rb', line 3

def initialize(group:, interval:)
  @group = group
  @interval = interval
  @last_heartbeat = Time.now
end

Instance Method Details

#send_if_necessaryObject


9
10
11
12
13
14
# File 'lib/kafka/heartbeat.rb', line 9

def send_if_necessary
  if Time.now > @last_heartbeat + @interval
    @group.heartbeat
    @last_heartbeat = Time.now
  end
end