De-centralize some configs to where they are used. (#3162)

* De-centralize some configs to where they are used.

And make default variables.

Renaming a bit, but these are all internal config and have not been
added to documented config.

* Keep documented config as is.

* test

* typo
This commit is contained in:
Raja Subramanian
2024-11-08 12:47:30 +05:30
committed by GitHub
parent 55d084fd18
commit 86383b2271
20 changed files with 426 additions and 327 deletions
+3 -2
View File
@@ -21,7 +21,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/utils/hwstats"
@@ -29,6 +28,8 @@ import (
const (
livekitNamespace string = "livekit"
statsUpdateInterval = time.Second * 10
)
var (
@@ -183,7 +184,7 @@ func GetUpdatedNodeStats(prev *livekit.NodeStats, prevAverage *livekit.NodeStats
updatedAt := time.Now().Unix()
elapsed := updatedAt - prevAverage.UpdatedAt
// include sufficient buffer to be sure a stats update had taken place
computeAverage := elapsed > int64(config.StatsUpdateInterval.Seconds()+2)
computeAverage := elapsed > int64(statsUpdateInterval.Seconds()+2)
if bytesInNow != prevAverage.BytesIn ||
bytesOutNow != prevAverage.BytesOut ||
packetsInNow != prevAverage.PacketsIn ||
+1 -2
View File
@@ -23,7 +23,6 @@ import (
"github.com/frostbyte73/core"
"go.uber.org/atomic"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
)
@@ -122,7 +121,7 @@ func (s *BytesTrackStats) report() {
}
func (s *BytesTrackStats) reporter() {
ticker := time.NewTicker(config.TelemetryNonMediaStatsUpdateInterval)
ticker := time.NewTicker(telemetryNonMediaStatsUpdateInterval)
defer func() {
ticker.Stop()
s.report()
+4 -2
View File
@@ -19,7 +19,6 @@ import (
"sync"
"time"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/utils"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
@@ -87,6 +86,9 @@ type TelemetryService interface {
const (
workerCleanupWait = 3 * time.Minute
jobsQueueMinSize = 2048
telemetryStatsUpdateInterval = time.Second * 30
telemetryNonMediaStatsUpdateInterval = time.Minute * 5
)
type telemetryService struct {
@@ -172,7 +174,7 @@ func (t *telemetryService) FlushStats() {
}
func (t *telemetryService) run() {
for range time.Tick(config.TelemetryStatsUpdateInterval) {
for range time.Tick(telemetryStatsUpdateInterval) {
t.FlushStats()
}
}