Remove duplication within cpuload and sysload (#4818)

* Removed duplication within cpuload and sysload

* spelling fix
This commit is contained in:
Viacheslav Sergeev
2026-08-30 19:39:35 +05:30
committed by GitHub
parent c934aa29b7
commit 8b38f61fa1
3 changed files with 29 additions and 25 deletions
+5 -13
View File
@@ -27,21 +27,13 @@ type CPULoadSelector struct {
}
func (s *CPULoadSelector) filterNodes(nodes []*livekit.Node) ([]*livekit.Node, error) {
nodes = GetAvailableNodes(nodes)
if len(nodes) == 0 {
return nil, ErrNoAvailableNodes
nodes, err := FilterNodesByCriteria(nodes, s.CPULoadLimit, func(node *livekit.Node) float32 {
return node.Stats.CpuLoad
})
if err != nil {
return nil, err
}
nodesLowLoad := make([]*livekit.Node, 0)
for _, node := range nodes {
stats := node.Stats
if stats.CpuLoad < s.CPULoadLimit {
nodesLowLoad = append(nodesLowLoad, node)
}
}
if len(nodesLowLoad) > 0 {
nodes = nodesLowLoad
}
return nodes, nil
}