selector

package
v0.0.0-...-6941808 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 8 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")
	ErrSortByUnknown              = errors.New("unknown sort by option")
)
View Source
var ErrUnsupportedSelector = errors.New("unsupported node selector")

Functions

func GetAvailableNodes

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

func GetNodeSysload

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

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

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

func SelectSortedNode

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

Types

type AnySelector

type AnySelector struct {
	SortBy string
}

AnySelector selects any available node with no limitations

func (*AnySelector) SelectNode

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

type CPULoadSelector

type CPULoadSelector struct {
	CPULoadLimit float32
	SortBy       string
}

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

func (*CPULoadSelector) SelectNode

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

type NodeSelector

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

NodeSelector selects an appropriate node to run the current session

func CreateNodeSelector

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

type RegionAwareSelector

type RegionAwareSelector struct {
	SystemLoadSelector
	CurrentRegion string

	SortBy 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) (*RegionAwareSelector, error)

func (*RegionAwareSelector) SelectNode

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

type SystemLoadSelector

type SystemLoadSelector struct {
	SysloadLimit float32
	SortBy       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