Class: Broadcaster::Watchdog

Inherits:
Object
  • Object
show all
Defined in:
lib/broadcaster/watchdog.rb

Constant Summary collapse

CHANNEL =
'__watchdog__'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(broadcaster, interval:, timeout:, logger:) ⇒ Watchdog

Returns a new instance of Watchdog.



6
7
8
9
10
11
# File 'lib/broadcaster/watchdog.rb', line 6

def initialize(broadcaster, interval:, timeout:, logger:)
  @broadcaster = broadcaster
  @interval = interval
  @timeout = timeout
  @logger = logger
end

Instance Method Details

#startObject



13
14
15
16
17
18
19
20
# File 'lib/broadcaster/watchdog.rb', line 13

def start
  @thread = Thread.new do
    loop do
      sleep interval
      check
    end
  end
end

#stopObject



22
23
24
# File 'lib/broadcaster/watchdog.rb', line 22

def stop
  thread.kill
end