Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseLoadBalancingStrategy ¶ added in v1.7.0
BaseLoadBalancingStrategy provides common logic for load balancing strategies.
func (*BaseLoadBalancingStrategy) UpdateBackends ¶ added in v1.7.0
func (b *BaseLoadBalancingStrategy) UpdateBackends(backends []*RemoteProxy)
UpdateBackends updates the list of backends in a thread-safe manner.
type ConsistentHashingStrategy ¶ added in v1.7.0
type ConsistentHashingStrategy struct {
BaseLoadBalancingStrategy
// contains filtered or unexported fields
}
ConsistentHashingStrategy implements consistent hashing load balancing.
func (*ConsistentHashingStrategy) Name ¶ added in v1.7.0
func (ch *ConsistentHashingStrategy) Name() string
Name returns the name of the strategy.
func (*ConsistentHashingStrategy) PickOne ¶ added in v1.7.0
func (ch *ConsistentHashingStrategy) PickOne(req *http.Request) *RemoteProxy
PickOne selects a backend using consistent hashing.
func (*ConsistentHashingStrategy) UpdateBackends ¶ added in v1.7.0
func (ch *ConsistentHashingStrategy) UpdateBackends(backends []*RemoteProxy)
type LoadBalancer ¶
type LoadBalancer struct {
// contains filtered or unexported fields
}
LoadBalancer is a struct that holds the load balancing strategy and backends.
func NewLoadBalancer ¶
func NewLoadBalancer( lbMode string, remoteServers []*url.URL, localCacheMgr cachemanager.CacheManager, transportMgr transport.Interface, healthChecker healthchecker.Interface, filterFinder filter.FilterFinder, stopCh <-chan struct{}) *LoadBalancer
NewLoadBalancer creates a loadbalancer for specified remote servers
func (*LoadBalancer) CurrentStrategy ¶ added in v1.7.0
func (lb *LoadBalancer) CurrentStrategy() LoadBalancingStrategy
func (*LoadBalancer) PickOne ¶ added in v1.7.0
func (lb *LoadBalancer) PickOne(req *http.Request) *RemoteProxy
func (*LoadBalancer) UpdateBackends ¶ added in v1.7.0
func (lb *LoadBalancer) UpdateBackends(remoteServers []*url.URL)
UpdateBackends dynamically updates the list of remote servers.
type LoadBalancingStrategy ¶ added in v1.7.0
type LoadBalancingStrategy interface {
Name() string
PickOne(req *http.Request) *RemoteProxy
UpdateBackends(backends []*RemoteProxy)
}
LoadBalancingStrategy defines the interface for different load balancing strategies.
type PriorityStrategy ¶ added in v1.7.0
type PriorityStrategy struct {
BaseLoadBalancingStrategy
}
PriorityStrategy implements priority-based load balancing.
func (*PriorityStrategy) Name ¶ added in v1.7.0
func (prio *PriorityStrategy) Name() string
Name returns the name of the strategy.
func (*PriorityStrategy) PickOne ¶ added in v1.7.0
func (prio *PriorityStrategy) PickOne(_ *http.Request) *RemoteProxy
PickOne selects the first available healthy backend.
type RemoteProxy ¶
type RemoteProxy struct {
// contains filtered or unexported fields
}
RemoteProxy is an reverse proxy for remote server
func NewRemoteProxy ¶
func NewRemoteProxy(remoteServer *url.URL, modifyResponse func(*http.Response) error, errhandler func(http.ResponseWriter, *http.Request, error), transportMgr transport.Interface, stopCh <-chan struct{}) (*RemoteProxy, error)
NewRemoteProxy creates an *RemoteProxy object, and will be used by LoadBalancer
func (*RemoteProxy) Name ¶
func (rp *RemoteProxy) Name() string
Name represents the address of remote server
func (*RemoteProxy) RemoteServer ¶ added in v1.1.0
func (rp *RemoteProxy) RemoteServer() *url.URL
func (*RemoteProxy) RoundTrip ¶ added in v0.6.0
RoundTrip is used to implement http.RoundTripper for RemoteProxy.
func (*RemoteProxy) ServeHTTP ¶
func (rp *RemoteProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type RoundRobinStrategy ¶ added in v1.7.0
type RoundRobinStrategy struct {
BaseLoadBalancingStrategy
// contains filtered or unexported fields
}
RoundRobinStrategy implements round-robin load balancing.
func (*RoundRobinStrategy) Name ¶ added in v1.7.0
func (rr *RoundRobinStrategy) Name() string
Name returns the name of the strategy.
func (*RoundRobinStrategy) PickOne ¶ added in v1.7.0
func (rr *RoundRobinStrategy) PickOne(_ *http.Request) *RemoteProxy
PickOne selects a backend using a round-robin approach.
type Server ¶ added in v1.7.0
type Server interface {
UpdateBackends(remoteServers []*url.URL)
PickOne(req *http.Request) *RemoteProxy
CurrentStrategy() LoadBalancingStrategy
}
Server is an interface for proxying http request to remote server based on the load balance mode(round-robin or priority)