Region aware routing (#135)
* Region aware routing * update config, fix spacing on commented out lines
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user