monitor

package
v0.0.0-...-7652ffb Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// HeartBeatTimeout is the maximum age of a component's heartbeat.
	// After this time, the heartbeat is considered to be stale and the
	// component in a bad state.
	HeartBeatTimeout = 90 * time.Second

	// HeartBeatWaitTimeout is the maximum amount of time the component will
	// wait to get a heartbeat. After this time, the component will examine
	// the last heartbeat received to determine if it has timed out. If so,
	// the component will be set at a bad state.
	HeartBeatWaitTimeout = 120 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	State            *State
	HeartBeatChannel chan *heart.HeartBeat
	Name             string
}

Component is a basic statemachine Heartbeat timeout: OK(true)->OK(false) ; OK(false)->OK(false) Heartbeat received: OK(true)->OK(true) ; OK(false)->OK(true)

Once a HeartBeat is received, a component has HeartBeatWaitTimeout until the next heartbeat is received. When that heartbeat is received, it will be checked for recency. If it has not timed out (i.e. the HeartBeat is < 30 seconds old, its state will be the state of the component. If the HeartBeat is stale, it will be discarded and the component will be in a bad state.

func NewComponent

func NewComponent(name string) *Component

func (*Component) Send

func (c *Component) Send(hb *heart.HeartBeat)

type Monitor

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

func NewMonitor

func NewMonitor(nsqdHost string) (*Monitor, error)

func (*Monitor) SerializeState

func (m *Monitor) SerializeState() ([]byte, error)

func (*Monitor) Stop

func (m *Monitor) Stop()

type State

type State struct {
	OK        bool `json:"ok"`
	HeartBeat *heart.HeartBeat
}

Jump to

Keyboard shortcuts

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