Documentation ¶
Index ¶
- Constants
- type Comparable
- type Ring
- func (r *Ring[K]) Add(position int, node K) any
- func (r *Ring[K]) All() []K
- func (r *Ring[K]) Contains(node K) bool
- func (r *Ring[K]) Get(position int) K
- func (r *Ring[K]) GetNextN(position int, n int) []K
- func (r *Ring[K]) GetUniqueHashes() map[string]K
- func (r *Ring[K]) GetUniques() map[K][]uint32
- func (r *Ring[K]) Remove(node K) []int
Constants ¶
View Source
const Size = 256
Size indicates the exact number of virtual-nodes on the ring.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparable ¶
type Comparable interface { comparable Hash() string }
type Ring ¶
type Ring[K Comparable] struct { sync.Mutex // contains filtered or unexported fields }
func NewRing ¶
func NewRing[K Comparable]() *Ring[K]
func (*Ring[K]) Add ¶
Add a new node to the ring on the specified position. If a node with the same position is already exists, replace it then return the old node.
func (*Ring[K]) All ¶
func (r *Ring[K]) All() []K
All returns virtual nodes on the ring sorted by their index (from 0 to 255)
func (*Ring[K]) GetNextN ¶
GetNextN returns n clockwise nodes starting from position on the ring. does not return error if it cannot find n nodes
func (*Ring[K]) GetUniqueHashes ¶
func (*Ring[K]) GetUniques ¶
GetUniques returns all the unique values stored on the ring
Click to show internal directories.
Click to hide internal directories.