feat(ring-hash): add hash ring interface

This commit is contained in:
bandl 2021-10-17 13:29:56 +08:00
parent 6fdf250833
commit b54f72c575
2 changed files with 21 additions and 0 deletions

12
pkg/hash-ring/define.go Normal file
View File

@ -0,0 +1,12 @@
package hashring
type RingInterface interface {
// 获取一个 远程连接用的目标
GetTarget(key string) (*target, error)
// 获取下一个目标
NextTarget(*target) (*target, error)
// 获取上一个目标
PreTarget(*target) (*target, error)
}

9
pkg/hash-ring/load.go Normal file
View File

@ -0,0 +1,9 @@
package hashring
type target struct {
}
func (t *target) GetAddrString() string {
// TODO 获取负载机器地址
return ""
}