healthcheck

package
v0.0.0-...-df04a74 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2016 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package healthcheck implements backend and service healthchecks.

Index

Constants

View Source
const (
	ICMP4_ECHO_REQUEST = 8
	ICMP4_ECHO_REPLY   = 0
	ICMP6_ECHO_REQUEST = 128
	ICMP6_ECHO_REPLY   = 129
)

Variables

This section is empty.

Functions

func DNSType

func DNSType(name string) (uint16, error)

DNSType returns the dnsType that corresponds with the given name.

Types

type Check

type Check struct {
	Config
	// contains filtered or unexported fields
}

Check represents a healthcheck instance.

func NewCheck

func NewCheck(notify chan<- *Notification) *Check

NewCheck returns an initialised Check.

func (*Check) Blocking

func (hc *Check) Blocking(block bool)

Blocking enables or disables blocking updates for a healthcheck.

func (*Check) Notify

func (hc *Check) Notify()

Notify generates a healthcheck notification for this checker.

func (*Check) Run

func (hc *Check) Run(start <-chan time.Time)

Run invokes a healthcheck. It waits for the initial configuration to be provided via the configuration channel, after which the configured healthchecker is invoked at the given interval. If a new configuration is provided the healthchecker is updated and checks are scheduled at the new interval. Notifications are generated and sent via the notification channel whenever a state transition occurs. Run will terminate once a value is received on the quit channel.

func (*Check) Status

func (hc *Check) Status() Status

Status returns the current status for this healthcheck instance.

func (*Check) Stop

func (hc *Check) Stop()

Stop notifies a running healthcheck that it should quit.

func (*Check) Update

func (hc *Check) Update(config *Config)

Update queues a healthcheck configuration update for processing.

type Checker

type Checker interface {
	Check(timeout time.Duration) *Result
	String() string
}

Checker is the interface that must be implemented by a healthcheck.

type Checks

type Checks struct {
	Configs map[Id]*Config
}

Checks provides a map of healthcheck configurations.

type Config

type Config struct {
	Id
	Interval time.Duration
	Timeout  time.Duration
	Retries  int
	Checker
}

Config contains the configuration for a healthcheck.

func NewConfig

func NewConfig(id Id, checker Checker) *Config

NewConfig returns an initialised Config.

type DNSChecker

type DNSChecker struct {
	Target
	Question dns.Question
	Answer   string
}

DNSChecker contains configuration specific to a DNS healthcheck.

func NewDNSChecker

func NewDNSChecker(ip net.IP, port int) *DNSChecker

NewDNSChecker returns an initialised DNSChecker.

func (*DNSChecker) Check

func (hc *DNSChecker) Check(timeout time.Duration) *Result

Check executes a DNS healthcheck.

func (*DNSChecker) String

func (hc *DNSChecker) String() string

String returns the string representation of a DNS healthcheck.

type HTTPChecker

type HTTPChecker struct {
	Target
	Secure       bool
	TLSVerify    bool
	Method       string
	Proxy        bool
	Request      string
	Response     string
	ResponseCode int
}

HTTPChecker contains configuration specific to a HTTP healthcheck.

func NewHTTPChecker

func NewHTTPChecker(ip net.IP, port int) *HTTPChecker

NewHTTPChecker returns an initialised HTTPChecker.

func (*HTTPChecker) Check

func (hc *HTTPChecker) Check(timeout time.Duration) *Result

Check executes a HTTP healthcheck.

func (*HTTPChecker) String

func (hc *HTTPChecker) String() string

String returns the string representation of an HTTP healthcheck.

type HealthState

type HealthState struct {
	Ctx           *ipc.Context
	Notifications []*Notification
}

HealthState contains data for a healthcheck state IPC.

type Id

type Id uint64

Id provides the unique identifier of a given healthcheck.

type Notification

type Notification struct {
	Id
	Status
}

Notification stores a status notification for a healthcheck.

func (*Notification) String

func (n *Notification) String() string

String returns the string representation for the given notification.

type PingChecker

type PingChecker struct {
	Target
	ID     uint16
	Seqnum uint16
}

