balancer

package
v1.1.1-0...-0345012 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReplicas = 10
	Salt            = "n*@if09g3n"
)
View Source
const ConsistentHash = "consistent_hash_x"
View Source
const LeastConnection = "least_connection_x"
View Source
const Random = "random_x"
View Source
const RoundRobin = "round_robin_x"

Variables

View Source
var DefaultConsistentHashKey = "consistent-hash"

Functions

func DefaultHash

func DefaultHash(data []byte) uint32

func InitConsistentHashBuilder

func InitConsistentHashBuilder(consistanceHashKey string)

Types

type HashFunc

type HashFunc func(data []byte) uint32

type Ketama

type Ketama struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewKetama

func NewKetama(replicas int, fn HashFunc) *Ketama

func (*Ketama) Add

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

func (*Ketama) Get

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

func (*Ketama) IsEmpty

func (h *Ketama) IsEmpty() bool

func (*Ketama) Remove

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

type Node

type Node struct {
	balancer.SubConn
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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