Documentation ¶
Index ¶
- Constants
- type ConsistentHashBanlance
- func (c *ConsistentHashBanlance) Add(params ...string) error
- func (c *ConsistentHashBanlance) Close()
- func (c *ConsistentHashBanlance) Get(key string) (string, error)
- func (c *ConsistentHashBanlance) IsEmpty() bool
- func (c *ConsistentHashBanlance) SetConf(conf LoadBalanceConf)
- func (c *ConsistentHashBanlance) Update()
- type Hash
- type LbType
- type LoadBalance
- type LoadBalanceCheckConf
- type LoadBalanceConf
- type LoadBalanceObserver
- type LoadBalanceZkConf
- type Observer
- type RandomBalance
- type RoundRobinBalance
- type UInt32Slice
- type WeightNode
- type WeightRoundRobinBalance
- func (r *WeightRoundRobinBalance) Add(params ...string) error
- func (r *WeightRoundRobinBalance) Close()
- func (r *WeightRoundRobinBalance) Get(key string) (string, error)
- func (r *WeightRoundRobinBalance) Next() string
- func (r *WeightRoundRobinBalance) SetConf(conf LoadBalanceConf)
- func (r *WeightRoundRobinBalance) Update()
Constants ¶
View Source
const ( //default check setting DefaultCheckMethod = 0 DefaultCheckTimeout = 2 DefaultCheckMaxErrNum = 2 DefaultCheckInterval = 5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsistentHashBanlance ¶
type ConsistentHashBanlance struct {
// contains filtered or unexported fields
}
func NewConsistentHashBanlance ¶
func NewConsistentHashBanlance(replicas int, fn Hash) *ConsistentHashBanlance
func (*ConsistentHashBanlance) Add ¶
func (c *ConsistentHashBanlance) Add(params ...string) error
Add 方法用来添加缓存节点,参数为节点key,比如使用IP
func (*ConsistentHashBanlance) Close ¶
func (c *ConsistentHashBanlance) Close()
func (*ConsistentHashBanlance) Get ¶
func (c *ConsistentHashBanlance) Get(key string) (string, error)
Get 方法根据给定的对象获取最靠近它的那个节点
func (*ConsistentHashBanlance) IsEmpty ¶
func (c *ConsistentHashBanlance) IsEmpty() bool
IsEmpty 验证是否为空
func (*ConsistentHashBanlance) SetConf ¶
func (c *ConsistentHashBanlance) SetConf(conf LoadBalanceConf)
func (*ConsistentHashBanlance) Update ¶
func (c *ConsistentHashBanlance) Update()
type LoadBalance ¶
type LoadBalance interface { Add(...string) error Get(string) (string, error) //后期服务发现补充 Update() Close() }
func LoadBanlanceFactorWithConf ¶
func LoadBanlanceFactorWithConf(lbType LbType, mConf LoadBalanceConf) LoadBalance
func LoadBanlanceFactory ¶
func LoadBanlanceFactory(lbType LbType) LoadBalance
type LoadBalanceCheckConf ¶
type LoadBalanceCheckConf struct {
// contains filtered or unexported fields
}
func NewLoadBalanceCheckConf ¶
func NewLoadBalanceCheckConf(name, format string, conf map[string]string) (*LoadBalanceCheckConf, error)
func (*LoadBalanceCheckConf) Attach ¶
func (s *LoadBalanceCheckConf) Attach(o Observer)
func (*LoadBalanceCheckConf) CloseWatch ¶
func (s *LoadBalanceCheckConf) CloseWatch()
func (*LoadBalanceCheckConf) GetConf ¶
func (s *LoadBalanceCheckConf) GetConf() []string
func (*LoadBalanceCheckConf) NotifyAllObservers ¶
func (s *LoadBalanceCheckConf) NotifyAllObservers()
func (*LoadBalanceCheckConf) UpdateConf ¶
func (s *LoadBalanceCheckConf) UpdateConf(conf []string)
UpdateConf 更新配置时,通知监听者也更新
func (*LoadBalanceCheckConf) WatchConf ¶
func (s *LoadBalanceCheckConf) WatchConf()
WatchConf 更新配置时,通知监听者也更新
type LoadBalanceConf ¶
type LoadBalanceConf interface { Attach(o Observer) GetConf() []string WatchConf() UpdateConf(conf []string) CloseWatch() }
LoadBalanceConf 配置主题
type LoadBalanceObserver ¶
type LoadBalanceObserver struct {
ModuleConf *LoadBalanceZkConf
}
func NewLoadBalanceObserver ¶
func NewLoadBalanceObserver(conf *LoadBalanceZkConf) *LoadBalanceObserver
func (*LoadBalanceObserver) Update ¶
func (l *LoadBalanceObserver) Update()
type LoadBalanceZkConf ¶
type LoadBalanceZkConf struct {
// contains filtered or unexported fields
}
func NewLoadBalanceZkConf ¶
func (*LoadBalanceZkConf) Attach ¶
func (s *LoadBalanceZkConf) Attach(o Observer)
func (*LoadBalanceZkConf) CloseWatch ¶
func (s *LoadBalanceZkConf) CloseWatch()
func (*LoadBalanceZkConf) GetConf ¶
func (s *LoadBalanceZkConf) GetConf() []string
func (*LoadBalanceZkConf) NotifyAllObservers ¶
func (s *LoadBalanceZkConf) NotifyAllObservers()
func (*LoadBalanceZkConf) UpdateConf ¶
func (s *LoadBalanceZkConf) UpdateConf(conf []string)
UpdateConf 更新配置时,通知监听者也更新
func (*LoadBalanceZkConf) WatchConf ¶
func (s *LoadBalanceZkConf) WatchConf()
WatchConf 更新配置时,通知监听者也更新
type RandomBalance ¶
type RandomBalance struct {
// contains filtered or unexported fields
}
func (*RandomBalance) Add ¶
func (r *RandomBalance) Add(params ...string) error
func (*RandomBalance) Close ¶
func (r *RandomBalance) Close()
func (*RandomBalance) Next ¶
func (r *RandomBalance) Next() string
func (*RandomBalance) SetConf ¶
func (r *RandomBalance) SetConf(conf LoadBalanceConf)
func (*RandomBalance) Update ¶
func (r *RandomBalance) Update()
type RoundRobinBalance ¶
type RoundRobinBalance struct {
// contains filtered or unexported fields
}
func (*RoundRobinBalance) Add ¶
func (r *RoundRobinBalance) Add(params ...string) error
func (*RoundRobinBalance) Close ¶
func (r *RoundRobinBalance) Close()
func (*RoundRobinBalance) Next ¶
func (r *RoundRobinBalance) Next() string
func (*RoundRobinBalance) SetConf ¶
func (r *RoundRobinBalance) SetConf(conf LoadBalanceConf)
func (*RoundRobinBalance) Update ¶
func (r *RoundRobinBalance) Update()
type UInt32Slice ¶
type UInt32Slice []uint32
func (UInt32Slice) Len ¶
func (s UInt32Slice) Len() int
func (UInt32Slice) Less ¶
func (s UInt32Slice) Less(i, j int) bool
func (UInt32Slice) Swap ¶
func (s UInt32Slice) Swap(i, j int)
type WeightNode ¶
type WeightNode struct {
// contains filtered or unexported fields
}
type WeightRoundRobinBalance ¶
type WeightRoundRobinBalance struct {
// contains filtered or unexported fields
}
func (*WeightRoundRobinBalance) Add ¶
func (r *WeightRoundRobinBalance) Add(params ...string) error
func (*WeightRoundRobinBalance) Close ¶
func (r *WeightRoundRobinBalance) Close()
func (*WeightRoundRobinBalance) Get ¶
func (r *WeightRoundRobinBalance) Get(key string) (string, error)
func (*WeightRoundRobinBalance) Next ¶
func (r *WeightRoundRobinBalance) Next() string
func (*WeightRoundRobinBalance) SetConf ¶
func (r *WeightRoundRobinBalance) SetConf(conf LoadBalanceConf)
func (*WeightRoundRobinBalance) Update ¶
func (r *WeightRoundRobinBalance) Update()
Click to show internal directories.
Click to hide internal directories.