health

package module
v0.0.0-...-30f6ce7 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: GPL-3.0 Imports: 20 Imported by: 1

README

health-check

health check service

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotReady      = errors.New("not ready")
	ErrBadBase64Blob = errors.New("wrong base64 encoding")
)
View Source
var (
	ErrUnknownEntity = errors.New("unknown entity")
)

Functions

func HealthQueryHandlerHTML

func HealthQueryHandlerHTML(phs map[string]*HealthService, provider string) httpHandler

User facing status (html) (TODO)

func HealthQueryHandlerJSON

func HealthQueryHandlerJSON(phs map[string]*HealthService, provider string) httpHandler

func HealthSummaryHandlerText

func HealthSummaryHandlerText(phs map[string]*HealthService, provider string) httpHandler

PoC for a general view of status (text/plain)

Types

type Checker

type Checker interface {
	Kind() string
	Proto() string
	ProviderName() string
	Run(chan *Measurement) error
}

Checker is a VPN checker with aspirations of universality.

type HealthService

type HealthService struct {
	// Name contains the provider/entity this service is associated with.
	Name string
	// Checker is the service checker implementation associated with this service.
	Checker Checker

	// The idea behind storing current/previous measurement batches is that
	// we can detect (and store) deltas.
	Current  *MeasurementBatch
	Previous *MeasurementBatch
}

Health schedules service checks, and exposes a method to query for the health status of a particular endpoint.

func (*HealthService) Healthy

func (hs *HealthService) Healthy(addr net.Addr, proto string) (bool, error)

Healthy returns true if the passed address/proto is known to be healthy. It will return an error if we don't have that measurement.

func (*HealthService) RunBatch

func (hs *HealthService) RunBatch(ctx context.Context)

func (*HealthService) Start

func (hs *HealthService) Start() error

Start initiates the scheduler

type Measurement

type Measurement struct {
	// Healthy is true if the service is up.
	Healthy bool
	// Addr is the address we measured.
	Addr net.Addr
	// Transport is tcp | udp
	Transport string
	// For metrics purposes.
	Timestamp time.Time
	// Recovered is intended to be set by the monitoring service, by
	// comparing with the previous run.
	// TODO remove if I don't end up using it (for instance, to make
	// any service using this one aware that this is a resource tha can be
	// added back into the pool).
	Recovered bool
}

Measurement is a single measurement. For what we really care about, it can only be healthy or unhealthy. For the time being, our criteria for "healthy" is having a gateway that can route us to the internet has a ICMP packet loss less than a certain threshold. There's more info we could share: did we get a handshake but we could not route? Can we resolve DNS through the GW? (gateway could have routing problems etc).

func (*Measurement) String

func (m *Measurement) String() string

type MeasurementBatch

type MeasurementBatch struct {
	TimeInRound time.Duration
	// contains filtered or unexported fields
}

A MeasuremenMeasurementBatch is a round of measurements.

func NewMeasurementBatch

func NewMeasurementBatch() *MeasurementBatch

NewNewMeasurementBatch returns a pointer to a MeasurementBatch ready to be used.

func (*MeasurementBatch) Healthy

func (mb *MeasurementBatch) Healthy(addr net.Addr, transport string) (bool, error)

Healthy returns true if the passed address is known to be healthy. It will return an error if we don't have that measurement.

func (*MeasurementBatch) Measurements

func (mb *MeasurementBatch) Measurements() []*Measurement

type VPNChecker

type VPNChecker struct {
	Provider vpn.Provider
	// contains filtered or unexported fields
}

VPNChecker is the real thing.

func (*VPNChecker) Kind

func (v *VPNChecker) Kind() string

func (*VPNChecker) Proto

func (v *VPNChecker) Proto() string

func (*VPNChecker) ProviderName

func (v *VPNChecker) ProviderName() string

func (*VPNChecker) Run

func (v *VPNChecker) Run(mCh chan *Measurement) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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