guard

package
v0.0.0-...-12a582f Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTTP will make an HTTP request
	// to some data source to test a guard
	HTTP Kind = iota

	// Query Means query a data source
	Query

	// OK means the guard was not triggered
	OK Status = iota

	// Failing status can be used when any status in the window
	// has failed
	Failing

	// Failed means the guard was triggered
	Failed

	// Warn will send a warning
	Warn Action = iota

	// Alert will trigger an alert
	Alert

	// Abort will unsafely and suddenly end the guarded operation
	Abort

	// Teardown will safely begin teardown for any guarded operation
	Teardown

	// DefaultPollInterval is the default checking interval
	// for a guide
	DefaultPollInterval = time.Second * 1

	// DefaultIntegration is the default integration to use
	DefaultIntegration = "cloudwatch"

	// DefaultKind is the default guard type to use
	DefaultKind = Query

	// DefaultWindowSize is the default windowSize to keep of
	// historical statuses
	DefaultWindowSize = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action is the response to take to a guard being triggered

type Guard

type Guard struct {
	Kind               Kind          `json:"kind"`
	Name               string        `json:"name"`
	Status             Status        `json:"status"`
	StatusDistribution []Status      `json:"statusDist"`
	Count              int           `json:"count"`
	Threshold          int           `json:"threshold"`
	Interval           time.Duration `json:"interval"`
	WindowSize         int           `json:"windowSize"`
	Tolerance          float32       `json:"tolerance"`
	Spec               interface{}   `json:"spec"`
	Integration        string        `json:"integration"`

	Err error
	// contains filtered or unexported fields
}

Guard is a mechanism for watching some data and using that as signal to see if

func NewGuard

func NewGuard() *Guard

NewGuard returns an initialized Guard

func (*Guard) Evaluate

func (g *Guard) Evaluate() Status

Evaluate uses the distribution of previous checks to see if we cross a defined threshold for the guard. Needs improving

func (*Guard) Failed

func (g *Guard) Failed() bool

Failed returns true if we've determined the guard to be failing

func (*Guard) Start

func (g *Guard) Start() chan Status

Start begins continuously running a guard

func (*Guard) Stop

func (g *Guard) Stop() error

Stop stops a running guard

type Kind

type Kind int

Kind represents the type of guard to use and how the data as input to the guard is sourced

type Status

type Status int

Status is the guard's suggestion of a state of the input data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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