NatureWhistle. BackgroundCleaner
(nature_whistle v0.3.0)
Copy Markdown
GenServer responsible for alert resolution and periodic cleanup.
The background cleaner has two jobs:
- manage resolution timers for breached alerts
- periodically sweep stale sliding-window and rate-limit buckets from ETS
Resolution timers are stored in the GenServer state rather than ETS because
they are process-local scheduling details. The alert lifecycle itself is still
tracked in :nature_whistle_alert_state, which allows the rest of the system
to see whether an alert is currently breached.
Sweeping is controlled by :background_sweep_interval_ms in application
configuration and uses :max_window_history_ms to decide how far back old
telemetry history should be retained.
Summary
Functions
Returns a specification to start this module under a supervisor.
Replaces the current resolution timer for an alert that is still active.
Removes old rate-limit and sliding-window entries from ETS.
Schedules a resolution timer for a newly breached alert.
Starts the background cleaner process.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Replaces the current resolution timer for an alert that is still active.
If the alert breaches again before the resolution timer expires, the timer is
cancelled and restarted so the calm notification only appears after the metric
has stayed healthy for a full resolution_ms interval.
Removes old rate-limit and sliding-window entries from ETS.
max_window_history_ms defines the oldest timestamp bucket that should be
kept. Buckets older than that are deleted, and rate-limit timestamp lists are
compacted so only recent values remain.
This function is public so it can be exercised directly in tests or invoked manually when diagnosing state retention.
Schedules a resolution timer for a newly breached alert.
This message records the alert's current value and telemetry metadata so the calmer notification can describe the breach that just ended.
Starts the background cleaner process.
Supported options:
:name- optional process name, defaults toNatureWhistle.BackgroundCleaner:sweep_interval_ms- how often to prune ETS state
The process is normally started by NatureWhistle.Application.