A Go library that implements Consistent Hashing and Consistent Hashing With Bounded Loads.
A Go library that implements Consistent Hashing and Consistent Hashing With Bounded Loads.
A Golang implementation of Consistent Hashing and Consistent Hashing With Bounded Loads.
https://en.wikipedia.org/wiki/Consistent_hashing
https://research.googleblog.com/2017/04/consistent-hashing-with-bounded-loads.html
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 hosts in it.
host, err := c.Get("/app.html")
if err != nil {
log.Fatal(err)
}
log.Println(host)
}
…https://godoc.org/github.com/lafikl/consistent
…No open issues yet, or sync has not completed.