Class: NeetoMonitorRuby::HeartbeatRunnerJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/neeto_monitor_ruby/heartbeat_runner_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(heartbeat_name, schedule) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/neeto_monitor_ruby/heartbeat_runner_job.rb', line 10

def perform(heartbeat_name, schedule)
  NeetoMonitorRuby::Monitor.new(heartbeat_name).ping

  fugit = Fugit.do_parse_cronish(schedule)
  next_time_string = fugit.next_time(Time.now).to_s
  next_time = Time.parse(next_time_string)

  NeetoMonitorRuby::HeartbeatRunnerJob.set(wait_until: next_time).perform_later(heartbeat_name, schedule)
rescue Date::Error, ArgumentError => exception
  NeetoMonitor.logger.error "Error while parsing fugit date time: #{error.message}"
end