Periodically prunes data older than the configured retention window.
Calls SquatchMail.Tracker.prune/0 (which itself reads retention_days
off the source row, and applies a fixed 30-day window to webhook_logs)
on a timer, every SquatchMail.Config.pruner_interval_ms/0 (6 hours by
default). The first run is delayed by a full interval rather than firing
at boot, so a freshly-started host isn't immediately hit with a prune
sweep before it's had a chance to configure anything. Call run_now/0 to
prune immediately (tests, a manual "prune now" admin action, etc).
Disabled entirely (no timer scheduled) when
SquatchMail.Config.pruner_enabled?/0 is false.
Failures are caught and logged rather than crashing the process — a transient database hiccup during one scheduled prune shouldn't take down the pruner and stop all future runs.
Emits [:squatch_mail, :prune, :done] telemetry with measurements
%{emails: n, webhook_logs: n} (plus events in metadata) after every
run, scheduled or manual.
Summary
Functions
Returns a specification to start this module under a supervisor.
Runs a prune immediately, outside the regular schedule.
Starts the pruner.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec run_now() :: %{ emails: non_neg_integer(), events: non_neg_integer(), webhook_logs: non_neg_integer() }
Runs a prune immediately, outside the regular schedule.
Returns the same shape as SquatchMail.Tracker.prune/0 and still emits
[:squatch_mail, :prune, :done].
@spec start_link(Keyword.t()) :: GenServer.on_start()
Starts the pruner.