snapshot of https://github.com/livekit/livekit.git @ 08c5433449c106943231037d0b892895f6e92d3b (2026-09-15)
Some checks failed
Release to Docker / docker (push) Failing after 2s
Release Test Server to Docker / docker (push) Failing after 3s
Test / test (push) Failing after 16s

This commit is contained in:
upstream-mirror
2026-09-15 16:14:22 +05:00
commit 78704103fc
422 changed files with 154805 additions and 0 deletions

44
pkg/service/egressid.go Normal file
View File

@@ -0,0 +1,44 @@
package service
import (
"context"
"strings"
"github.com/twitchtv/twirp"
"github.com/livekit/protocol/utils/guid"
)
type egressIDKey struct{}
func TwirpEgressID() *twirp.ServerHooks {
return &twirp.ServerHooks{
RequestRouted: func(ctx context.Context) (context.Context, error) {
// generate egressID for start egress methods for tracing egress failure before it reaches egress service.
if isStartEgressMethod(ctx) {
egressID := guid.New(guid.EgressPrefix)
ctx = WithEgressID(ctx, egressID)
AppendLogFields(ctx, "egressID", egressID)
}
return ctx, nil
},
}
}
func WithEgressID(ctx context.Context, egressID string) context.Context {
return context.WithValue(ctx, egressIDKey{}, egressID)
}
func EgressID(ctx context.Context) (string, bool) {
if egressID, ok := ctx.Value(egressIDKey{}).(string); ok && egressID != "" {
return egressID, true
}
return "", false
}
func isStartEgressMethod(ctx context.Context) bool {
if methodName, ok := twirp.MethodName(ctx); ok && strings.HasPrefix(methodName, "Start") && strings.HasSuffix(methodName, "Egress") {
return true
}
return false
}