tinylb

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// TargetGroups is a list of configs for all if this load balancer's target groups.
	TargetGroups []TargetGroupConfig `json:"target_groups"`
}

func LoadConfig

func LoadConfig(reader io.Reader) (*Config, error)

LoadConfig tries to decode a Config struct from the given reader.

type LoadBalancer

type LoadBalancer struct {
	sync.RWMutex
	Config
	// contains filtered or unexported fields
}

func Open

func Open(configPath string, log *logrus.Logger) (*LoadBalancer, error)

Open starts a new load balancer with the given config, ready to receive incoming TCP connections.

func (*LoadBalancer) Close

func (lb *LoadBalancer) Close() error

Close gracefully shuts down this load balancer, draining all load balancer target groups and shutting down the control plane server if it's running.

func (*LoadBalancer) ReloadConfig added in v0.2.1

func (lb *LoadBalancer) ReloadConfig() error

func (*LoadBalancer) UpdateConfig

func (lb *LoadBalancer) UpdateConfig(config Config) error

UpdateConfig applies the given config to this load balancer without downtime for existing or new connections.

type Target

type Target struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Target manages TCP connections to a backend server.

type TargetConfig

type TargetConfig struct {
	// The host name of the target's backend server.
	Host string
	// The port that the target's backend server expects connections on.
	Port uint
}

type TargetGroup

type TargetGroup struct {
	sync.RWMutex
	TargetGroupConfig
	// contains filtered or unexported fields
}

TargetGroup listens for incoming connections on a specific port, assigning each new connection to a healthy target from the configured group of targets. TargetGroups use consistent hashing based on the incoming connection's source address to assign connections to targets, so the same client will always be routed to the same target as long as that target is healthy and present in the target group.

type TargetGroupConfig

type TargetGroupConfig struct {
	// Name is a unique name for this target group.
	Name string
	// Port is the port on which this target group should listen for new connections.
	Port uint
	// Timeout is how long inactive connections should live.
	Timeout uint
	// Targets is a list of configs for all if this target group's targets.
	Targets []TargetConfig
}

Jump to

Keyboard shortcuts

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