Configurable limit for number of tracks (#197)
* configurable node track limit * sample config * todos * end of file new line * default max num tracks * bandwidth limit * client message for limit exceeded node * 10 Gbps default network limit
This commit is contained in:
@@ -8,6 +8,7 @@ var (
|
||||
ErrHandlerNotDefined = errors.New("handler not defined")
|
||||
ErrIncorrectRTCNode = errors.New("current node isn't the RTC node for the room")
|
||||
ErrNodeNotFound = errors.New("could not locate the node")
|
||||
ErrNodeLimitReached = errors.New("reached configured limit for node")
|
||||
ErrInvalidRouterMessage = errors.New("invalid router message")
|
||||
ErrChannelClosed = errors.New("channel closed")
|
||||
ErrChannelFull = errors.New("channel is full")
|
||||
|
||||
@@ -444,6 +444,7 @@ func (r *RedisRouter) handleRTCMessage(rm *livekit.RTCNodeMessage) error {
|
||||
if err := prometheus.UpdateCurrentNodeStats(r.currentNode.Stats); err != nil {
|
||||
logger.Errorw("could not update node stats", err)
|
||||
}
|
||||
// TODO: check stats against config.Limit values
|
||||
if err := r.RegisterNode(); err != nil {
|
||||
logger.Errorw("could not update node", err)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package selector
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
livekit "github.com/livekit/protocol/proto"
|
||||
"github.com/thoas/go-funk"
|
||||
)
|
||||
@@ -20,3 +21,19 @@ func GetAvailableNodes(nodes []*livekit.Node) []*livekit.Node {
|
||||
return IsAvailable(node) && node.State == livekit.NodeState_SERVING
|
||||
}).([]*livekit.Node)
|
||||
}
|
||||
|
||||
// TODO: check remote node configured limit, instead of this node's config
|
||||
func LimitsReached(limitConfig config.LimitConfig, nodeStats *livekit.NodeStats) bool {
|
||||
if nodeStats == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if limitConfig.NumTracks > 0 && limitConfig.NumTracks <= nodeStats.NumTracksIn+nodeStats.NumTracksOut {
|
||||
return true
|
||||
}
|
||||
if limitConfig.BytesPerSec > 0 && limitConfig.BytesPerSec <= nodeStats.BytesInPerSec+nodeStats.BytesOutPerSec {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user