vc5ng

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

README

vc5ng

A library to manage load balanced services. The balancer is implemented by an interface passed to the Director, and configured with a list of services which include health check definitions.

Backend servers are added and removed from the balancer's pool by the Director according to the status of the health checks.

A BGP implementation is included and may be used to advertise healthy virtual IP address to the network.

A sample application is included which uses an XDP/eBPF load balancer implementation to provide a layer 2 Direct Server Return service.

Godoc can be found at https://pkg.go.dev/github.com/davidcoles/vc5ng

Documentation

Index

Constants

View Source
const (
	TCP = 0x06
	UDP = 0x11
)

Variables

This section is empty.

Functions

func AllVIPs added in v0.0.7

func AllVIPs(services []Service) (r []netip.Addr)

func HealthyVIPs added in v0.0.7

func HealthyVIPs(services []Service) (r []netip.Addr)

Types

type Balancer

type Balancer interface {
	Configure([]Service) error
}

type Check

type Check = mon.Check

type Destination

type Destination struct {
	Address  netip.Addr  `json:"address"`
	Port     uint16      `json:"port"`
	Disabled bool        `json:"disabled"`
	Weight   uint8       `json:"weight"`
	Status   mon.Status  `json:"status"`
	Checks   []mon.Check `json:"checks"`
}

func (*Destination) HealthyWeight

func (d *Destination) HealthyWeight() uint8

If the destination is healthy then this function returns its weight. If unhealthy or disabled, zero is returned

type Director

type Director struct {
	// A channel which may be used to receive notifications of changes in status of backend servers.
	C chan bool

	// The Balancer which will implement the services managed by this Director.
	Balancer Balancer

	// Default IP address to use for network probes (needed for SYN, should be optional).
	Address netip.Addr

	Logger log.Log
	// contains filtered or unexported fields
}

func (*Director) Configure

func (d *Director) Configure(config []Service) error

func (*Director) Start

func (d *Director) Start(cfg []Service) (err error)

func (*Director) Status

func (d *Director) Status() (services []Service)

func (*Director) Stop

func (d *Director) Stop()

type Scheduler

type Scheduler = uint8

type Service

type Service struct {
	Address      netip.Addr
	Port         uint16
	Protocol     uint8
	Scheduler    Scheduler //TODO
	Sticky       bool
	Required     uint8
	Destinations []Destination

	Up   bool
	When time.Time
	// contains filtered or unexported fields
}

func (*Service) Available

func (s *Service) Available() uint8

func (*Service) Healthy

func (s *Service) Healthy() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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