health

package
v0.0.0-...-8488f5b Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2016 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check interface {
	Check() error
}

type HTTPCheck

type HTTPCheck struct {
	// URL is the URL that will be requested
	URL string

	// Host specifies the host to be used in the Host header as well as the TLS
	// SNI extension. It is optional, if unset the host from the URL will be
	// used.
	Host string

	Timeout time.Duration
	// The response must respond with StatusCode for the check to pass. It
	// defaults to 200.
	StatusCode int
	// If set, MatchBytes must be a subset present in the first 5120 bytes of
	// the response for the check to pass.
	MatchBytes []byte
}

func (*HTTPCheck) Check

func (c *HTTPCheck) Check() error

func (*HTTPCheck) String

func (c *HTTPCheck) String() string

type Monitor

type Monitor struct {
	// StartInterval is the check interval to use when waiting for the service
	// to transition from created -> up. It defaults to 100ms.
	StartInterval time.Duration

	// Interval is the check interval to use when the service is up or down. It
	// defaults to two seconds.
	Interval time.Duration

	// Threshold is the number of consecutive checks of the same status before
	// a service will transition up -> down or down -> up. It defaults to 2.
	Threshold int

	// Logger is the logger that will be used to emit messages for each
	// transition and for each failed check. If it is nil, no messages will be
	// logged.
	Logger log15.Logger
}

func (Monitor) Run

func (m Monitor) Run(check Check, ch chan MonitorEvent) stream.Stream

Run monitors a service using Check and sends up/down transitions to ch

type MonitorEvent

type MonitorEvent struct {
	Status MonitorStatus
	// If Status is MonitorStatusDown, Err is the last failure
	Err error
	// Check is included to identify the monitor.
	Check Check
}

type MonitorStatus

type MonitorStatus int
const (
	MonitorStatusUnknown MonitorStatus = iota
	MonitorStatusCreated
	MonitorStatusUp
	MonitorStatusDown
)

func (MonitorStatus) String

func (m MonitorStatus) String() string

type Registrar

type Registrar interface {
	RegisterInstance(service string, inst *discoverd.Instance) (discoverd.Heartbeater, error)
}

type Registration

type Registration struct {
	Registrar Registrar
	Service   string
	Instance  *discoverd.Instance
	Monitor   func(Check, chan MonitorEvent) stream.Stream
	Check     Check
	Events    chan MonitorEvent
	Logger    log15.Logger
}

func (*Registration) Register

func (r *Registration) Register() discoverd.Heartbeater

type TCPCheck

type TCPCheck struct {
	Addr    string
	Timeout time.Duration
}

func (*TCPCheck) Check

func (c *TCPCheck) Check() error

func (*TCPCheck) String

func (c *TCPCheck) String() string

Jump to

Keyboard shortcuts

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