balancer

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_HSAHNODE_NUM = 1024

	CONSISTENCY_HASH_WAIT_SORT = -1
)
View Source
const (
	RANDOM_WAIT_SORT = -1
)

Variables

This section is empty.

Functions

func NewBalancerConfig

func NewBalancerConfig() *balancerConfig

func NewBalancerItem

func NewBalancerItem(addr string, wight int) balancerItem

the wight should be greater than or equal to 1. if wight == 0 , load balancing behavior does not take effect.

func NewConsistencyHashBalancer

func NewConsistencyHashBalancer(conf balancerConfig) (*consistencyHashBalancer, error)

func NewRandomBalancer

func NewRandomBalancer(conf balancerConfig) (*randomBalancer, error)

Types

type Balancer

type Balancer interface {
	// Pick well get a HostInfo interface.
	// The HostInfo contains link information.
	// param `key` valid for `consistency_hash`
	Pick(key []byte) (HostInfo, error)

	Add(conf ...balancerItem) error

	Remove(addr string) error
}

func NewBalancer

func NewBalancer(conf balancerConfig) (Balancer, error)

type BalancerTyp

type BalancerTyp string
const (
	RandomType          BalancerTyp = "random"
	P2cType             BalancerTyp = "p2c"
	ConsistencyHashType BalancerTyp = "consistency_hash"
	RangeType           BalancerTyp = "range"
)

type HostInfo

type HostInfo interface {
	GetAddr() string
	GetHost() (net.Conn, error)
}

Jump to

Keyboard shortcuts

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