PingChecker contains configuration specific to a ping healthcheck.

func NewPingChecker

func NewPingChecker(ip net.IP) *PingChecker

NewPingChecker returns an initialised PingChecker.

func (*PingChecker) Check

func (hc *PingChecker) Check(timeout time.Duration) *Result

Check executes a ping healthcheck.

func (*PingChecker) String

func (hc *PingChecker) String() string

String returns the string representation of a Ping healthcheck.

type RADIUSChecker

type RADIUSChecker struct {
	Target
	Username string
	Password string
	Secret   string
	Response string
}

RADIUSChecker contains configuration specific to a RADIUS healthcheck.

func NewRADIUSChecker

func NewRADIUSChecker(ip net.IP, port int) *RADIUSChecker

NewRADIUSChecker returns an initialised RADIUSChecker.

func (*RADIUSChecker) Check

func (hc *RADIUSChecker) Check(timeout time.Duration) *Result

Check executes a RADIUS healthcheck.

func (*RADIUSChecker) String

func (hc *RADIUSChecker) String() string

String returns the string representation of a RADIUS healthcheck.

type Result

type Result struct {
	Message string
	Success bool
	time.Duration
	Err error
}

Result stores the result of a healthcheck performed by a checker.

func (*Result) String

func (r *Result) String() string

String returns the string representation of a healthcheck result.

type Server

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

Server contains the data needed to run a healthcheck server.

func NewServer

func NewServer(cfg *ServerConfig) *Server

NewServer returns an initialised healthcheck server.

func (*Server) Run

func (s *Server) Run()

Run runs a healthcheck server.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown notifies a healthcheck server to shutdown.

type ServerConfig

type ServerConfig struct {
	BatchDelay     time.Duration
	BatchSize      int
	ChannelSize    int
	EngineSocket   string
	MaxFailures    int
	NotifyInterval time.Duration
	RetryDelay     time.Duration
}

ServerConfig specifies the configuration for a healthcheck server.

func DefaultServerConfig

func DefaultServerConfig() ServerConfig

DefaultServerConfig returns the default server configuration.

type State

type State int

State represents the current state of a healthcheck.

const (
	StateUnknown State = iota
	StateUnhealthy
	StateHealthy
)

func (State) String

func (s State) String() string

String returns the string representation for the given healthcheck state.

type Status

type Status struct {
	LastCheck time.Time
	Duration  time.Duration
	Failures  uint64
	Successes uint64
	State
	Message string
}

Status represents the current status of a healthcheck instance.

type TCPChecker

type TCPChecker struct {
	Target
	Receive   string
	Send      string
	Secure    bool
	TLSVerify bool
}

TCPChecker contains configuration specific to a TCP healthcheck.

func NewTCPChecker

func NewTCPChecker(ip net.IP, port int) *TCPChecker

NewTCPChecker returns an initialised TCPChecker.

func (*TCPChecker) Check

func (hc *TCPChecker) Check(timeout time.Duration) *Result

Check executes a TCP healthcheck.

func (*TCPChecker) String

func (hc *TCPChecker) String() string

String returns the string representation of a TCP healthcheck.

type Target

type Target struct {
	IP    net.IP // IP address of the healthcheck target.
	Host  net.IP // Host to run the healthcheck against.
	Mark  int
	Mode  seesaw.HealthcheckMode
	Port  int
	Proto seesaw.IPProto
}

Target specifies the target for a healthcheck.

func (Target) String

func (t Target) String() string

String returns the string representation of a healthcheck target.

type UDPChecker

type UDPChecker struct {
	Target
	Receive string
	Send    string
}

UDPChecker contains configuration specific to a UDP healthcheck.

func NewUDPChecker

func NewUDPChecker(ip net.IP, port int) *UDPChecker

NewUDPChecker returns an initialised UDPChecker.

func (*UDPChecker) Check

func (hc *UDPChecker) Check(timeout time.Duration) *Result

Check executes a UDP healthcheck.

func (*UDPChecker) String

func (hc *UDPChecker) String() string

String returns the string representation of a UDP healthcheck.

Jump to

Keyboard shortcuts

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