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
+3 -12
View File
@@ -27,20 +27,11 @@ type SystemLoadSelector struct {
}
func (s *SystemLoadSelector) filterNodes(nodes []*livekit.Node) ([]*livekit.Node, error) {
nodes = GetAvailableNodes(nodes)
if len(nodes) == 0 {
return nil, ErrNoAvailableNodes
nodes, err := FilterNodesByCriteria(nodes, s.SysloadLimit, GetNodeSysload)
if err != nil {
return nil, err
}
nodesLowLoad := make([]*livekit.Node, 0)
for _, node := range nodes {
if GetNodeSysload(node) < s.SysloadLimit {
nodesLowLoad = append(nodesLowLoad, node)
}
}
if len(nodesLowLoad) > 0 {
nodes = nodesLowLoad
}
return nodes, nil
}