cleanup room state, proper participant termination

This commit is contained in:
David Zhao
2021-01-18 23:44:59 -08:00
parent d83a1b1af3
commit 71b4673a0a
22 changed files with 374 additions and 101 deletions
+22
View File
@@ -0,0 +1,22 @@
package routing
import (
"time"
"github.com/thoas/go-funk"
"github.com/livekit/livekit-server/proto/livekit"
)
// checks if a node has been updated recently to be considered for selection
func IsAvailable(node *livekit.Node) bool {
delta := time.Now().Unix() - node.Stats.UpdatedAt
limit := statsUpdateInterval.Seconds() * 2
return float64(delta) < limit
}
func GetAvailableNodes(nodes []*livekit.Node) []*livekit.Node {
return funk.Filter(nodes, func(node *livekit.Node) bool {
return IsAvailable(node)
}).([]*livekit.Node)
}