seesaw

package
v0.0.0-...-1cdf2d7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 198

Documentation

Overview

Package seesaw contains structures, interfaces and utility functions that are used by Seesaw v2 components.

Index

Constants

View Source
const (
	SeesawVersion = 2

	BinaryPath = "/usr/local/seesaw"
	ConfigPath = "/etc/seesaw"
	RunPath    = "/var/run/seesaw"
)

Variables

View Source
var (
	EngineSocket = socketPath("engine")
	NCCSocket    = socketPath("ncc")
)

Functions

func InSubnets

func InSubnets(ip net.IP, subnets map[string]*net.IPNet) bool

InSubnets reports whether an IP address is in one of a map of subnets.

func IsAnycast

func IsAnycast(ip net.IP) bool

IsAnycast reports whether an IP address is an anycast address.

Types

type AF

type AF int

AF represents a network address family.

const (
	IPv4 AF = syscall.AF_INET
	IPv6 AF = syscall.AF_INET6
)

func AFs

func AFs() []AF

AFs returns the Seesaw-supported address families.

func (AF) String

func (af AF) String() string

String returns the string representation of an AF.

type Backend

type Backend struct {
	Host
	Weight    int32
	Enabled   bool
	InService bool
}

Backend represents a backend server that can be used as a load balancing destination.

func (*Backend) Clone

func (b *Backend) Clone() *Backend

Clone creates an identical copy of the given Seesaw Backend.

func (*Backend) Copy

func (b *Backend) Copy(c *Backend)

Copy deep copies from the given Seesaw Backend.

func (*Backend) Key

func (b *Backend) Key() string

Key returns the unique identifier for a Seesaw Backend.

type BackendMap

type BackendMap struct {
	Backends map[string]*Backend
}

BackendMap provides a map of backends keyed by backend hostname.

type BackendOverride

type BackendOverride struct {
	Hostname string
	OverrideState
}

func (*BackendOverride) State

func (o *BackendOverride) State() OverrideState

func (*BackendOverride) Target

func (o *BackendOverride) Target() string

type ClusterStatus

type ClusterStatus struct {
	Version int
	Site    string
	Nodes
}

ClusterStatus specifies the status of a Seesaw cluster.

type Component

type Component int

Component identifies a particular Seesaw component.

const (
	SCNone Component = iota
	SCEngine
	SCECU
	SCHA
	SCHealthcheck
	SCLocalCLI
	SCNCC
	SCRemoteCLI
)

func (Component) String

func (sc Component) String() string

String returns the string representation of a Component.

type ConfigMetadata

type ConfigMetadata struct {
	Name  string
	Value string
}

ConfigMetadata describes part of the state of the currently-loaded config.

type ConfigStatus

type ConfigStatus struct {
	Attributes []ConfigMetadata
	LastUpdate time.Time
	Warnings   []string
}

ConfigStatus describes the status of the currently-loaded config.

type Destination

type Destination struct {
	Name        string
	VserverName string
	Weight      int32
	Stats       *DestinationStats
	Backend     *Backend
	Enabled     bool
	Healthy     bool
	Active      bool
}

Destination represents a load balancing destination.

func (*Destination) IP

func (d *Destination) IP(af AF) net.IP

IP returns the destination IP address for a given address family.

type DestinationOverride

type DestinationOverride struct {
	VserverName     string
	DestinationName string
	OverrideState
}

func (*DestinationOverride) State

func (*DestinationOverride) Target

func (o *DestinationOverride) Target() string

type DestinationStats

type DestinationStats struct {
	*ipvs.DestinationStats
}

DestinationStats contains statistics for a Destination.

type Destinations

type Destinations []*Destination

Destinations represents a list of Destination.

func (Destinations) Len

func (d Destinations) Len() int

func (Destinations) Less

func (d Destinations) Less(i, j int) bool

func (Destinations) Swap

func (d Destinations) Swap(i, j int)

type HAConfig

type HAConfig struct {
	Enabled    bool
	LocalAddr  net.IP
	RemoteAddr net.IP
	Priority   uint8
	VRID       uint8
}

HAConfig represents the high availability configuration for a node in a Seesaw cluster.

func (*HAConfig) Clone

func (h *HAConfig) Clone() *HAConfig

Clone creates an identical copy of the given Seesaw HAConfig.

func (*HAConfig) Copy

func (h *HAConfig) Copy(c *HAConfig)

Copy deep copies from the given Seesaw HAConfig.

func (*HAConfig) Equal

func (h *HAConfig) Equal(other *HAConfig) bool

Equal reports whether this HAConfig is equal to the given HAConfig.

func (HAConfig) String

func (h HAConfig) String() string

String returns the string representation of an HAConfig.

type HAStatus

type HAStatus struct {
	LastUpdate     time.Time
	State          spb.HaState
	Since          time.Time
	Sent           uint64
	Received       uint64
	ReceivedQueued uint64
	Transitions    uint64
}

