Class: Plutonium::Wizard::SweepJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Plutonium::Wizard::SweepJob
- Defined in:
- lib/plutonium/wizard/sweep_job.rb
Overview
The abandonment sweep (§8.1). Reaps idle wizard sessions whose expires_at
has passed (status in_progress or completing — the latter catches a
finalize that crashed mid-flight, §6.2). For each row it builds a Runner
and calls cancel, which runs the wizard's cleanup — each step's per-step
on_rollback (additive side-effect cleanup, if any) then the engine's
always-on destroy of every tracked record, in reverse order — and then
deletes the row.
This is load-bearing for save-as-you-go wizards: for +execute+-only
wizards an unscheduled sweep merely leaves stale session rows (harmless), but
for on_submit wizards the sweep is the only thing that cleans up abandoned
partial domain records. Hosts must schedule it (a periodic job / rake task).
The job is idempotent and safe to re-run: a row already cleared is skipped,
and an unconstantizable wizard class is skipped while the row is still reaped.
completed rows are never touched (the sweepable scope excludes them).
Instance Method Summary collapse
Instance Method Details
#perform(now: Time.current) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/plutonium/wizard/sweep_job.rb', line 22 def perform(now: Time.current) store = Store::ActiveRecord.new Session.sweepable(now).find_each do |row| sweep_row(row, store, now) end end |