Help us shape the future of Go! Take the 2026 Go Developer Survey

selector

package
v1.13.11 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AvailableSeconds = 5

Variables

View Source
var (
	ErrNoAvailableNodes           = errors.New("could not find any available nodes")
	ErrCurrentRegionNotSet        = errors.New("current region cannot be blank")
	ErrCurrentRegionUnknownLatLon = errors.New("unknown lat and lon for the current region")
	ErrSortByNotSet               = errors.New("sort by option cannot be blank")
	ErrAlgorithmNotSet            = errors.New("node selector algorithm option cannot be blank")
	ErrSortByUnknown              = errors.New("unknown sort by option")
	ErrAlgorithmUnknown           = errors.New("unknown node selector algorithm option")
)
View Source
var ErrUnsupportedSelector = errors.New("unsupported node selector")

Functions

func FilterNodesByCriteria added in v1.13.7

func FilterNodesByCriteria(nodes []*livekit.Node, criteriaThreshold float32, calculateCriteriaFunc func(*livekit.Node) float32) ([]*livekit.Node, error)

func GetAvailableNodes

func GetAvailableNodes(nodes []*livekit.Node) []*livekit.Node

func GetNodeSysload added in v0.15.7

func GetNodeSysload(node *livekit.Node) float32

func IsAvailable

func IsAvailable(node *livekit.Node) bool

checks if a node has been updated recently to be considered for selection

func LimitsReached added in v0.15.0

func LimitsReached(limitConfig config.LimitConfig, nodeStats *livekit.NodeStats) bool

TODO: check remote node configured limit, instead of this node's config

func SelectSortedNode added in v0.15.7

func SelectSortedNode(nodes []*livekit.Node, sortBy string, algorithm string) (*livekit.Node, error)

Types

type AnySelector added in v0.15.7

type AnySelector struct {
	SortBy    string
	Algorithm string
}

AnySelector selects any available node with no limitations

func (*AnySelector) SelectNode added in v0.15.7

func (s *AnySelector) SelectNode(nodes []*livekit.Node) (*livekit.Node, error)

type CPULoadSelector added in v0.15.6

type CPULoadSelector struct {
	CPULoadLimit float32
	SortBy       string
	Algorithm    string
}

CPULoadSelector eliminates nodes that have CPU usage higher than CPULoadLimit then selects a node from nodes that are not overloaded

func (*CPULoadSelector) SelectNode added in v0.15.6

func (s *CPULoadSelector) SelectNode(nodes []*livekit.Node) (*livekit.Node, error)

type NodeSelector added in v0.13.5

type NodeSelector interface {
	SelectNode(nodes []*livekit.Node) (*livekit.Node, error)
}

NodeSelector selects an appropriate node to run the current session

func CreateNodeSelector added in v0.13.5

func CreateNodeSelector(conf *config.Config) (NodeSelector, error)

type RegionAwareSelector

type RegionAwareSelector struct {
	SystemLoadSelector
	CurrentRegion string

	SortBy    string
	Algorithm string
	// contains filtered or unexported fields
}

RegionAwareSelector prefers available nodes that are closest to the region of the current instance

func NewRegionAwareSelector

func NewRegionAwareSelector(currentRegion string, regions []config.RegionConfig, sortBy string, algorithm string) (*RegionAwareSelector, error)

func (*RegionAwareSelector) SelectNode

func (s *RegionAwareSelector) SelectNode(nodes []*livekit.Node) (*livekit.Node, error)

type SystemLoadSelector

type SystemLoadSelector struct {
	SysloadLimit float32
	SortBy       string
	Algorithm    string
}

SystemLoadSelector eliminates nodes that surpass has a per-cpu node higher than SysloadLimit then selects a node from nodes that are not overloaded

func (*SystemLoadSelector) SelectNode

func (s *SystemLoadSelector) SelectNode(nodes []*livekit.Node) (*livekit.Node, error)

Jump to

Keyboard shortcuts

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