Integrate QueuedNotifier, fixes out-of-order delivery (#1615)
This commit is contained in:
@@ -21,11 +21,9 @@ func (t *telemetryService) NotifyEvent(ctx context.Context, event *livekit.Webho
|
||||
event.CreatedAt = time.Now().Unix()
|
||||
event.Id = utils.NewGuid("EV_")
|
||||
|
||||
t.webhookPool.Submit(func() {
|
||||
if err := t.notifier.Notify(ctx, event); err != nil {
|
||||
logger.Warnw("failed to notify webhook", err, "event", event.Event)
|
||||
}
|
||||
})
|
||||
if err := t.notifier.QueueNotify(ctx, event); err != nil {
|
||||
logger.Warnw("failed to notify webhook", err, "event", event.Event)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *telemetryService) RoomStarted(ctx context.Context, room *livekit.Room) {
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gammazero/workerpool"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
@@ -72,22 +70,20 @@ const (
|
||||
type telemetryService struct {
|
||||
AnalyticsService
|
||||
|
||||
notifier webhook.Notifier
|
||||
webhookPool *workerpool.WorkerPool
|
||||
jobsChan chan func()
|
||||
notifier webhook.QueuedNotifier
|
||||
jobsChan chan func()
|
||||
|
||||
lock sync.RWMutex
|
||||
workers map[livekit.ParticipantID]*StatsWorker
|
||||
}
|
||||
|
||||
func NewTelemetryService(notifier webhook.Notifier, analytics AnalyticsService) TelemetryService {
|
||||
func NewTelemetryService(notifier webhook.QueuedNotifier, analytics AnalyticsService) TelemetryService {
|
||||
t := &telemetryService{
|
||||
AnalyticsService: analytics,
|
||||
|
||||
notifier: notifier,
|
||||
webhookPool: workerpool.New(maxWebhookWorkers),
|
||||
jobsChan: make(chan func(), jobQueueBufferSize),
|
||||
workers: make(map[livekit.ParticipantID]*StatsWorker),
|
||||
notifier: notifier,
|
||||
jobsChan: make(chan func(), jobQueueBufferSize),
|
||||
workers: make(map[livekit.ParticipantID]*StatsWorker),
|
||||
}
|
||||
|
||||
go t.run()
|
||||
|
||||
Reference in New Issue
Block a user