Documentation ¶
Index ¶
- Variables
- type ConsistentHash
- func (ch *ConsistentHash) DecLoad(address string)
- func (ch *ConsistentHash) GetHostByKey(key string) (string, error)
- func (ch *ConsistentHash) GetHostByKeyLeast(key string) (string, error)
- func (ch *ConsistentHash) GetLoads() map[string]int64
- func (ch *ConsistentHash) IncLoad(address string)
- func (ch *ConsistentHash) MaxLoad() int64
- func (ch *ConsistentHash) RegisterHost(address string) error
- func (ch *ConsistentHash) UnregisterHost(address string) error
- type Host
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrHostAlreadyExists = errors.New("host already exists") ErrHostNotFound = errors.New("host not found") )
Functions ¶
This section is empty.
Types ¶
type ConsistentHash ¶
type ConsistentHash struct {
// contains filtered or unexported fields
}
ConsistentHash is an implementation of consistent-hashing-algorithm
func NewConsistent ¶
func NewConsistent(replicaNum int, hashFunc func(key string) uint64) *ConsistentHash
NewConsistent creates a consistent-hashing-algorithm
func (*ConsistentHash) DecLoad ¶
func (ch *ConsistentHash) DecLoad(address string)
DecLoad 递减缓存服务器的负载
func (*ConsistentHash) GetHostByKey ¶
func (ch *ConsistentHash) GetHostByKey(key string) (string, error)
GetHostByKey 根据Key查询Host
func (*ConsistentHash) GetHostByKeyLeast ¶
func (ch *ConsistentHash) GetHostByKeyLeast(key string) (string, error)
GetHostByKeyLeast 有界负载的一致性哈希
func (*ConsistentHash) GetLoads ¶
func (ch *ConsistentHash) GetLoads() map[string]int64
GetLoads 获取所有缓存服务器的负载数据
func (*ConsistentHash) IncLoad ¶
func (ch *ConsistentHash) IncLoad(address string)
IncLoad 递增缓存服务器的负载
func (*ConsistentHash) MaxLoad ¶
func (ch *ConsistentHash) MaxLoad() int64
MaxLoad 获取单节点的最大负载 (total_load / number_of_hosts) * (1 + load_bound_factor)
func (*ConsistentHash) RegisterHost ¶
func (ch *ConsistentHash) RegisterHost(address string) error
RegisterHost 注册缓存服务器
func (*ConsistentHash) UnregisterHost ¶
func (ch *ConsistentHash) UnregisterHost(address string) error
UnregisterHost 注销缓存服务器
Click to show internal directories.
Click to hide internal directories.