consistent:一个Go库,该库实现一致性哈希和有界负载的一致性哈希
包装一致
一致性哈希和有界负载的一致性哈希的Golang实现。
一致的哈希示例
package main
import (
"log"
"github.com/lafikl/consistent"
)
func main () {
c := consistent . New ()
// adds the hosts to the ring
c . Add ( "127.0.0.1:8000" )
c . Add ( "92.0.0.1:8000" )
// Returns the host that owns `key`.
//
// As described in https://en.wikipedia.org/wiki/Consistent_hashing
//
// It returns ErrNoHosts if the ring has no host