store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 9 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

This section is empty.

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) []Record

type ProbeHistory

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

type ProbeHistoryMap

type ProbeHistoryMap map[string]*ProbeHistory

func (ProbeHistoryMap) AsSortedArray

func (hs ProbeHistoryMap) AsSortedArray() []*ProbeHistory

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
)

func ParseStatus

func ParseStatus(s string) Status

func (Status) String

func (s Status) String() string

type Store

type Store struct {
	sync.Mutex

	Path string

	ProbeHistory     ProbeHistoryMap
	CurrentIncidents []*Incident
	IncidentHistory  []*Incident

	OnIncident []IncidentHandler
	// 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) Append

func (s *Store) Append(rs ...Record)

func (*Store) Close

func (s *Store) Close() error

func (*Store) Err

func (s *Store) Err() error

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