From a3862f17202b383ec4bb639f0019472a9c1f9b85 Mon Sep 17 00:00:00 2001 From: Jai Luthra Date: Fri, 5 Mar 2021 01:50:02 +0530 Subject: [PATCH] core/lb: use SessionID as map index --- core/lb.go | 4 ++-- core/transcoder_test.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/lb.go b/core/lb.go index 5906eb4013..2b5a451b65 100644 --- a/core/lb.go +++ b/core/lb.go @@ -48,7 +48,7 @@ func NewLoadBalancingTranscoder(devices string, newTranscoderFn newTranscoderFn) func (lb *LoadBalancingTranscoder) Transcode(md *SegTranscodingMetadata) (*TranscodeData, error) { lb.mu.RLock() - session, exists := lb.sessions[string(md.ManifestID)] + session, exists := lb.sessions[string(md.AuthToken.SessionId)] lb.mu.RUnlock() if exists { glog.V(common.DEBUG).Info("LB: Using existing transcode session for ", session.key) @@ -67,7 +67,7 @@ func (lb *LoadBalancingTranscoder) createSession(md *SegTranscodingMetadata) (*t lb.mu.Lock() defer lb.mu.Unlock() - job := string(md.ManifestID) + job := string(md.AuthToken.SessionId) if session, exists := lb.sessions[job]; exists { glog.V(common.DEBUG).Info("Attempted to create session but already exists ", session.key) return session, nil diff --git a/core/transcoder_test.go b/core/transcoder_test.go index cb25ebb8c9..191a77ab58 100644 --- a/core/transcoder_test.go +++ b/core/transcoder_test.go @@ -6,13 +6,14 @@ import ( "testing" "github.com/livepeer/go-livepeer/common" + "github.com/livepeer/go-livepeer/net" "github.com/livepeer/lpms/ffmpeg" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func stubMetadata(sess string, profile ...ffmpeg.VideoProfile) *SegTranscodingMetadata { - return &SegTranscodingMetadata{ManifestID: ManifestID(sess), Profiles: profile} + return &SegTranscodingMetadata{AuthToken: &net.AuthToken{SessionId: sess}, Profiles: profile} } func TestLocalTranscoder(t *testing.T) {