loadbalancer

package
v0.0.0-...-64e30f5 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 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 {
	Link   string
	Mode   Mode
	Weight weightType
}

TODO: stats of each server. TODO: support weighted mode.

type LoadBalancer

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

TODO: stats of each server. TODO: support weighted mode.

func New

func New(cfg Config) *LoadBalancer

func (*LoadBalancer) AddServer

func (lb *LoadBalancer) AddServer(srv *Server)

func (*LoadBalancer) IsEmpty

func (lb *LoadBalancer) IsEmpty() bool

func (*LoadBalancer) Rebalance

func (lb *LoadBalancer) Rebalance()

func (*LoadBalancer) RemoveServer

func (lb *LoadBalancer) RemoveServer(srv *Server)

func (*LoadBalancer) ServeHTTP

func (lb *LoadBalancer) ServeHTTP(rw http.ResponseWriter, r *http.Request)

func (*LoadBalancer) Start

func (lb *LoadBalancer) Start()

func (*LoadBalancer) Stop

func (lb *LoadBalancer) Stop()

type Mode

type Mode string
const (
	RoundRobin Mode = "roundrobin"
	LeastConn  Mode = "leastconn"
	IPHash     Mode = "iphash"
)

func (*Mode) ValidateUpdate

func (mode *Mode) ValidateUpdate() bool

type Server

type Server struct {
	Name   string
	URL    types.URL
	Weight weightType
	// contains filtered or unexported fields
}

func NewServer

func NewServer(name string, url types.URL, weight weightType, handler http.Handler) *Server

func (*Server) String

func (srv *Server) String() string

Jump to

Keyboard shortcuts

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