loadbalancer

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 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 ConsistentHash

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

func NewConsistentHash

func NewConsistentHash(replicas int) *ConsistentHash

func (*ConsistentHash) Add

func (c *ConsistentHash) Add(node string)

Add 添加一个节点到哈希环

func (*ConsistentHash) Get

func (c *ConsistentHash) Get(key string) string

Get 返回给定 key 所在的节点

func (*ConsistentHash) Remove

func (c *ConsistentHash) Remove(node string)

Remove 从哈希环中移除一个节点

type RoundRobin

type RoundRobin[Id comparable, T RoundRobinItem[Id]] struct {
	// contains filtered or unexported fields
}

func NewRoundRobin

func NewRoundRobin[Id comparable, T RoundRobinItem[Id]]() *RoundRobin[Id, T]

func (*RoundRobin[Id, T]) Add

func (r *RoundRobin[Id, T]) Add(t T)

func (*RoundRobin[Id, T]) Next

func (r *RoundRobin[Id, T]) Next() (t T)

func (*RoundRobin[Id, T]) Refresh

func (r *RoundRobin[Id, T]) Refresh()

func (*RoundRobin[Id, T]) Remove

func (r *RoundRobin[Id, T]) Remove(t T)

type RoundRobinItem

type RoundRobinItem[Id comparable] interface {
	// GetId 返回唯一标识
	GetId() Id
}

Jump to

Keyboard shortcuts

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