loadbalance

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RR round robin.
	RR = "rr"

	// Shuffle shuffle.
	Shuffle = "shuffle"

	// ConsistentHash consistent hash.
	ConsistentHash = "consistenthash"
)

Variables

This section is empty.

Functions

func SetClient

func SetClient(factory Factory)

SetClient set client to global client.

Types

type ConsistentHashLB

type ConsistentHashLB interface {
	Add(keys ...string)
	Get(key string) string
}

ConsistentHashLB consistent hash algorithm interface.

type Factory

type Factory interface {
	RR() RRLB
	Shuffle() ShuffleLB
	ConsistentHash() ConsistentHashLB
}

Factory load balance factory.

func Client

func Client() Factory

Client returns a exist client.

type RRLB

type RRLB interface {
	SwitchTo(indexes []int) (int, error)
}

RRLB rr algorithm interface.

type ShuffleLB

type ShuffleLB interface {
	SwitchTo(indexes []int) (int, error)
}

ShuffleLB shuffle algorithm interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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