Documentation
¶
Index ¶
Constants ¶
const ( // PhaseScheduled means no check-in has been received yet, so the monitor is scheduled but inactive. PhaseScheduled Phase = "scheduled" // PhaseAwaiting means the monitor is awaiting the next expected check-in. PhaseAwaiting Phase = "awaiting" // PhaseOverdue means the expected check-in deadline elapsed and the alerting delay is running. PhaseOverdue Phase = "overdue" // PhaseAlerting means the alerting delay elapsed and notification was sent. PhaseAlerting Phase = "alerting" // StatusAlerting marks an alerting notification. StatusAlerting EventStatus = "alerting" // StatusResolved marks a resolved notification. StatusResolved EventStatus = "resolved" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
CheckResult describes lifecycle events emitted by advancing the monitor clock.
type Event ¶
type Event struct {
IncidentID string
NotificationID string
CheckInName string
LastCheckIn time.Time
ExpectedBy time.Time
OverdueSince time.Time
AlertingAt time.Time
Now time.Time
Phase Phase
Status EventStatus
Resolved bool
Title string
Text string
}
Event describes a check-in lifecycle event used when rendering and sending notifications.
IncidentID identifies one overdue episode and is shared by the alerting and resolved notifications. NotificationID identifies one concrete notification message and is stable across delivery retries for that message.
The monitor owns factual event data only. Presentation fields such as Title and Text are intentionally left empty by the monitor and are filled by the notification renderer from the configured title/text templates.
type EventStatus ¶
type EventStatus string
EventStatus describes the status of a notification lifecycle event.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor tracks check-in deadlines and notification state.
func New ¶
func New( checkInName string, expectedEvery, alertingDelay time.Duration, logger *slog.Logger, ) *Monitor
New creates a monitor and requires a logger because logging is part of monitor behavior.
func (*Monitor) Check ¶
func (m *Monitor) Check(now time.Time) CheckResult
Check advances monitor state for a given time and returns lifecycle events when needed.
func (*Monitor) CheckInName ¶
CheckInName returns the configured check-in monitor name.
func (*Monitor) NextDeadline ¶
NextDeadline returns the next lifecycle deadline for the current phase.
func (*Monitor) RecordCheckIn ¶
func (m *Monitor) RecordCheckIn(at time.Time) RecordResult
RecordCheckIn stores a check-in time, activates or restarts the expected deadline, and returns a resolved event after alerts.
type RecordResult ¶
RecordResult describes the outcome of recording a check-in.