checks

package
v0.0.0-...-9581e64 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StateFnMap = map[StateId]StateFn{}

	ValidStates = []StateId{
		StateOK,
		StateFailWait,
		StatePassWait,
		StateFail,
		StateWarn,
	}
)

Functions

func AddHook

func AddHook(hook TransitionHook)

func AddStateHook

func AddStateHook(id StateId, hook TransitionHook)

Types

type ResultMemo

type ResultMemo struct {
	CheckId       string    `json:"check_id" db:"check_id"`
	CustomerId    string    `json:"customer_id" db:"customer_id"`
	BastionId     string    `json:"bastion_id" db:"bastion_id"`
	FailingCount  int32     `json:"failing_count" db:"failing_count"`
	ResponseCount int       `json:"response_count" db:"response_count"`
	LastUpdated   time.Time `json:"last_updated" db:"last_updated"`
}

func ResultMemoFromCheckResult

func ResultMemoFromCheckResult(result *schema.CheckResult) *ResultMemo

type State

type State struct {
	CheckId         string        `json:"check_id" db:"check_id"`
	CustomerId      string        `json:"customer_id" db:"customer_id"`
	Id              StateId       `json:"state_id" db:"state_id"`
	State           string        `json:"state_name" db:"state_name"`
	TimeEntered     time.Time     `json:"time_entered" db:"time_entered"`
	LastUpdated     time.Time     `json:"last_updated" db:"last_updated"`
	MinFailingCount int32         `json:"min_failing_count" db:"min_failing_count"`
	MinFailingTime  time.Duration `json:"min_failing_time" db:"min_failing_time"`
	FailingCount    int32         `json:"failing_count" db:"failing_count"`
	ResponseCount   int32         `json:"response_count" db:"response_count"`
}

State represents what we know about a given Check based on a collection of CheckResults from bastions.

func (*State) TimeInState

func (state *State) TimeInState() time.Duration

func (*State) Transition

func (state *State) Transition(result *schema.CheckResult) error

Transition is the transition function for the Check state machine. Given a proposed change to the current state (a new CheckResult object), update the state for the check associated with the result.

type StateFn

type StateFn func(state *State) StateId

type StateId

type StateId int
const (
	StateInvalid StateId = iota // ignore 0
	StateOK
	StateFailWait
	StatePassWait
	StateFail
	StateWarn
)

func (StateId) String

func (s StateId) String() string

type StateTransitionLogEntry

type StateTransitionLogEntry struct {
	Id         int64     `json:"id" db:"id"`
	CheckId    string    `json:"check_id" db:"check_id"`
	CustomerId string    `json:"customer_id" db:"customer_id"`
	From       StateId   `json:"from_state" db:"from_state"`
	To         StateId   `json:"to_state" db:"to_state"`
	CreatedAt  time.Time `json:"created_at" db:"created_at"`
}

StateTransitionLogEntry is a record of a transition from one state (From) to another state (To).

type TransitionHook

type TransitionHook func(newStateId StateId, state *State, result *schema.CheckResult)

Directories

Path Synopsis
There are two hot tables in DynamoDB for CheckResults and CheckResponses named check_results and check_responses respectively.
There are two hot tables in DynamoDB for CheckResults and CheckResponses named check_results and check_responses respectively.

Jump to

Keyboard shortcuts

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