Region aware routing (#135)

* Region aware routing

* update config, fix spacing on commented out lines
This commit is contained in:
David Zhao
2021-10-06 21:40:04 -07:00
committed by GitHub
parent b0eca12ee8
commit c745f0a318
22 changed files with 406 additions and 113 deletions
+20
View File
@@ -0,0 +1,20 @@
package selector
import (
livekit "github.com/livekit/protocol/proto"
"github.com/thoas/go-funk"
)
// RandomSelector selects an available node at random
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
}