Module: Infield::Heartbeat::Runner

Defined in:
lib/infield/heartbeat.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.threadObject (readonly)

Returns the value of attribute thread.



7
8
9
# File 'lib/infield/heartbeat.rb', line 7

def thread
  @thread
end

Class Method Details

.run(interval: 60) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/infield/heartbeat.rb', line 9

def run(interval: 60)
  @thread = Thread.new do
    loop do
      if DeprecationWarning::Runner.thread&.alive?
        send_heartbeat
      else
        stop
        break
      end
      sleep(interval)
    end
  end
end

.stopObject



23
24
25
# File 'lib/infield/heartbeat.rb', line 23

def stop
  @thread&.kill
end