balancer

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnparsableChunk     = errors.New("could not get server because of invalid chunk name")
	ErrServerUnavailable   = errors.New("rolled server is down now")
	ErrUpstreamUnavailable = errors.New("upstream is empty or undefined; balancing is not possible")
)
View Source
var GetBalancerByString = map[string]BalancerCluster{
	"cache-nodes": BalancerClusterNodes,
	"cache-cloud": BalancerClusterCloud,
}

Functions

This section is empty.

Types

type Balancer

type Balancer interface {
	BalanceByChunk(prefix, chunkname string) (_ string, server *BalancerServer, e error)
	BalanceRandom() (_ string, server *BalancerServer, e error)
	UpdateServers(servers map[string]net.IP)
	GetStats() io.Reader
	ResetStats()
	ResetUpstream()
	GetClusterName() string
}

type BalancerCluster

type BalancerCluster uint8
const (
	BalancerClusterNodes BalancerCluster = iota
	BalancerClusterCloud
)

type BalancerServer

type BalancerServer struct {
	Ip   net.IP
	Name string

	sync.RWMutex
	// contains filtered or unexported fields
}

type ClusterBalancer

type ClusterBalancer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewClusterBalancer

func NewClusterBalancer(ctx context.Context, cluster BalancerCluster) *ClusterBalancer

func (*ClusterBalancer) BalanceByChunk

func (m *ClusterBalancer) BalanceByChunk(prefix, chunkname string) (_ string, server *BalancerServer, e error)

func (*ClusterBalancer) BalanceRandom

func (m *ClusterBalancer) BalanceRandom() (_ string, server *BalancerServer, e error)

func (*ClusterBalancer) GetClusterName

func (m *ClusterBalancer) GetClusterName() string

func (*ClusterBalancer) GetStats

func (m *ClusterBalancer) GetStats() io.Reader

func (*ClusterBalancer) ResetStats

func (m *ClusterBalancer) ResetStats()

func (*ClusterBalancer) ResetUpstream

func (m *ClusterBalancer) ResetUpstream()

func (*ClusterBalancer) UpdateServers

func (m *ClusterBalancer) UpdateServers(servers map[string]net.IP)

Jump to

Keyboard shortcuts

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