alerts

package
v0.0.0-...-52973e1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package alerts provides alerts based on history of events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEvent

func AddEvent(events []*Event, message string)

AddEvent adds an event to store.

Types

type Alerter

type Alerter struct {
	sync.Mutex

	History *History
	Events  []*Event
	// contains filtered or unexported fields
}

Alerter is based on number of recent requests.

func New

func New(c clock.Clock, h *History, i time.Duration, t int, s *screens.Screen) *Alerter

New creates a new alerter.

func (*Alerter) Check

func (a *Alerter) Check()

Check activates and clears the alert as needed

func (*Alerter) IsActivated

func (a *Alerter) IsActivated() bool

IsActivated ...

func (*Alerter) Run

func (a *Alerter) Run()

Run starts the process of periodically processing the alert.

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event is message with a time stamp

type History

type History struct {
	sync.Mutex
	// contains filtered or unexported fields
}

History stores a list of recent requests.

func NewHistory

func NewHistory(c clock.Clock, d time.Duration) *History

NewHistory creates a new instance of History. A clock is passed in to facilate testing.

func (*History) RecentRequestCount

func (h *History) RecentRequestCount() int

RecentRequestCount returns number of requests since last watch interval.

func (*History) Record

func (h *History) Record(req *http.Request)

Record processes the HTTP request.

func (*History) Tidy

func (h *History) Tidy()

Tidy deletes requests that are old.

Jump to

Keyboard shortcuts

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