Documentation
¶
Overview ¶
Package maintenance holds one-off scheduled maintenance windows: their validation, state, and the lead-time announcement through alert channels.
Index ¶
- Constants
- func AnnounceDue(w store.MaintenanceWindow, now time.Time) bool
- func DomainWindow(m store.DomainMaintenance, app string, now, until time.Time) store.MaintenanceWindow
- func NormalizeBypass(entries []string) ([]string, error)
- func NoticeText(w store.MaintenanceWindow) string
- func StateAt(w store.MaintenanceWindow, now time.Time) string
- type AnnounceStore
- type Announcer
- type Channels
- type DomainExpirer
- type DomainExpiryStore
- type DomainInput
- type Input
- type Notifier
Constants ¶
const ( MaxDomainTitle = 120 MaxDomainMessage = 2000 MaxBypassEntries = 32 MaxRetryAfterSecond = 86400 )
Bounds on a domain's maintenance settings.
const ( StateScheduled = "scheduled" StateActive = "active" StateEnded = "ended" )
Window states relative to one instant.
const ( MaxDuration = 30 * 24 * time.Hour MaxLeadMinutes = 7 * 24 * 60 )
Bounds on user input.
const DefaultInterval = time.Minute
DefaultInterval is how often the announcer looks for windows entering their lead time.
Variables ¶
This section is empty.
Functions ¶
func AnnounceDue ¶
func AnnounceDue(w store.MaintenanceWindow, now time.Time) bool
AnnounceDue reports whether the lead-time notice should go out now.
func DomainWindow ¶
func DomainWindow(m store.DomainMaintenance, app string, now, until time.Time) store.MaintenanceWindow
DomainWindow is the scheduled window that carries a domain's end time, so the banner, status page and announcer see it without a second state.
func NormalizeBypass ¶
NormalizeBypass turns IP addresses and CIDRs into deduplicated, masked CIDRs. A catch-all range is refused: that is ending maintenance.
func NoticeText ¶
func NoticeText(w store.MaintenanceWindow) string
NoticeText is the plain-text announcement for w.
Types ¶
type AnnounceStore ¶
type AnnounceStore interface {
ListMaintenanceWindows(ctx context.Context, since time.Time) ([]store.MaintenanceWindow, error)
MarkMaintenanceAnnounced(ctx context.Context, id string, at time.Time) error
}
AnnounceStore is the store surface the announcer needs.
type Announcer ¶
type Announcer struct {
Store AnnounceStore
Channels Channels
Notifier Notifier
Logger *slog.Logger
Now func() time.Time
}
Announcer sends each window's lead-time notice once.
type Channels ¶
type Channels interface {
ListNotificationChannels(ctx context.Context) ([]alerting.NotificationChannel, error)
}
Channels lists notification channels. *alerting.DB satisfies it.
type DomainExpirer ¶
type DomainExpirer struct {
Store DomainExpiryStore
Nudge func()
Logger *slog.Logger
Now func() time.Time
}
DomainExpirer ends a domain's maintenance once its linked window ends or is cancelled. The ingress already stops serving the page at that instant; this removes the row, audits it and asks for a prompt reconcile.
type DomainExpiryStore ¶
type DomainExpiryStore interface {
ListExpiredDomainMaintenance(ctx context.Context, now time.Time) ([]store.DomainMaintenance, error)
DeleteDomainMaintenance(ctx context.Context, domain string) error
SaveAuditEntry(ctx context.Context, e store.AuditEntry) error
}
DomainExpiryStore is what ending timed domain maintenance needs.
type DomainInput ¶
type DomainInput struct {
Title string
Message string
RetryAfterSeconds int
// Until, when set, ends maintenance automatically through a linked window.
Until *time.Time
Bypass []string
BypassHealthCheck bool
}
DomainInput is a request to put one domain into maintenance.
func (DomainInput) Validate ¶
func (in DomainInput) Validate(domain string, now time.Time) (store.DomainMaintenance, error)
Validate checks in and returns the settings to store, without a window id.