loadbalance

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 1 Imported by: 0

README

go-loadbalance

codecov

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aperture

type Aperture interface {
	// Next returns next selected item.
	Next() (interface{}, func(balancer.DoneInfo))
	// Set logical aperture
	SetLogicalAperture(int)
	// Set local peer id
	SetLocalPeerID(string)
	// Set local peers.
	SetLocalPeers([]string)
	// Set remote peers.
	SetRemotePeers([]interface{})
}

Aperture support map local peers to remote peers to divide remote peers into subsets to separate services into small sets and reduce the total connections

type Picker

type Picker interface {
	// Next returns next selected item.
	Next() (interface{}, func(balancer.DoneInfo))
	// Add a weighted item.
	Add(interface{}, float64)
	// Reset this picker
	Reset()
}

Picker supports multiple algorithms for load balance, uses the ideas behind the "power of 2 choices" to select two nodes from the underlying vector.

type Set

type Set interface {
	// Next returns next selected item.
	Next() (interface{}, func(balancer.DoneInfo))
	// Add a weighted item with set info.
	Add(interface{}, float64, SetInfo)
	// Reset this picker
	Reset()
}

Set supports divide remote peers into subsets based on region, zone and set info

type SetInfo

type SetInfo struct {
	// Name, app name defined as set
	Name string
	// Region, like `bj(beijing)` or `sh(shanghai)`
	Region string
	// UnitName, unit name defined as subsets
	UnitName string
}

SetInfo contains region, zone and set

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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