Sha256: 1f00fd798012c59d755d3bf217651e4d8018f55347a456e7cc927299eaea26ce
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
module Legion module Extensions module Scheduler module Runners module Schedule include Legion::Extensions::Helpers::Transport include Legion::Extensions::Helpers::Cache include Legion::Extensions::Helpers::Data include Legion::Extensions::Helpers::Lex def push_refresh(**) Legion::Extensions::Scheduler::Transport::Messages::Refresh.new.publish end def refresh(**) Legion::Cache.set('scheduler_schedule_lock', Legion::Settings[:client][:name], 5) end def schedule_tasks(**) return unless Legion::Cache.get('scheduler_schedule_lock') == Legion::Settings[:client][:name] models_class::Schedule.where(active: 1).each do |row| next unless row.values[:interval].positive? next if (Time.now - row.values[:last_run]) < row.values[:interval] send_task(function_id: row.values[:function_id], **Legion::JSON.load(row.values[:payload])) row.update(last_run: Sequel::CURRENT_TIMESTAMP) end end def send_task(**opts) payload = {} %i[runner_class function_id function debug args].each do |thing| payload[thing] = opts[thing] if opts.key? thing end Legion::Extensions::Scheduler::Transport::Messages::SendTask.new(**payload).publish end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lex-scheduler-0.1.0 | lib/legion/extensions/scheduler/runners/schedule.rb |