lb

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggerConfig

func LoggerConfig(prefix string)

Types

type AddForm

type AddForm struct {
	Url                   string
	HealthCheckTcpTimeout int
	MaximalRequests       int
}

AddForm is a structure which is parsed from a POST-request processed by AddServerHandler.

type LoadBalancer

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

LoadBalancer is a struct that contains all the configuration of the load balancer.

func NewLoadBalancer

func NewLoadBalancer(
	config *LoadBalancerConfig,
	cachingProperties *cache.CachingProperties,
	healthChecker func(*backend.Backend),
) *LoadBalancer

NewLoadBalancer is the constructor of the load balancer.

func NewLoadBalancerWithPool

func NewLoadBalancerWithPool(
	config *LoadBalancerConfig,
	cachingProperties *cache.CachingProperties,
	healthChecker func(*backend.Backend),
	servers []config.ServerConfig,
) *LoadBalancer

func (*LoadBalancer) AddServerHandler

func (lb *LoadBalancer) AddServerHandler(rw http.ResponseWriter, req *http.Request)

AddServerHandler handles adding a new backend into the server pool of the LoadBalancer.

func (*LoadBalancer) CacheProps

func (lb *LoadBalancer) CacheProps() *cache.CachingProperties

func (*LoadBalancer) ClearCacheHandler

func (lb *LoadBalancer) ClearCacheHandler(rw http.ResponseWriter, req *http.Request)

func (*LoadBalancer) Config

func (lb *LoadBalancer) Config() *LoadBalancerConfig

func (*LoadBalancer) GetServersHandler

func (lb *LoadBalancer) GetServersHandler(rw http.ResponseWriter, req *http.Request)

GetServersHandler takes all the information about the backends from the server pool and puts an HTML page to http.ResponseWriter with the info in <table>...</table> tags.

func (*LoadBalancer) HealthCheckFunc

func (lb *LoadBalancer) HealthCheckFunc() func(*backend.Backend)

func (*LoadBalancer) HealthChecker

func (lb *LoadBalancer) HealthChecker()

HealthChecker periodically checks all the backends in balancer pool.

func (*LoadBalancer) LoadBalancerHandler

func (lb *LoadBalancer) LoadBalancerHandler(rw http.ResponseWriter, req *http.Request)

LoadBalancerHandler is the main handler for load balancer.

func (*LoadBalancer) Pool

func (lb *LoadBalancer) Pool() *backend.ServerPool

func (*LoadBalancer) RemoveServerHandler

func (lb *LoadBalancer) RemoveServerHandler(rw http.ResponseWriter, req *http.Request)

RemoveServerHandler handles removing a backend from the server pool of the LoadBalancer.

func (*LoadBalancer) SaveToCache

func (lb *LoadBalancer) SaveToCache(req *http.Request, resp *http.Response, byteArray []byte)

SaveToCache takes all the necessary information about a response and saves it in cache.

type LoadBalancerConfig

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

LoadBalancerConfig is parse from `config.json` file. It contains all the necessary information of the load balancer.

func NewLoadBalancerConfig

func NewLoadBalancerConfig(
	port int,
	healthCheckPeriod time.Duration,
	maxCacheSize int64,
	observeFrequency time.Duration,
) *LoadBalancerConfig

func (*LoadBalancerConfig) HealthCheckPeriod

func (c *LoadBalancerConfig) HealthCheckPeriod() time.Duration

func (*LoadBalancerConfig) MaxCacheSize

func (c *LoadBalancerConfig) MaxCacheSize() int64

func (*LoadBalancerConfig) ObserveFrequency

func (c *LoadBalancerConfig) ObserveFrequency() time.Duration

func (*LoadBalancerConfig) Port

func (c *LoadBalancerConfig) Port() int

type RemoveForm

type RemoveForm struct {
	Url string
}

RemoveForm is a structure which is parsed from a POST-request processed by RemoveServerHandlerRemoveServer.

Jump to

Keyboard shortcuts

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