pulse

package
v0.0.0-...-9c0b796 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: LGPL-3.0 Imports: 10 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownPulseType     = errors.New("specified pulse type is unknown")
	ErrInvalidPulseInterval = errors.New("pulse interval must be positive")
)

Possible validation errors.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	Check() StatusType
}

Driver provides the actual health check for Pulse.

type ID

type ID struct {
	VsID, RsID string
}

ID is a (vsID, rsID) tuple used in Pulse notifications.

func (ID) String

func (id ID) String() string

type Metrics

type Metrics struct {
	Status StatusType    `json:"status"`
	Health float64       `json:"health"`
	Uptime time.Duration `json:"uptime"`
	// contains filtered or unexported fields
}

Metrics contain statistical information about backend's Pulse.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates a new instance of metrics.

func (*Metrics) Update

func (m *Metrics) Update(status StatusType) Metrics

Update updates metrics based on Pulse status message.

type Options

type Options struct {
	Type     string          `json:"type"`
	Interval string          `json:"interval"`
	Args     util.DynamicMap `json:"args"`
	// contains filtered or unexported fields
}

Options contain Pulse configuration.

func (*Options) Validate

func (o *Options) Validate() error

Validate fills missing fields and validates Pulse configuration.

type Pulse

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

Pulse is an health check manager for a backend.

func New

func New(host string, port uint16, opts *Options) (*Pulse, error)

New creates a new Pulse from the provided endpoint and options.

func (*Pulse) Loop

func (p *Pulse) Loop(id ID, pulseCh chan Update, consumerStopCh <-chan struct{})

Loop starts the Pulse.

func (*Pulse) Stop

func (p *Pulse) Stop()

Stop stops the Pulse.

type StatusType

type StatusType int

StatusType represents the backend's Pulse status code.

const (
	// StatusUp means the backend is up and healthy.
	StatusUp StatusType = iota
	// StatusDown means the backend is not responding to Pulse.
	StatusDown
	// StatusRemoved means the backend has been removed
	StatusRemoved
)

func (StatusType) String

func (status StatusType) String() string

type Update

type Update struct {
	Source  ID
	Metrics Metrics
}

Update is a Pulse notification message.

Jump to

Keyboard shortcuts

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