Documentation ¶
Index ¶
- Constants
- func NewBalancerConfig() *balancerConfig
- func NewBalancerItem(addr string, wight int) balancerItem
- func NewConsistencyHashBalancer(conf balancerConfig) (*consistencyHashBalancer, error)
- func NewRandomBalancer(conf balancerConfig) (*randomBalancer, error)
- type Balancer
- type BalancerTyp
- type HostInfo
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 ¶
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 ¶
type BalancerTyp ¶
type BalancerTyp string
const ( RandomType BalancerTyp = "random" P2cType BalancerTyp = "p2c" ConsistencyHashType BalancerTyp = "consistency_hash" RangeType BalancerTyp = "range" )
Click to show internal directories.
Click to hide internal directories.