Documentation
¶
Overview ¶
Package cleanup runs the scheduled, in-process pruning of stale rows from the slack_messages table. The scheduler runs one cleanup immediately on start, then once every Interval, until its context is cancelled.
Index ¶
Constants ¶
const Interval = 24 * time.Hour
Interval is the fixed cadence between cleanup ticks. 24h is conservative enough that a transient DB error has nearly a full day to clear before the next attempt.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler periodically deletes slack_messages rows older than ttl.
func NewScheduler ¶
func NewScheduler(deleter StaleMessageDeleter, ttl, interval time.Duration, logger *slog.Logger) *Scheduler
NewScheduler constructs a Scheduler. ttl is the maximum age a row may reach before becoming eligible for deletion; interval is the cadence between cleanup attempts (use cleanup.Interval in production).
func (*Scheduler) Run ¶
Run drives one cleanup immediately, then one per interval, until ctx is cancelled. Errors from the deleter are logged and swallowed — the next tick retries. Always returns nil (the signature stays error-returning so callers can compose it with other long-running goroutines without special-casing).
func (*Scheduler) SetNowFunc ¶
SetNowFunc overrides the clock used to compute cutoff timestamps. Tests only — production code uses the default time.Now.