mon

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET  method = false
	HEAD method = true
	UDP  method = false
	TCP  method = true
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	// Type of check; http, https, syn, dns
	Type string `json:"type,omitempty"`

	// TCP/UDP port to use for L4/L7 checks
	Port uint16 `json:"port,omitempty"`

	// HTTP Host header to send in healthcheck
	Host string `json:"host,omitempty"`

	// Path of resource to use when building a URI for HTTP/HTTPS healthchecks
	Path string `json:"path,omitempty"`

	// Expected HTTP status codes to allow check to succeed
	Expect []int `json:"expect,omitempty"`

	// Method - HTTP: GET=false, HEAD=true DNS: UDP=false TCP=true
	Method method `json:"method,omitempty"`
}

func (Check) String added in v0.0.10

func (c Check) String() string

render checks almost exactly like the raw Go output, but give more context to the method field

type Checks

type Checks = []Check

type Destination

type Destination struct {
	Address netip.Addr
	Port    uint16
}

type Instance

type Instance struct {
	Service     Service
	Destination Destination
}

type Mon

type Mon struct {
	C        chan bool
	Prober   Prober
	Notifier Notifier
	// contains filtered or unexported fields
}

func New

func New(addr netip.Addr, services map[Instance]Target, notifier Notifier, prober Prober) (*Mon, error)

func (*Mon) Probe

func (m *Mon) Probe(addr netip.Addr, c Check) (ok bool, s string)

func (*Mon) Start added in v0.0.10

func (m *Mon) Start(addr netip.Addr, services map[Instance]Target) error

func (*Mon) Status

func (m *Mon) Status(svc Service, dst Destination) (status Status, _ bool)

func (*Mon) Stop

func (m *Mon) Stop()

func (*Mon) Update

func (m *Mon) Update(checks map[Instance]Target)

type Notifier added in v0.0.5

type Notifier interface {
	Notify(Instance, bool)
	Result(Instance, bool, string)
	Check(Instance, string, uint64, bool, string)
}

type Prober

type Prober interface {
	Probe(*Mon, Instance, Check) (bool, string)
}

type SYN

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

func Syn

func Syn(addr netip.Addr, rst bool) (*SYN, error)

func (*SYN) Check

func (s *SYN) Check(dst [4]byte, port uint16) (bool, string)

func (*SYN) Probe

func (s *SYN) Probe(addr netip.Addr, port uint16) bool

type Service

type Service struct {
	Address  netip.Addr
	Port     uint16
	Protocol uint8
}

type Services

type Services map[Instance]Checks

type Status

type Status struct {
	OK          bool
	Diagnostic  string
	Took        time.Duration
	Last        time.Time
	When        time.Time
	Initialised bool
}

type SynChecks

type SynChecks = SYN

type Target

type Target struct {
	Init   bool
	Checks Checks
}

Jump to

Keyboard shortcuts

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