Class: ProconBypassMan::Scheduler
- Inherits:
-
Object
- Object
- ProconBypassMan::Scheduler
- Defined in:
- lib/procon_bypass_man/scheduler.rb
Defined Under Namespace
Classes: Schedule
Constant Summary collapse
- @@schedules =
{}
Class Method Summary collapse
Class Method Details
.register(schedule:) ⇒ Object
90 91 92 |
# File 'lib/procon_bypass_man/scheduler.rb', line 90 def self.register(schedule: ) schedules[schedule.klass] = schedule end |
.register_schedules ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/procon_bypass_man/scheduler.rb', line 70 def self.register_schedules if ProconBypassMan.config.has_api_server? register( schedule: Schedule.new( klass: ProconBypassMan::SyncDeviceStatsJob, args: [->{ ProconBypassMan::DeviceStatus.current }], interval: 60, ) ) register( schedule: Schedule.new( klass: ProconBypassMan::ReportProconPerformanceMeasurementsJob, args: [->{ ProconBypassMan::Procon::PerformanceMeasurement.pop_measurement_collection }], interval: 60, ) ) end end |
.schedules ⇒ Hash
49 50 51 |
# File 'lib/procon_bypass_man/scheduler.rb', line 49 def self.schedules @@schedules end |
.start! ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/procon_bypass_man/scheduler.rb', line 55 def self.start! register_schedules @@thread = Thread.start do loop do schedules.each do |_key, schedule| if schedule.past_interval? schedule.enqueue end end sleep 10 end end end |