Class: Textus::Jobs::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/jobs/scheduler.rb

Overview

Time-based seeding for the daemon: at each tick, enqueue a re-pull job for every intake key past its source.ttl and a sweep job to GC entries past retention.ttl. Dedup means a job already queued from a prior tick is a no-op. Both are stamped automation (the daemon’s own authority); the sweep handler runs retention as that role.

Instance Method Summary collapse

Constructor Details

#initialize(container:, queue:) ⇒ Scheduler

Returns a new instance of Scheduler.



9
10
11
12
# File 'lib/textus/jobs/scheduler.rb', line 9

def initialize(container:, queue:)
  @container = container
  @queue = queue
end

Instance Method Details

#run_onceObject



14
15
16
17
18
19
# File 'lib/textus/jobs/scheduler.rb', line 14

def run_once
  stale_intake.each do |key|
    @queue.enqueue(job("re-pull", { "key" => key }))
  end
  @queue.enqueue(job("sweep", { "scope" => { "prefix" => nil, "zone" => nil } }))
end