Module: OMQ::Engine::Maintenance
- Defined in:
- lib/omq/engine/maintenance.rb
Overview
Spawns a periodic maintenance task for the parent mechanism.
The mechanism declares maintenance needs via #maintenance, which returns { interval:, task: } or nil.
Class Method Summary collapse
Class Method Details
.start(parent_task, mechanism) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/omq/engine/maintenance.rb', line 16 def self.start(parent_task, mechanism) return unless mechanism.respond_to?(:maintenance) spec = mechanism.maintenance or return spec interval = spec[:interval] callable = spec[:task] parent_task.async(transient: true, annotation: "mechanism maintenance") do Async::Loop.quantized(interval: interval) do callable.call end rescue Async::Stop # clean shutdown end end |