Class: Textus::Surface::Watcher
- Inherits:
-
Object
- Object
- Textus::Surface::Watcher
- Defined in:
- lib/textus/surface/watcher.rb
Instance Method Summary collapse
-
#initialize(container:) ⇒ Watcher
constructor
A new instance of Watcher.
- #run(poll: nil) ⇒ Object
- #tick ⇒ Object
Constructor Details
#initialize(container:) ⇒ Watcher
Returns a new instance of Watcher.
8 9 10 |
# File 'lib/textus/surface/watcher.rb', line 8 def initialize(container:) @container = container end |
Instance Method Details
#run(poll: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/textus/surface/watcher.rb', line 23 def run(poll: nil) interval = poll || @container.manifest.data.worker_config[:poll] lock = Textus::Port::WatcherLock.new(@container.root) lock.acquire begin loop do tick sleep(interval) end ensure lock.release end end |
#tick ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/textus/surface/watcher.rb', line 12 def tick queue = Textus::Store::Jobs::Queue.new(store: @container.job_store) Textus::Store::Jobs::Planner.seed( container: @container, queue: queue, role: Textus::Value::Role::AUTOMATION, ) queue.reclaim(now: Textus::Port::Clock.new.now) Textus::Store::Jobs::Worker.for(container: @container, queue: queue).drain end |