update protocol (#2760)

* update protocol

* deps
This commit is contained in:
Paul Wells
2024-06-05 19:46:34 -07:00
committed by GitHub
parent d3f9e8b8e5
commit f1886ece42
22 changed files with 53 additions and 38 deletions
+2 -1
View File
@@ -28,6 +28,7 @@ import (
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
@@ -35,7 +36,7 @@ import (
)
func generateKeys(_ *cli.Context) error {
apiKey := utils.NewGuid(utils.APIKeyPrefix)
apiKey := guid.New(utils.APIKeyPrefix)
secret := utils.RandomSecret()
fmt.Println("API Key: ", apiKey)
fmt.Println("API Secret: ", secret)
+1 -1
View File
@@ -20,7 +20,7 @@ require (
github.com/jxskiss/base62 v1.1.0
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
github.com/livekit/mediatransportutil v0.0.0-20240501132628-6105557bbb9a
github.com/livekit/protocol v1.17.0
github.com/livekit/protocol v1.17.1-0.20240606023900-429fec77a69b
github.com/livekit/psrpc v0.5.3-0.20240526192918-fbdaf10e6aa5
github.com/mackerelio/go-osstat v0.2.4
github.com/magefile/mage v1.15.0
+2 -2
View File
@@ -120,8 +120,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20240501132628-6105557bbb9a h1:ATbv0x7G5tW2HgiouQ57csFE/G4gekl2oV1cxb2Dy24=
github.com/livekit/mediatransportutil v0.0.0-20240501132628-6105557bbb9a/go.mod h1:jwKUCmObuiEDH0iiuJHaGMXwRs3RjrB4G6qqgkr/5oE=
github.com/livekit/protocol v1.17.0 h1:E8t9kssblb1MVEYTPF0R65lFqN4pEr4SOcnlbcI3ehc=
github.com/livekit/protocol v1.17.0/go.mod h1:cN8WmGQR+kWz1+UWcAQdFFUcbW76PnfZDdkLAbYIqd4=
github.com/livekit/protocol v1.17.1-0.20240606023900-429fec77a69b h1:VZMvqc23x/dXRpJQLc6CIkCuLUjev0HDLFO9NCEqfOk=
github.com/livekit/protocol v1.17.1-0.20240606023900-429fec77a69b/go.mod h1:cN8WmGQR+kWz1+UWcAQdFFUcbW76PnfZDdkLAbYIqd4=
github.com/livekit/psrpc v0.5.3-0.20240526192918-fbdaf10e6aa5 h1:mTZyrjk5WEWMsvaYtJ42pG7DuxysKj21DKPINpGSIto=
github.com/livekit/psrpc v0.5.3-0.20240526192918-fbdaf10e6aa5/go.mod h1:CQUBSPfYYAaevg1TNCc6/aYsa8DJH4jSRFdCeSZk5u0=
github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs=
+2 -1
View File
@@ -27,6 +27,7 @@ import (
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/psrpc"
)
@@ -121,7 +122,7 @@ func (c *agentClient) LaunchJob(ctx context.Context, desc *JobDescription) {
target.ForEach(func(ns string) {
c.workers.Submit(func() {
_, err := c.client.JobRequest(ctx, ns, jobTypeTopic, &livekit.Job{
Id: utils.NewGuid(utils.AgentJobPrefix),
Id: guid.New(utils.AgentJobPrefix),
Type: desc.JobType,
Room: desc.Room,
Participant: desc.Participant,
+2 -1
View File
@@ -28,6 +28,7 @@ import (
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
putil "github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
)
type WorkerProtocolVersion int
@@ -353,7 +354,7 @@ func (w *Worker) handleSimulateJob(simulate *livekit.SimulateJobRequest) {
}
job := &livekit.Job{
Id: utils.NewGuid(utils.AgentJobPrefix),
Id: guid.New(utils.AgentJobPrefix),
Type: jobType,
Room: simulate.Room,
Participant: simulate.Participant,
+2 -1
View File
@@ -20,6 +20,7 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/pkg/config"
)
@@ -27,7 +28,7 @@ import (
type LocalNode *livekit.Node
func NewLocalNode(conf *config.Config) (LocalNode, error) {
nodeID := utils.NewGuid(utils.NodePrefix)
nodeID := guid.New(utils.NodePrefix)
if conf.RTC.NodeIP == "" {
return nil, ErrIPNotSet
}
+2 -1
View File
@@ -22,6 +22,7 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing/selector"
@@ -152,7 +153,7 @@ func newTestNodeInRegion(region string, available bool) *livekit.Node {
load = 1.0
}
return &livekit.Node{
Id: utils.NewGuid(utils.NodePrefix),
Id: guid.New(utils.NodePrefix),
Region: region,
State: livekit.NodeState_SERVING,
Stats: &livekit.NodeStats{
+2 -2
View File
@@ -28,7 +28,7 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/psrpc"
"github.com/livekit/psrpc/pkg/middleware"
)
@@ -84,7 +84,7 @@ func (r *signalClient) StartParticipantSignal(
resSource MessageSource,
err error,
) {
connectionID = livekit.ConnectionID(utils.NewGuid("CO_"))
connectionID = livekit.ConnectionID(guid.New("CO_"))
ss, err := pi.ToStartSession(roomName, connectionID)
if err != nil {
return
+2 -1
View File
@@ -38,6 +38,7 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
@@ -2297,7 +2298,7 @@ func (p *ParticipantImpl) setStableTrackID(cid string, info *livekit.TrackInfo)
case livekit.TrackSource_SCREEN_SHARE_AUDIO:
trackPrefix += "s"
}
trackID = utils.NewGuid(trackPrefix)
trackID = guid.New(trackPrefix)
}
info.Sid = trackID
}
+2 -1
View File
@@ -31,6 +31,7 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
@@ -749,7 +750,7 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p
FmtpLine: c.FmtpLine,
})
}
sid := livekit.ParticipantID(utils.NewGuid(utils.ParticipantPrefix))
sid := livekit.ParticipantID(guid.New(utils.ParticipantPrefix))
p, _ := NewParticipant(ParticipantParams{
SID: sid,
Identity: identity,
+3 -2
View File
@@ -18,6 +18,7 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/rtc/types/typesfakes"
@@ -25,7 +26,7 @@ import (
func NewMockParticipant(identity livekit.ParticipantIdentity, protocol types.ProtocolVersion, hidden bool, publisher bool) *typesfakes.FakeLocalParticipant {
p := &typesfakes.FakeLocalParticipant{}
sid := utils.NewGuid(utils.ParticipantPrefix)
sid := guid.New(utils.ParticipantPrefix)
p.IDReturns(livekit.ParticipantID(sid))
p.IdentityReturns(identity)
p.StateReturns(livekit.ParticipantInfo_JOINED)
@@ -80,7 +81,7 @@ func NewMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro
func NewMockTrack(kind livekit.TrackType, name string) *typesfakes.FakeMediaTrack {
t := &typesfakes.FakeMediaTrack{}
t.IDReturns(livekit.TrackID(utils.NewGuid(utils.TrackPrefix)))
t.IDReturns(livekit.TrackID(guid.New(utils.TrackPrefix)))
t.KindReturns(kind)
t.NameReturns(name)
t.ToProtoReturns(&livekit.TrackInfo{
+2 -1
View File
@@ -24,6 +24,7 @@ import (
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
)
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
@@ -73,7 +74,7 @@ func (s *egressLauncher) StartEgressWithClusterId(ctx context.Context, clusterId
// Ensure we have an Egress ID
if req.EgressId == "" {
req.EgressId = utils.NewGuid(utils.EgressPrefix)
req.EgressId = guid.New(utils.EgressPrefix)
}
return s.client.StartEgress(ctx, clusterId, req)
+3 -2
View File
@@ -26,6 +26,7 @@ import (
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/psrpc"
)
@@ -145,11 +146,11 @@ func (s *IngressService) CreateIngressWithUrl(ctx context.Context, urlStr string
var sk string
if req.InputType != livekit.IngressInput_URL_INPUT {
sk = utils.NewGuid("")
sk = guid.New("")
}
info := &livekit.IngressInfo{
IngressId: utils.NewGuid(utils.IngressPrefix),
IngressId: guid.New(utils.IngressPrefix),
Name: req.Name,
StreamKey: sk,
Url: urlStr,
+2 -2
View File
@@ -29,7 +29,7 @@ import (
"github.com/livekit/protocol/ingress"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/version"
)
@@ -240,7 +240,7 @@ func (s *RedisStore) DeleteRoom(ctx context.Context, roomName livekit.RoomName)
}
func (s *RedisStore) LockRoom(_ context.Context, roomName livekit.RoomName, duration time.Duration) (string, error) {
token := utils.NewGuid("LOCK")
token := guid.New("LOCK")
key := RoomLockPrefix + string(roomName)
startTime := time.Now()
+5 -4
View File
@@ -26,6 +26,7 @@ import (
"github.com/livekit/protocol/ingress"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/pkg/service"
)
@@ -164,8 +165,8 @@ func TestEgressStore(t *testing.T) {
// store egress info
info := &livekit.EgressInfo{
EgressId: utils.NewGuid(utils.EgressPrefix),
RoomId: utils.NewGuid(utils.RoomPrefix),
EgressId: guid.New(utils.EgressPrefix),
RoomId: guid.New(utils.RoomPrefix),
RoomName: roomName,
Status: livekit.EgressStatus_EGRESS_STARTING,
Request: &livekit.EgressInfo_RoomComposite{
@@ -184,8 +185,8 @@ func TestEgressStore(t *testing.T) {
// store another
info2 := &livekit.EgressInfo{
EgressId: utils.NewGuid(utils.EgressPrefix),
RoomId: utils.NewGuid(utils.RoomPrefix),
EgressId: guid.New(utils.EgressPrefix),
RoomId: guid.New(utils.RoomPrefix),
RoomName: "another-egress-test",
Status: livekit.EgressStatus_EGRESS_STARTING,
Request: &livekit.EgressInfo_RoomComposite{
+2 -1
View File
@@ -22,6 +22,7 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
@@ -66,7 +67,7 @@ func (r *StandardRoomAllocator) CreateRoom(ctx context.Context, req *livekit.Cre
if errors.Is(err, ErrRoomNotFound) {
created = true
rm = &livekit.Room{
Sid: utils.NewGuid(utils.RoomPrefix),
Sid: guid.New(utils.RoomPrefix),
Name: req.Name,
CreationTime: time.Now().Unix(),
TurnPassword: utils.RandomSecret(),
+2 -1
View File
@@ -33,6 +33,7 @@ import (
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/protocol/utils/must"
"github.com/livekit/psrpc"
@@ -378,7 +379,7 @@ func (r *RoomManager) StartSession(
pv := types.ProtocolVersion(pi.Client.Protocol)
rtcConf := *r.rtcConfig
rtcConf.SetBufferFactory(room.GetBufferFactory())
sid := livekit.ParticipantID(utils.NewGuid(utils.ParticipantPrefix))
sid := livekit.ParticipantID(guid.New(utils.ParticipantPrefix))
pLogger := rtc.LoggerWithParticipant(
rtc.LoggerWithRoom(logger.GetLogger(), room.Name(), room.ID()),
pi.Identity,
+3 -2
View File
@@ -24,6 +24,7 @@ import (
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/sip"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/psrpc"
"github.com/livekit/livekit-server/pkg/config"
@@ -91,7 +92,7 @@ func (s *SIPService) CreateSIPTrunk(ctx context.Context, req *livekit.CreateSIPT
}
// Now we can generate ID and store.
info.SipTrunkId = utils.NewGuid(utils.SIPTrunkPrefix)
info.SipTrunkId = guid.New(utils.SIPTrunkPrefix)
if err := s.store.StoreSIPTrunk(ctx, info); err != nil {
return nil, err
}
@@ -153,7 +154,7 @@ func (s *SIPService) CreateSIPDispatchRule(ctx context.Context, req *livekit.Cre
}
// Now we can generate ID and store.
info.SipDispatchRuleId = utils.NewGuid(utils.SIPDispatchRulePrefix)
info.SipDispatchRuleId = guid.New(utils.SIPDispatchRulePrefix)
if err := s.store.StoreSIPDispatchRule(ctx, info); err != nil {
return nil, err
}
+4 -3
View File
@@ -21,6 +21,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit/rpc"
"github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/config"
@@ -39,9 +40,9 @@ type analyticsService struct {
nodeID string
sequenceNumber atomic.Uint64
events livekit.AnalyticsRecorderService_IngestEventsClient
stats livekit.AnalyticsRecorderService_IngestStatsClient
nodeRooms livekit.AnalyticsRecorderService_IngestNodeRoomStatesClient
events rpc.AnalyticsRecorderService_IngestEventsClient
stats rpc.AnalyticsRecorderService_IngestStatsClient
nodeRooms rpc.AnalyticsRecorderService_IngestNodeRoomStatesClient
}
func NewAnalyticsService(_ *config.Config, currentNode routing.LocalNode) AnalyticsService {
+2 -2
View File
@@ -23,7 +23,7 @@ import (
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/protocol/webhook"
)
@@ -33,7 +33,7 @@ func (t *telemetryService) NotifyEvent(ctx context.Context, event *livekit.Webho
}
event.CreatedAt = time.Now().Unix()
event.Id = utils.NewGuid("EV_")
event.Id = guid.New("EV_")
if err := t.notifier.QueueNotify(ctx, event); err != nil {
logger.Warnw("failed to notify webhook", err, "event", event.Event)
+4 -4
View File
@@ -35,7 +35,7 @@ import (
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
)
const (
@@ -80,8 +80,8 @@ func setupSingleNodeTest(name string) (*service.LivekitServer, func()) {
func setupMultiNodeTest(name string) (*service.LivekitServer, *service.LivekitServer, func()) {
logger.Infow("----------------STARTING TEST----------------", "test", name)
s1 := createMultiNodeServer(utils.NewGuid(nodeID1), defaultServerPort)
s2 := createMultiNodeServer(utils.NewGuid(nodeID2), secondServerPort)
s1 := createMultiNodeServer(guid.New(nodeID1), defaultServerPort)
s2 := createMultiNodeServer(guid.New(nodeID2), secondServerPort)
go s1.Start()
go s2.Start()
@@ -161,7 +161,7 @@ func createSingleNodeServer(configUpdater func(*config.Config)) *service.Livekit
if err != nil {
panic(fmt.Sprintf("could not create local node: %v", err))
}
currentNode.Id = utils.NewGuid(nodeID1)
currentNode.Id = guid.New(nodeID1)
s, err := service.InitializeServer(conf, currentNode)
if err != nil {
+2 -2
View File
@@ -30,7 +30,7 @@ import (
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/protocol/webhook"
"github.com/livekit/livekit-server/pkg/config"
@@ -137,7 +137,7 @@ func setupServerWithWebhook() (server *service.LivekitServer, testServer *webhoo
if err != nil {
return
}
currentNode.Id = utils.NewGuid(nodeID1)
currentNode.Id = guid.New(nodeID1)
server, err = service.InitializeServer(conf, currentNode)
if err != nil {