HAStatus indicates the High-Availability status for a Seesaw Node.

type HealthcheckMode

type HealthcheckMode int

HealthcheckMode specifies the mode for a Healthcheck.

const (
	HCModePlain HealthcheckMode = iota
	HCModeDSR
	HCModeTUN
)

func (HealthcheckMode) String

func (h HealthcheckMode) String() string

String returns the name for a given HealthcheckMode.

type HealthcheckType

type HealthcheckType int

HealthcheckType specifies the type for a Healthcheck.

const (
	HCTypeNone HealthcheckType = iota
	HCTypeDNS
	HCTypeHTTP
	HCTypeHTTPS
	HCTypeICMP
	HCTypeRADIUS
	HCTypeTCP
	HCTypeTCPTLS
	HCTypeUDP
)

func (HealthcheckType) String

func (h HealthcheckType) String() string

String returns the name for the given HealthcheckType.

type Host

type Host struct {
	Hostname string
	IPv4Addr net.IP
	IPv4Mask net.IPMask
	IPv6Addr net.IP
	IPv6Mask net.IPMask
}

Host contains the hostname, IP addresses, and IP masks for a host.

func TestAnycastHost

func TestAnycastHost() Host

TestAnycastHost returns a Host containing the details of the test anycast service.

func (*Host) Clone

func (h *Host) Clone() *Host

Clone creates an identical copy of the given Seesaw Host.

func (*Host) Copy

func (h *Host) Copy(c *Host)

Copy deep copies from the given Seesaw Host.

func (*Host) Equal

func (h *Host) Equal(other *Host) bool

Equal returns whether two hosts are equal.

func (*Host) IPv4Net

func (h *Host) IPv4Net() *net.IPNet

IPv4Net returns a net.IPNet for the host's IPv4 address.

func (*Host) IPv4Printable

func (h *Host) IPv4Printable() string

IPv4Printable returns a printable representation of the host's IPv4 address.

func (*Host) IPv6Net

func (h *Host) IPv6Net() *net.IPNet

IPv6Net returns a net.IPNet for the host's IPv6 address.

func (*Host) IPv6Printable

func (h *Host) IPv6Printable() string

IPv6Printable returns a printable representation of the host's IPv4 address.

type IP

type IP [net.IPv6len]byte

IP specifies an IP address.

func NewIP

func NewIP(nip net.IP) IP

NewIP returns a seesaw IP initialised from a net.IP address.

func ParseIP

func ParseIP(ip string) IP

ParseIP parses the given string and returns a seesaw IP initialised with the resulting IP address.

func (IP) AF

func (ip IP) AF() AF

AF returns the address family of a seesaw IP address.

func (IP) Equal

func (ip IP) Equal(eip IP) bool

Equal returns true of the given seesaw.IP addresses are equal, as determined by net.IP.Equal().

func (IP) IP

func (ip IP) IP() net.IP

IP returns the net.IP representation of a seesaw IP address.

func (IP) String

func (ip IP) String() string

String returns the string representation of an IP address.

type IPProto

type IPProto uint16

IPProto specifies an IP protocol.

const (
	IPProtoICMP   IPProto = syscall.IPPROTO_ICMP
	IPProtoICMPv6 IPProto = syscall.IPPROTO_ICMPV6
	IPProtoTCP    IPProto = syscall.IPPROTO_TCP
	IPProtoUDP    IPProto = syscall.IPPROTO_UDP
)

func (IPProto) String

func (proto IPProto) String() string

String returns the name for the given protocol value.

type LBMode

type LBMode int

LBMode specifies the load balancing mode for a Vserver.

const (
	LBModeNone LBMode = iota
	LBModeDSR
	LBModeNAT
	LBModeTUN
)

func (LBMode) String

func (lbm LBMode) String() string

String returns the string representation of a LBMode.

type LBScheduler

type LBScheduler int

LBScheduler specifies the load balancer scheduling algorithm for a Vserver.

const (
	LBSchedulerNone LBScheduler = iota
	LBSchedulerRR
	LBSchedulerWRR
	LBSchedulerLC
	LBSchedulerWLC
	LBSchedulerSH
	LBSchedulerMH
)

func (LBScheduler) String

func (lbs LBScheduler) String() string

String returns the string representation of a LBScheduler.

type Node

type Node struct {
	Host
	Priority        uint8
	State           spb.HaState
	AnycastEnabled  bool
	BGPEnabled      bool
	VserversEnabled bool
}

Node represents a node that is part of a Seesaw cluster.

func (*Node) Clone

func (n *Node) Clone() *Node

Clone creates an identical copy of the given Seesaw Node.

func (*Node) Copy

func (n *Node) Copy(c *Node)

Copy deep copies from the given Seesaw Node.

func (*Node) Key

func (n *Node) Key() string

Key returns the unique identifier for a Seesaw Node.

type Nodes

type Nodes []*Node

