一致性哈希的golang实现
一致性哈希背景和原理 点这里 源码实现 package consistent // import "stathat.com/c/consistent" import ( "errors" "hash/crc32" "sort" "strconv" "sync" ) type uints [] uint32 // Len returns the length of the uints array. func (x uints) Len() int { return len (x) } // Less returns true if element i is less than element j. func (x uints) Less(i, j int ) bool { return x[i] < x[j] } // Swap exchanges elements i and j. func (x uints) Swap(i, j int ) { x[i], x[j] = x[j], x[i] } // ErrEmptyCircle is the error returned when trying to get an element when nothing has been added to hash. var ErrEmptyCircle = errors.New(