mule/plugins/pruner
The Pruner plugin: delete terminal jobs older than max_age on a timer, to
keep the table from growing without bound. A Stager-shaped actor — the
pruning SQL lives in the engine (engine.prune_jobs, per driver);
this plugin just drives it on its interval.
Leader-only, so duplicate work is avoided across a cluster: the leader check
reads config.peer.is_leader() (a pure cell lookup) — the Postgres lease
peer elects one node, and single-node / in-memory uses peer.always_leader.
limit caps how many rows a single pass deletes, so a large backlog drains
over several ticks rather than one long statement.
Types
pub type State {
State(
config: config.Config,
max_age: duration.Duration,
interval: duration.Duration,
limit: Int,
self_subject: process.Subject(Message),
)
}
Constructors
-
State( config: config.Config, max_age: duration.Duration, interval: duration.Duration, limit: Int, self_subject: process.Subject(Message), )
Values
pub fn default_interval() -> duration.Duration
How often a prune pass runs — Elixir’s default
(pruner.ex interval: :timer.seconds(30)).
pub const default_limit: Int
Cap on rows deleted per pass — Elixir’s default (pruner.ex limit: 10_000).
pub fn default_max_age() -> duration.Duration
How old a terminal job must be to be removed — Elixir’s default
(pruner.ex max_age: 60 seconds).
pub fn plugin() -> plugin.Plugin
Package the Pruner as a runtime Plugin for MuleSpec.plugins with
Elixir’s defaults: delete terminal jobs older than 60 seconds, sweeping
every 30 seconds, at most 10,000 rows per pass.
pub fn plugin_with(
max_age max_age: duration.Duration,
interval interval: duration.Duration,
limit limit: Int,
) -> plugin.Plugin
plugin with explicit settings: max_age is how old a terminal job must
be to be removed, interval how often a pass runs, and limit the cap
per pass.
pub fn start(
config config: config.Config,
max_age max_age: duration.Duration,
interval interval: duration.Duration,
limit limit: Int,
) -> Result(
actor.Started(process.Subject(Message)),
actor.StartError,
)