Nodes represents a list of Nodes

func (Nodes) Len

func (n Nodes) Len() int

func (Nodes) Swap

func (n Nodes) Swap(i, j int)

type NodesByIPv4

type NodesByIPv4 struct{ Nodes }

NodesByIPv4 allows sorting Nodes by IPv4Addr.

func (NodesByIPv4) Less

func (n NodesByIPv4) Less(i, j int) bool

type NodesByIPv6

type NodesByIPv6 struct{ Nodes }

NodesByIPv6 allows sorting Nodes by IPv6Addr.

func (NodesByIPv6) Less

func (n NodesByIPv6) Less(i, j int) bool

type Override

type Override interface {
	Target() string
	State() OverrideState
}

type OverrideState

type OverrideState int

OverrideState specifies an override state for a vserver, backend, or destination.

const (
	OverrideDefault OverrideState = iota
	OverrideDisable
	OverrideEnable
)

func (OverrideState) String

func (o OverrideState) String() string

String returns the string representation of an OverrideState.

type Service

type Service struct {
	ServiceKey
	IP               net.IP
	Mode             LBMode
	Scheduler        LBScheduler
	OnePacket        bool
	Persistence      int
	Stats            *ServiceStats
	Destinations     map[string]*Destination // keyed by backend hostname
	Enabled          bool
	Healthy          bool
	Active           bool
	HighWatermark    float32
	LowWatermark     float32
	CurrentWatermark float32
}

Service represents a load balancing service.

type ServiceKey

type ServiceKey struct {
	AF
	Proto IPProto
	Port  uint16
}

ServiceKey provides a unique identifier for a load balancing service.

func (ServiceKey) String

func (sk ServiceKey) String() string

String returns the string representation of a ServiceKey.

type ServiceKeys

type ServiceKeys []*ServiceKey

ServiceKeys represents a list of ServiceKey.

func (ServiceKeys) Len

func (sk ServiceKeys) Len() int

func (ServiceKeys) Less

func (sk ServiceKeys) Less(i, j int) bool

func (ServiceKeys) Swap

func (sk ServiceKeys) Swap(i, j int)

type ServiceStats

type ServiceStats struct {
	*ipvs.ServiceStats
}

ServiceStats contains statistics for a Service.

type VIP

type VIP struct {
	IP
	Type VIPType
}

VIP represents a Seesaw VIP.

func NewVIP

func NewVIP(ip net.IP, vipSubnets map[string]*net.IPNet) *VIP

NewVIP returns a seesaw VIP.

func (VIP) String

func (v VIP) String() string

String returns the string representation of a VIP.

type VIPType

type VIPType int

VIPType indicates whether a VIP is in a normal, dedicated, or anycast subnet.

const (
	AnycastVIP VIPType = iota
	DedicatedVIP
	UnicastVIP
)

func (VIPType) String

func (vt VIPType) String() string

String returns the string representation of a VIPType.

type VLAN

type VLAN struct {
	ID uint16
	Host
	BackendCount map[AF]uint
	VIPCount     map[AF]uint
}

VLAN represents a VLAN interface configuration.

func (*VLAN) Equal

func (v *VLAN) Equal(other *VLAN) bool

Equal reports whether this VLAN is equal to the given VLAN.

func (*VLAN) Key

func (v *VLAN) Key() uint16

Key returns the unique identifier for a VLAN.

func (*VLAN) String

func (v *VLAN) String() string

String returns the string representation of a VLAN.

type VLANs

type VLANs struct {
	VLANs []*VLAN
}

VLANs provides a slice of VLANs.

func (VLANs) Len

func (v VLANs) Len() int

func (VLANs) Less

func (v VLANs) Less(i, j int) bool

func (VLANs) Swap

func (v VLANs) Swap(i, j int)

type Vserver

type Vserver struct {
	Name    string
	Entries []*VserverEntry
	FWM     map[AF]uint32
	Host
	Services map[ServiceKey]*Service
	OverrideState
	Enabled       bool
	ConfigEnabled bool
	Warnings      []string
}

Vserver represents a virtual server configured for load balancing.

type VserverEntry

type VserverEntry struct {
	Port          uint16
	Proto         IPProto
	Scheduler     LBScheduler
	Mode          LBMode
	Persistence   int
	OnePacket     bool
	HighWatermark float32
	LowWatermark  float32
	// TODO(angusc): Rename these:
	LThreshold int
	UThreshold int
}

VserverEntry represents a port and protocol combination for a Vserver.

type VserverMap

type VserverMap struct {
	Vservers map[string]*Vserver
}

VserverMap provides a map of vservers keyed by vserver name.

type VserverOverride

type VserverOverride struct {
	VserverName string
	OverrideState
}

func (*VserverOverride) State

func (o *VserverOverride) State() OverrideState

func (*VserverOverride) Target

func (o *VserverOverride) Target() string

Jump to

Keyboard shortcuts

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