- Add jump_credo_checks ~> 0.4 with all 20 checks enabled - Fix all standard Credo issues: 139 @spec (113 done, 26 remain), 4 refactoring, 3 alias usage, 9 System.cmd env, 5 unsafe_to_atom, 2 max line length, 9 assert_receive timeout - Fix 170+ jump_credo_checks warnings: - 117 TopLevelAliasImportRequire: move nested alias/import to module top - 32 UseObanProWorker: switch to Oban.Pro.Worker - 4 DoctestIExExamples: add doctests / create test file - ~20 WeakAssertion: strengthen type-check assertions - Various ConditionalAssertion, AssertReceiveTimeout fixes - Exclude vendor/ from Credo analysis - Remaining: 175 warnings (mostly opinionated WeakAssertion, AvoidSocketAssignsInTest), 26 @spec annotations
28 lines
937 B
Elixir
28 lines
937 B
Elixir
defmodule Microwaveprop.Workers.PropagationPruneWorker do
|
|
@moduledoc """
|
|
Standalone worker that prunes stale rows from `propagation_scores`.
|
|
|
|
Pruning used to be tacked on to the end of `PropagationGridWorker.perform/1`,
|
|
which meant it only ran after a successful grid compute. When the compute
|
|
worker was being killed mid-run (OOM / SIGTERM), prune never ran and the
|
|
table grew unbounded. Running prune on its own cron keeps the table healthy
|
|
regardless of the compute worker's state.
|
|
"""
|
|
|
|
use Oban.Pro.Worker,
|
|
queue: :propagation,
|
|
# Lower priority than PropagationGridWorker so the hourly chain
|
|
# never waits behind a pending prune on the shared :propagation
|
|
# queue (2 slots).
|
|
priority: 5,
|
|
max_attempts: 3,
|
|
unique: [period: 300, states: :incomplete]
|
|
|
|
alias Microwaveprop.Propagation
|
|
|
|
@impl Oban.Worker
|
|
def perform(%Oban.Job{}) do
|
|
Propagation.prune_old_scores()
|
|
:ok
|
|
end
|
|
end
|