store

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROBE_HISTORY_LEN    = 40
	INCIDENT_HISTORY_LEN = 10
	LOG_RESTORE_BYTES    = 1024 * 1024
)

Variables

This section is empty.

Functions

func EscapeMessage added in v0.3.0

func EscapeMessage(s string) string

func UnescapeMessage added in v0.3.0

func UnescapeMessage(s string) string

Types

type Incident

type Incident struct {
	Target     *url.URL
	Status     Status
	Message    string
	CausedAt   time.Time
	ResolvedAt time.Time
}

func NewIncident

func NewIncident(r Record) *Incident

func (*Incident) IsContinued

func (i *Incident) IsContinued(r Record) bool

func (*Incident) SameTarget

func (i *Incident) SameTarget(r Record) bool

type IncidentHandler

type IncidentHandler func(*Incident)

type ProbeHistory

type ProbeHistory struct {
	Target  *url.URL
	Records []*Record
}

type ProbeHistoryMap

type ProbeHistoryMap map[string]*ProbeHistory

func (ProbeHistoryMap) Append added in v0.3.0

func (hs ProbeHistoryMap) Append(r Record)

type Record

type Record struct {
	CheckedAt time.Time
	Target    *url.URL
	Status    Status
	Message   string
	Latency   time.Duration
}

func ParseRecord

func ParseRecord(s string) (Record, error)

func (Record) Equals

func (r Record) Equals(r2 Record) bool

func (Record) Sanitize

func (r Record) Sanitize() Record

func (Record) String

func (r Record) String() string

type Status

type Status int8
const (
	STATUS_UNKNOWN Status = iota
	STATUS_HEALTHY
	STATUS_FAILURE
	STATUS_ABORTED
)

func ParseStatus

func ParseStatus(s string) Status

func (Status) String

func (s Status) String() string

type Store

type Store struct {
	Path string

	Console io.Writer

	OnIncident    []IncidentHandler
	IncidentCount int
	// contains filtered or unexported fields
}

func New

func New(path string) (*Store, error)

func (*Store) AddTarget

func (s *Store) AddTarget(target *url.URL)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CurrentIncidents

func (s *Store) CurrentIncidents() []*Incident

func (*Store) Err

func (s *Store) Err() error

func (*Store) IncidentHistory

func (s *Store) IncidentHistory() []*Incident

func (*Store) ProbeHistory

func (s *Store) ProbeHistory() []*ProbeHistory

func (*Store) Report added in v0.4.0

func (s *Store) Report(r Record)

func (*Store) Restore

func (s *Store) Restore() error

Jump to

Keyboard shortcuts

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