Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HashingBalancer ¶
type HashingBalancer struct {
// contains filtered or unexported fields
}
HashingBalancer implements a consistent hashing balancer using the consistent package.
func NewBalancer ¶
func NewBalancer(proxies []proxy.Proxy, hashon string, replicas int) *HashingBalancer
NewBalancer creates a new HashingBalancer instance. It uses the consistent hashing package for better distribution and performance. Each proxy's virtual nodes are scaled by its Weight() to achieve weight-based distribution.
func (*HashingBalancer) Proxies ¶
func (b *HashingBalancer) Proxies() []proxy.Proxy
Proxies returns the list of proxies managed by the balancer.
func (*HashingBalancer) Select ¶
func (b *HashingBalancer) Select(ctx context.Context, c *app.RequestContext) (proxy.Proxy, error)
Select picks a proxy from the hash ring based on a hashed value from the request. If the selected proxy is unavailable, it tries the next nodes on the ring.
Click to show internal directories.
Click to hide internal directories.