incident

package
v0.12.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Prefix = []byte{0, 105, 110, 99, 105, 100, 101, 110, 116, 32, 104, 105, 115, 116, 111, 114, 121}

Functions

func Conclude

func Conclude(serviceID uuid.UUID, startTime, endTime time.Time) (err error)

Find the incident with the specified serviceID and startTime and update its endTime.

func Create

func Create(incident *Incident) (err error)

Create the incident in the correct incident day based on the start time.

func DateFromTime

func DateFromTime(ts time.Time) time.Time

func New

func New(previous, current health.ServiceStatus, service *services.Service) (err error)

New creates an incident based on the previous and current statuses.

func NewRelativeStatusChange

func NewRelativeStatusChange(previous, current health.ServiceStatus, service *services.Service) (err error)

func NewStatusChange

func NewStatusChange(previous, current health.ServiceStatus, service *services.Service) (err error)

func NewVersionChange

func NewVersionChange(previous, current health.ServiceStatus, service *services.Service) (err error)

func NewVersionDetected

func NewVersionDetected(current health.ServiceStatus, service *services.Service) (err error)

func NotADate

func NotADate(t time.Time) bool

func Today

func Today() time.Time

func Update

func Update(serviceID uuid.UUID, startTime time.Time, update func(*Incident) error) (err error)

Types

type Group

type Group struct {
	Date      time.Time   `msgpack:"date"`
	Incidents []*Incident `msgpack:"incidents"`
}

Incidents are grouped by day and stored together in the database to make it easier to fetch incidents for a specific date rather than have to serialize each incident individually. To update an incident group ensure a transaction is used.

func LastWeek

func LastWeek() (_ []*Group, err error)

Returns the last week's worth of incidents or an empty incident group if none exists.

func (*Group) Key

func (g *Group) Key() (key []byte, err error)

An incident group key is by date, ensuring the date is in the UTC timezone and that the timestamp is truncated to midnight (e.g. contains only date components).

func (*Group) Marshal

func (g *Group) Marshal() ([]byte, error)

func (*Group) Unmarshal

func (g *Group) Unmarshal(data []byte) error

type Incident

type Incident struct {
	ServiceID      uuid.UUID     `msgpack:"service_id"`
	ServiceName    string        `msgpack:"service_name"`
	Description    string        `msgpack:"description"`
	StartTime      time.Time     `msgpack:"start_time"`
	EndTime        time.Time     `msgpack:"end_time"`
	Status         health.Status `msgpack:"status"`
	PreviousStatus health.Status `msgpack:"previous_status"`
}

func (*Incident) DescriptionFromStatus

func (i *Incident) DescriptionFromStatus() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL