Documentation
¶
Overview ¶
Package statuspage builds the opt-in public status page: component probing, 90-day uptime bars, operator-authored incidents and the whitelisted public view. Nothing beyond View is ever published.
Index ¶
- Constants
- func OverallStatus(statuses []string) string
- func RenderHTML(v View) ([]byte, error)
- func RenderMarkdownLite(src string) template.HTML
- func RenderRSS(v View, baseURL string) ([]byte, error)
- func StatusText(s string) string
- type AppSource
- type ComponentView
- type Config
- type DayView
- type DomainSource
- type IncidentView
- type Service
- func (s *Service) Enabled(ctx context.Context) (bool, error)
- func (s *Service) Invalidate()
- func (s *Service) PreviewView(ctx context.Context) (View, error)
- func (s *Service) Run(ctx context.Context) error
- func (s *Service) Sample(ctx context.Context) error
- func (s *Service) SetWindows(w WindowSource)
- func (s *Service) View(ctx context.Context) (View, error)
- type Store
- type UpdateView
- type View
- type WindowSource
Constants ¶
const ( PagePath = "/public/status" SummaryPath = "/public/status.json" FeedPath = "/public/status.rss" )
FeedPath and SummaryPath are the public asset paths, relative to the page.
const ( DefaultSampleInterval = time.Minute DefaultCacheTTL = 30 * time.Second DefaultCheckTimeout = 8 * time.Second )
Defaults for Config, overridable via environment in cmd/levelrail.
const ( Operational = "operational" Degraded = "degraded" Outage = "outage" Maintenance = "maintenance" Unknown = "unknown" NoData = "nodata" )
Component and overall statuses.
const ( KindApp = "app" KindDomain = "domain" KindCheck = "check" )
Component kinds.
const ( IncidentKind = "incident" MaintenanceKind = "maintenance" StatusInvestigating = "investigating" StatusIdentified = "identified" StatusMonitoring = "monitoring" StatusResolved = "resolved" StatusScheduled = "scheduled" StatusInProgress = "in_progress" StatusCompleted = "completed" ImpactNone = "none" ImpactMinor = "minor" ImpactMajor = "major" ImpactCritical = "critical" )
Incident kinds, statuses and impacts.
const UptimeDays = 90
UptimeDays is the number of daily bars on the page.
Variables ¶
This section is empty.
Functions ¶
func OverallStatus ¶
OverallStatus folds component statuses into one headline status.
func RenderMarkdownLite ¶
RenderMarkdownLite converts operator text to safe HTML. All input is escaped first; only paragraphs, line breaks, "- " lists, **bold**, `code` and http(s) links are then re-introduced.
func RenderRSS ¶
RenderRSS renders incidents and maintenance as an RSS 2.0 feed with plain-text descriptions. baseURL is the page's own origin, e.g. "https://status.example.com".
func StatusText ¶
StatusText is the human headline for an overall status.
Types ¶
type ComponentView ¶
type ComponentView struct {
Name string `json:"name"`
Status string `json:"status"`
Uptime90 *float64 `json:"uptime_90d"`
Days []DayView `json:"days"`
}
ComponentView is one component as the public sees it.
type Config ¶
type Config struct {
SampleInterval time.Duration
CacheTTL time.Duration
CheckTimeout time.Duration
Parallelism int
}
Config tunes sampling and caching; zero values take the defaults.
type DayView ¶
type DayView struct {
Date string `json:"date"`
Status string `json:"status"`
Uptime *float64 `json:"uptime,omitempty"`
}
DayView is one uptime bar.
type DomainSource ¶
type DomainSource interface {
CheckDomainStatus(ctx context.Context, domain string) (string, error)
}
DomainSource is the existing DNS domain check.
type IncidentView ¶
type IncidentView struct {
ID string `json:"id"`
Title string `json:"title"`
Status string `json:"status"`
Impact string `json:"impact"`
StartsAt time.Time `json:"starts_at"`
EndsAt *time.Time `json:"ends_at,omitempty"`
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
Components []string `json:"components,omitempty"`
Updates []UpdateView `json:"updates"`
}
IncidentView is an incident or maintenance announcement.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service samples component health and builds the public View.
func New ¶
New builds a Service. apps and domains may be nil, in which case components of that kind report unknown.
func (*Service) Invalidate ¶
func (s *Service) Invalidate()
Invalidate drops the cached view so the next read reflects a management change.
func (*Service) PreviewView ¶
PreviewView builds an uncached view regardless of the enabled flag, for the management UI.
func (*Service) Sample ¶
Sample probes every component once and records the result. It does nothing while the page is disabled.
func (*Service) SetWindows ¶
func (s *Service) SetWindows(w WindowSource)
SetWindows adds scheduled maintenance windows to the public view.
type Store ¶
type Store interface {
GetStatusPageSettings(ctx context.Context) (store.StatusPageSettings, error)
ListStatusComponents(ctx context.Context) ([]store.StatusComponent, error)
AddStatusSamples(ctx context.Context, componentID, day string, ok, degraded, down int) error
ListStatusDaily(ctx context.Context, sinceDay string) ([]store.StatusDaily, error)
PruneStatusDaily(ctx context.Context, beforeDay string) error
ListStatusIncidents(ctx context.Context, limit int) ([]store.StatusIncident, error)
ListStatusIncidentUpdates(ctx context.Context) ([]store.StatusIncidentUpdate, error)
}
Store is what Service reads and writes. *store.DB satisfies it.
type UpdateView ¶
type UpdateView struct {
Status string `json:"status"`
Body string `json:"body"`
At time.Time `json:"at"`
}
UpdateView is one timeline entry.
type View ¶
type View struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
StatusText string `json:"status_text"`
GeneratedAt time.Time `json:"generated_at"`
Components []ComponentView `json:"components"`
Incidents []IncidentView `json:"incidents"`
Maintenance []IncidentView `json:"maintenance"`
}
View is the entire public payload. Every field is deliberate: a privacy test fails when one is added without updating its whitelist.
type WindowSource ¶
type WindowSource interface {
ListMaintenanceWindows(ctx context.Context, since time.Time) ([]store.MaintenanceWindow, error)
}
WindowSource lists one-off maintenance windows. *store.DB satisfies it.