NodeSelector using system load metric (#94)

* use load when selecting nodes

* Apply suggestions from code review

Co-authored-by: David Zhao <david@davidzhao.com>

* sysload selector test

* wire nodeSelectorFromConfig

* fix tests

* Update pkg/routing/selectorsystemload_test.go

Co-authored-by: David Zhao <david@davidzhao.com>

* dz review: nits

Co-authored-by: David Zhao <david@davidzhao.com>
This commit is contained in:
Mathew Kamkar
2021-08-26 15:24:39 -07:00
committed by GitHub
co-authored by David Zhao
parent 0a9d12bc35
commit c437152e2b
12 changed files with 140 additions and 21 deletions
+19
View File
@@ -0,0 +1,19 @@
package routing
import (
livekit "github.com/livekit/livekit-server/proto"
"github.com/thoas/go-funk"
)
type RandomSelector struct {
}
func (s *RandomSelector) SelectNode(nodes []*livekit.Node, room *livekit.Room) (*livekit.Node, error) {
nodes = GetAvailableNodes(nodes)
if len(nodes) == 0 {
return nil, ErrNoAvailableNodes
}
idx := funk.RandomInt(0, len(nodes))
return nodes[idx], nil
}