ring

package
v0.0.0-...-d55b4cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ring implements a consistent hashing ring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ring

type Ring struct {
	// contains filtered or unexported fields
}

Ring implements a consistent hashing ring.

func New

func New(replicas int, nodes []string) *Ring

New creates a new consistent hash ring. replicas: Number of virtual nodes per physical node (e.g., 50-200). nodes: Optional list of initial physical nodes.

func (*Ring) Add

func (r *Ring) Add(node string)

Add adds a physical node to the ring.

func (*Ring) Get

func (r *Ring) Get(key string) string

Get returns the closest node for the given key.

func (*Ring) GetN

func (r *Ring) GetN(key string, n int) []string

GetN returns the N distinct nodes responsible for the given key (for replication).

func (*Ring) Remove

func (r *Ring) Remove(node string)

Remove removes a physical node from the ring.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL