ketama

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ketama

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

Ketama is an implementation of consistent-hash

func New

func New(opts ...Option) *Ketama

New creates a new ketama

func (*Ketama) Add

func (k *Ketama) Add(nodes ...string)

Add adds nodes to the ketama ring

func (*Ketama) Empty

func (k *Ketama) Empty() bool

Empty returns true if the ketama is empty, otherwise returns false

func (*Ketama) Get

func (k *Ketama) Get(key string) (string, bool)

Get returns the node closest to key in the clockwise direction

func (*Ketama) Remove

func (k *Ketama) Remove(nodes ...string)

Remove removes nodes from the ketama ring

type Option

type Option func(option *Options)

Option is a function type used to set Options

func WithGoroutineSafe

func WithGoroutineSafe() Option

WithGoroutineSafe is used to config a Ketama with goroutine-safe

func WithReplicas

func WithReplicas(replicas int) Option

WithReplicas is used to config the hash replicas of a Ketama

type Options

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

Options hold Ketama's options

Jump to

Keyboard shortcuts

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