Documentation ¶
Index ¶
- func LoggerConfig(prefix string)
- type AddForm
- type LoadBalancer
- func (lb *LoadBalancer) AddServerHandler(rw http.ResponseWriter, req *http.Request)
- func (lb *LoadBalancer) CacheProps() *cache.CachingProperties
- func (lb *LoadBalancer) ClearCacheHandler(rw http.ResponseWriter, req *http.Request)
- func (lb *LoadBalancer) Config() *LoadBalancerConfig
- func (lb *LoadBalancer) GetServersHandler(rw http.ResponseWriter, req *http.Request)
- func (lb *LoadBalancer) HealthCheckFunc() func(*backend.Backend)
- func (lb *LoadBalancer) HealthChecker()
- func (lb *LoadBalancer) LoadBalancerHandler(rw http.ResponseWriter, req *http.Request)
- func (lb *LoadBalancer) Pool() *backend.ServerPool
- func (lb *LoadBalancer) RemoveServerHandler(rw http.ResponseWriter, req *http.Request)
- func (lb *LoadBalancer) SaveToCache(req *http.Request, resp *http.Response, byteArray []byte)
- type LoadBalancerConfig
- type RemoveForm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggerConfig ¶
func LoggerConfig(prefix string)
Types ¶
type AddForm ¶
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 ¶
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 (*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.