Update dependencies to generic versions (#1259)

This commit is contained in:
David Zhao
2022-12-26 22:29:13 -08:00
committed by GitHub
parent 51aee8f3cb
commit 988858a98a
7 changed files with 34 additions and 39 deletions
+4 -4
View File
@@ -8,7 +8,7 @@ import (
"sync"
"time"
lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/pion/rtcp"
"github.com/pion/sdp/v3"
"github.com/pion/webrtc/v3"
@@ -97,7 +97,7 @@ type ParticipantImpl struct {
isClosed atomic.Bool
state atomic.Value // livekit.ParticipantInfo_State
updateCache *lru.Cache
updateCache *lru.Cache[livekit.ParticipantID, uint32]
resSink atomic.Value // routing.MessageSink
resSinkValid atomic.Bool
grants *auth.ClaimGrants
@@ -207,7 +207,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
var err error
// keep last participants and when updates were sent
if p.updateCache, err = lru.New(128); err != nil {
if p.updateCache, err = lru.New[livekit.ParticipantID, uint32](128); err != nil {
return nil, err
}
@@ -909,7 +909,7 @@ func (p *ParticipantImpl) UpdateSubscribedTrackSettings(trackID livekit.TrackID,
}
func (p *ParticipantImpl) VerifySubscribeParticipantInfo(pID livekit.ParticipantID, version uint32) {
if v, ok := p.updateCache.Get(pID); ok && v.(uint32) >= version {
if v, ok := p.updateCache.Get(pID); ok && v >= version {
return
}
+8 -9
View File
@@ -47,18 +47,17 @@ func (p *ParticipantImpl) SendParticipantUpdate(participantsToUpdate []*livekit.
validUpdates := make([]*livekit.ParticipantInfo, 0, len(participantsToUpdate))
for _, pi := range participantsToUpdate {
isValid := true
if val, ok := p.updateCache.Get(pi.Sid); ok {
if lastVersion, ok := val.(uint32); ok {
// this is a message delivered out of order, a more recent version of the message had already been
// sent.
if pi.Version < lastVersion {
p.params.Logger.Debugw("skipping outdated participant update", "version", pi.Version, "lastVersion", lastVersion)
isValid = false
}
pID := livekit.ParticipantID(pi.Sid)
if lastVersion, ok := p.updateCache.Get(pID); ok {
// this is a message delivered out of order, a more recent version of the message had already been
// sent.
if pi.Version < lastVersion {
p.params.Logger.Debugw("skipping outdated participant update", "version", pi.Version, "lastVersion", lastVersion)
isValid = false
}
}
if isValid {
p.updateCache.Add(pi.Sid, pi.Version)
p.updateCache.Add(pID, pi.Version)
validUpdates = append(validUpdates, pi)
}
}