From a6eb4290d3f86ba90dc0945658de6ac56d05f38b Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 7 Feb 2022 23:15:24 -0800 Subject: [PATCH] Generate telemetry stubs (#412) --- .../telemetryfakes/fake_telemetry_service.go | 598 ++++++++++++++++++ pkg/telemetry/telemetryservice.go | 1 + 2 files changed, 599 insertions(+) create mode 100644 pkg/telemetry/telemetryfakes/fake_telemetry_service.go diff --git a/pkg/telemetry/telemetryfakes/fake_telemetry_service.go b/pkg/telemetry/telemetryfakes/fake_telemetry_service.go new file mode 100644 index 00000000..93375106 --- /dev/null +++ b/pkg/telemetry/telemetryfakes/fake_telemetry_service.go @@ -0,0 +1,598 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package telemetryfakes + +import ( + "context" + "sync" + + "github.com/livekit/livekit-server/pkg/telemetry" + "github.com/livekit/protocol/livekit" +) + +type FakeTelemetryService struct { + ParticipantActiveStub func(context.Context, livekit.ParticipantID, *livekit.AnalyticsClientMeta) + participantActiveMutex sync.RWMutex + participantActiveArgsForCall []struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.AnalyticsClientMeta + } + ParticipantJoinedStub func(context.Context, *livekit.Room, *livekit.ParticipantInfo, *livekit.ClientInfo, *livekit.AnalyticsClientMeta) + participantJoinedMutex sync.RWMutex + participantJoinedArgsForCall []struct { + arg1 context.Context + arg2 *livekit.Room + arg3 *livekit.ParticipantInfo + arg4 *livekit.ClientInfo + arg5 *livekit.AnalyticsClientMeta + } + ParticipantLeftStub func(context.Context, *livekit.Room, *livekit.ParticipantInfo) + participantLeftMutex sync.RWMutex + participantLeftArgsForCall []struct { + arg1 context.Context + arg2 *livekit.Room + arg3 *livekit.ParticipantInfo + } + RecordingEndedStub func(context.Context, *livekit.RecordingInfo) + recordingEndedMutex sync.RWMutex + recordingEndedArgsForCall []struct { + arg1 context.Context + arg2 *livekit.RecordingInfo + } + RecordingStartedStub func(context.Context, *livekit.RecordingInfo) + recordingStartedMutex sync.RWMutex + recordingStartedArgsForCall []struct { + arg1 context.Context + arg2 *livekit.RecordingInfo + } + RoomEndedStub func(context.Context, *livekit.Room) + roomEndedMutex sync.RWMutex + roomEndedArgsForCall []struct { + arg1 context.Context + arg2 *livekit.Room + } + RoomStartedStub func(context.Context, *livekit.Room) + roomStartedMutex sync.RWMutex + roomStartedArgsForCall []struct { + arg1 context.Context + arg2 *livekit.Room + } + TrackPublishedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo) + trackPublishedMutex sync.RWMutex + trackPublishedArgsForCall []struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + } + TrackPublishedUpdateStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo) + trackPublishedUpdateMutex sync.RWMutex + trackPublishedUpdateArgsForCall []struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + } + TrackStatsStub func(livekit.StreamType, livekit.ParticipantID, livekit.TrackID, *livekit.AnalyticsStat) + trackStatsMutex sync.RWMutex + trackStatsArgsForCall []struct { + arg1 livekit.StreamType + arg2 livekit.ParticipantID + arg3 livekit.TrackID + arg4 *livekit.AnalyticsStat + } + TrackSubscribedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo) + trackSubscribedMutex sync.RWMutex + trackSubscribedArgsForCall []struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + } + TrackUnpublishedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo, uint32) + trackUnpublishedMutex sync.RWMutex + trackUnpublishedArgsForCall []struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + arg4 uint32 + } + TrackUnsubscribedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo) + trackUnsubscribedMutex sync.RWMutex + trackUnsubscribedArgsForCall []struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeTelemetryService) ParticipantActive(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.AnalyticsClientMeta) { + fake.participantActiveMutex.Lock() + fake.participantActiveArgsForCall = append(fake.participantActiveArgsForCall, struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.AnalyticsClientMeta + }{arg1, arg2, arg3}) + stub := fake.ParticipantActiveStub + fake.recordInvocation("ParticipantActive", []interface{}{arg1, arg2, arg3}) + fake.participantActiveMutex.Unlock() + if stub != nil { + fake.ParticipantActiveStub(arg1, arg2, arg3) + } +} + +func (fake *FakeTelemetryService) ParticipantActiveCallCount() int { + fake.participantActiveMutex.RLock() + defer fake.participantActiveMutex.RUnlock() + return len(fake.participantActiveArgsForCall) +} + +func (fake *FakeTelemetryService) ParticipantActiveCalls(stub func(context.Context, livekit.ParticipantID, *livekit.AnalyticsClientMeta)) { + fake.participantActiveMutex.Lock() + defer fake.participantActiveMutex.Unlock() + fake.ParticipantActiveStub = stub +} + +func (fake *FakeTelemetryService) ParticipantActiveArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.AnalyticsClientMeta) { + fake.participantActiveMutex.RLock() + defer fake.participantActiveMutex.RUnlock() + argsForCall := fake.participantActiveArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeTelemetryService) ParticipantJoined(arg1 context.Context, arg2 *livekit.Room, arg3 *livekit.ParticipantInfo, arg4 *livekit.ClientInfo, arg5 *livekit.AnalyticsClientMeta) { + fake.participantJoinedMutex.Lock() + fake.participantJoinedArgsForCall = append(fake.participantJoinedArgsForCall, struct { + arg1 context.Context + arg2 *livekit.Room + arg3 *livekit.ParticipantInfo + arg4 *livekit.ClientInfo + arg5 *livekit.AnalyticsClientMeta + }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.ParticipantJoinedStub + fake.recordInvocation("ParticipantJoined", []interface{}{arg1, arg2, arg3, arg4, arg5}) + fake.participantJoinedMutex.Unlock() + if stub != nil { + fake.ParticipantJoinedStub(arg1, arg2, arg3, arg4, arg5) + } +} + +func (fake *FakeTelemetryService) ParticipantJoinedCallCount() int { + fake.participantJoinedMutex.RLock() + defer fake.participantJoinedMutex.RUnlock() + return len(fake.participantJoinedArgsForCall) +} + +func (fake *FakeTelemetryService) ParticipantJoinedCalls(stub func(context.Context, *livekit.Room, *livekit.ParticipantInfo, *livekit.ClientInfo, *livekit.AnalyticsClientMeta)) { + fake.participantJoinedMutex.Lock() + defer fake.participantJoinedMutex.Unlock() + fake.ParticipantJoinedStub = stub +} + +func (fake *FakeTelemetryService) ParticipantJoinedArgsForCall(i int) (context.Context, *livekit.Room, *livekit.ParticipantInfo, *livekit.ClientInfo, *livekit.AnalyticsClientMeta) { + fake.participantJoinedMutex.RLock() + defer fake.participantJoinedMutex.RUnlock() + argsForCall := fake.participantJoinedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 +} + +func (fake *FakeTelemetryService) ParticipantLeft(arg1 context.Context, arg2 *livekit.Room, arg3 *livekit.ParticipantInfo) { + fake.participantLeftMutex.Lock() + fake.participantLeftArgsForCall = append(fake.participantLeftArgsForCall, struct { + arg1 context.Context + arg2 *livekit.Room + arg3 *livekit.ParticipantInfo + }{arg1, arg2, arg3}) + stub := fake.ParticipantLeftStub + fake.recordInvocation("ParticipantLeft", []interface{}{arg1, arg2, arg3}) + fake.participantLeftMutex.Unlock() + if stub != nil { + fake.ParticipantLeftStub(arg1, arg2, arg3) + } +} + +func (fake *FakeTelemetryService) ParticipantLeftCallCount() int { + fake.participantLeftMutex.RLock() + defer fake.participantLeftMutex.RUnlock() + return len(fake.participantLeftArgsForCall) +} + +func (fake *FakeTelemetryService) ParticipantLeftCalls(stub func(context.Context, *livekit.Room, *livekit.ParticipantInfo)) { + fake.participantLeftMutex.Lock() + defer fake.participantLeftMutex.Unlock() + fake.ParticipantLeftStub = stub +} + +func (fake *FakeTelemetryService) ParticipantLeftArgsForCall(i int) (context.Context, *livekit.Room, *livekit.ParticipantInfo) { + fake.participantLeftMutex.RLock() + defer fake.participantLeftMutex.RUnlock() + argsForCall := fake.participantLeftArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeTelemetryService) RecordingEnded(arg1 context.Context, arg2 *livekit.RecordingInfo) { + fake.recordingEndedMutex.Lock() + fake.recordingEndedArgsForCall = append(fake.recordingEndedArgsForCall, struct { + arg1 context.Context + arg2 *livekit.RecordingInfo + }{arg1, arg2}) + stub := fake.RecordingEndedStub + fake.recordInvocation("RecordingEnded", []interface{}{arg1, arg2}) + fake.recordingEndedMutex.Unlock() + if stub != nil { + fake.RecordingEndedStub(arg1, arg2) + } +} + +func (fake *FakeTelemetryService) RecordingEndedCallCount() int { + fake.recordingEndedMutex.RLock() + defer fake.recordingEndedMutex.RUnlock() + return len(fake.recordingEndedArgsForCall) +} + +func (fake *FakeTelemetryService) RecordingEndedCalls(stub func(context.Context, *livekit.RecordingInfo)) { + fake.recordingEndedMutex.Lock() + defer fake.recordingEndedMutex.Unlock() + fake.RecordingEndedStub = stub +} + +func (fake *FakeTelemetryService) RecordingEndedArgsForCall(i int) (context.Context, *livekit.RecordingInfo) { + fake.recordingEndedMutex.RLock() + defer fake.recordingEndedMutex.RUnlock() + argsForCall := fake.recordingEndedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeTelemetryService) RecordingStarted(arg1 context.Context, arg2 *livekit.RecordingInfo) { + fake.recordingStartedMutex.Lock() + fake.recordingStartedArgsForCall = append(fake.recordingStartedArgsForCall, struct { + arg1 context.Context + arg2 *livekit.RecordingInfo + }{arg1, arg2}) + stub := fake.RecordingStartedStub + fake.recordInvocation("RecordingStarted", []interface{}{arg1, arg2}) + fake.recordingStartedMutex.Unlock() + if stub != nil { + fake.RecordingStartedStub(arg1, arg2) + } +} + +func (fake *FakeTelemetryService) RecordingStartedCallCount() int { + fake.recordingStartedMutex.RLock() + defer fake.recordingStartedMutex.RUnlock() + return len(fake.recordingStartedArgsForCall) +} + +func (fake *FakeTelemetryService) RecordingStartedCalls(stub func(context.Context, *livekit.RecordingInfo)) { + fake.recordingStartedMutex.Lock() + defer fake.recordingStartedMutex.Unlock() + fake.RecordingStartedStub = stub +} + +func (fake *FakeTelemetryService) RecordingStartedArgsForCall(i int) (context.Context, *livekit.RecordingInfo) { + fake.recordingStartedMutex.RLock() + defer fake.recordingStartedMutex.RUnlock() + argsForCall := fake.recordingStartedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeTelemetryService) RoomEnded(arg1 context.Context, arg2 *livekit.Room) { + fake.roomEndedMutex.Lock() + fake.roomEndedArgsForCall = append(fake.roomEndedArgsForCall, struct { + arg1 context.Context + arg2 *livekit.Room + }{arg1, arg2}) + stub := fake.RoomEndedStub + fake.recordInvocation("RoomEnded", []interface{}{arg1, arg2}) + fake.roomEndedMutex.Unlock() + if stub != nil { + fake.RoomEndedStub(arg1, arg2) + } +} + +func (fake *FakeTelemetryService) RoomEndedCallCount() int { + fake.roomEndedMutex.RLock() + defer fake.roomEndedMutex.RUnlock() + return len(fake.roomEndedArgsForCall) +} + +func (fake *FakeTelemetryService) RoomEndedCalls(stub func(context.Context, *livekit.Room)) { + fake.roomEndedMutex.Lock() + defer fake.roomEndedMutex.Unlock() + fake.RoomEndedStub = stub +} + +func (fake *FakeTelemetryService) RoomEndedArgsForCall(i int) (context.Context, *livekit.Room) { + fake.roomEndedMutex.RLock() + defer fake.roomEndedMutex.RUnlock() + argsForCall := fake.roomEndedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeTelemetryService) RoomStarted(arg1 context.Context, arg2 *livekit.Room) { + fake.roomStartedMutex.Lock() + fake.roomStartedArgsForCall = append(fake.roomStartedArgsForCall, struct { + arg1 context.Context + arg2 *livekit.Room + }{arg1, arg2}) + stub := fake.RoomStartedStub + fake.recordInvocation("RoomStarted", []interface{}{arg1, arg2}) + fake.roomStartedMutex.Unlock() + if stub != nil { + fake.RoomStartedStub(arg1, arg2) + } +} + +func (fake *FakeTelemetryService) RoomStartedCallCount() int { + fake.roomStartedMutex.RLock() + defer fake.roomStartedMutex.RUnlock() + return len(fake.roomStartedArgsForCall) +} + +func (fake *FakeTelemetryService) RoomStartedCalls(stub func(context.Context, *livekit.Room)) { + fake.roomStartedMutex.Lock() + defer fake.roomStartedMutex.Unlock() + fake.RoomStartedStub = stub +} + +func (fake *FakeTelemetryService) RoomStartedArgsForCall(i int) (context.Context, *livekit.Room) { + fake.roomStartedMutex.RLock() + defer fake.roomStartedMutex.RUnlock() + argsForCall := fake.roomStartedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeTelemetryService) TrackPublished(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) { + fake.trackPublishedMutex.Lock() + fake.trackPublishedArgsForCall = append(fake.trackPublishedArgsForCall, struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + }{arg1, arg2, arg3}) + stub := fake.TrackPublishedStub + fake.recordInvocation("TrackPublished", []interface{}{arg1, arg2, arg3}) + fake.trackPublishedMutex.Unlock() + if stub != nil { + fake.TrackPublishedStub(arg1, arg2, arg3) + } +} + +func (fake *FakeTelemetryService) TrackPublishedCallCount() int { + fake.trackPublishedMutex.RLock() + defer fake.trackPublishedMutex.RUnlock() + return len(fake.trackPublishedArgsForCall) +} + +func (fake *FakeTelemetryService) TrackPublishedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) { + fake.trackPublishedMutex.Lock() + defer fake.trackPublishedMutex.Unlock() + fake.TrackPublishedStub = stub +} + +func (fake *FakeTelemetryService) TrackPublishedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) { + fake.trackPublishedMutex.RLock() + defer fake.trackPublishedMutex.RUnlock() + argsForCall := fake.trackPublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeTelemetryService) TrackPublishedUpdate(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) { + fake.trackPublishedUpdateMutex.Lock() + fake.trackPublishedUpdateArgsForCall = append(fake.trackPublishedUpdateArgsForCall, struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + }{arg1, arg2, arg3}) + stub := fake.TrackPublishedUpdateStub + fake.recordInvocation("TrackPublishedUpdate", []interface{}{arg1, arg2, arg3}) + fake.trackPublishedUpdateMutex.Unlock() + if stub != nil { + fake.TrackPublishedUpdateStub(arg1, arg2, arg3) + } +} + +func (fake *FakeTelemetryService) TrackPublishedUpdateCallCount() int { + fake.trackPublishedUpdateMutex.RLock() + defer fake.trackPublishedUpdateMutex.RUnlock() + return len(fake.trackPublishedUpdateArgsForCall) +} + +func (fake *FakeTelemetryService) TrackPublishedUpdateCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) { + fake.trackPublishedUpdateMutex.Lock() + defer fake.trackPublishedUpdateMutex.Unlock() + fake.TrackPublishedUpdateStub = stub +} + +func (fake *FakeTelemetryService) TrackPublishedUpdateArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) { + fake.trackPublishedUpdateMutex.RLock() + defer fake.trackPublishedUpdateMutex.RUnlock() + argsForCall := fake.trackPublishedUpdateArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeTelemetryService) TrackStats(arg1 livekit.StreamType, arg2 livekit.ParticipantID, arg3 livekit.TrackID, arg4 *livekit.AnalyticsStat) { + fake.trackStatsMutex.Lock() + fake.trackStatsArgsForCall = append(fake.trackStatsArgsForCall, struct { + arg1 livekit.StreamType + arg2 livekit.ParticipantID + arg3 livekit.TrackID + arg4 *livekit.AnalyticsStat + }{arg1, arg2, arg3, arg4}) + stub := fake.TrackStatsStub + fake.recordInvocation("TrackStats", []interface{}{arg1, arg2, arg3, arg4}) + fake.trackStatsMutex.Unlock() + if stub != nil { + fake.TrackStatsStub(arg1, arg2, arg3, arg4) + } +} + +func (fake *FakeTelemetryService) TrackStatsCallCount() int { + fake.trackStatsMutex.RLock() + defer fake.trackStatsMutex.RUnlock() + return len(fake.trackStatsArgsForCall) +} + +func (fake *FakeTelemetryService) TrackStatsCalls(stub func(livekit.StreamType, livekit.ParticipantID, livekit.TrackID, *livekit.AnalyticsStat)) { + fake.trackStatsMutex.Lock() + defer fake.trackStatsMutex.Unlock() + fake.TrackStatsStub = stub +} + +func (fake *FakeTelemetryService) TrackStatsArgsForCall(i int) (livekit.StreamType, livekit.ParticipantID, livekit.TrackID, *livekit.AnalyticsStat) { + fake.trackStatsMutex.RLock() + defer fake.trackStatsMutex.RUnlock() + argsForCall := fake.trackStatsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeTelemetryService) TrackSubscribed(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) { + fake.trackSubscribedMutex.Lock() + fake.trackSubscribedArgsForCall = append(fake.trackSubscribedArgsForCall, struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + }{arg1, arg2, arg3}) + stub := fake.TrackSubscribedStub + fake.recordInvocation("TrackSubscribed", []interface{}{arg1, arg2, arg3}) + fake.trackSubscribedMutex.Unlock() + if stub != nil { + fake.TrackSubscribedStub(arg1, arg2, arg3) + } +} + +func (fake *FakeTelemetryService) TrackSubscribedCallCount() int { + fake.trackSubscribedMutex.RLock() + defer fake.trackSubscribedMutex.RUnlock() + return len(fake.trackSubscribedArgsForCall) +} + +func (fake *FakeTelemetryService) TrackSubscribedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) { + fake.trackSubscribedMutex.Lock() + defer fake.trackSubscribedMutex.Unlock() + fake.TrackSubscribedStub = stub +} + +func (fake *FakeTelemetryService) TrackSubscribedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) { + fake.trackSubscribedMutex.RLock() + defer fake.trackSubscribedMutex.RUnlock() + argsForCall := fake.trackSubscribedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeTelemetryService) TrackUnpublished(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo, arg4 uint32) { + fake.trackUnpublishedMutex.Lock() + fake.trackUnpublishedArgsForCall = append(fake.trackUnpublishedArgsForCall, struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + arg4 uint32 + }{arg1, arg2, arg3, arg4}) + stub := fake.TrackUnpublishedStub + fake.recordInvocation("TrackUnpublished", []interface{}{arg1, arg2, arg3, arg4}) + fake.trackUnpublishedMutex.Unlock() + if stub != nil { + fake.TrackUnpublishedStub(arg1, arg2, arg3, arg4) + } +} + +func (fake *FakeTelemetryService) TrackUnpublishedCallCount() int { + fake.trackUnpublishedMutex.RLock() + defer fake.trackUnpublishedMutex.RUnlock() + return len(fake.trackUnpublishedArgsForCall) +} + +func (fake *FakeTelemetryService) TrackUnpublishedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo, uint32)) { + fake.trackUnpublishedMutex.Lock() + defer fake.trackUnpublishedMutex.Unlock() + fake.TrackUnpublishedStub = stub +} + +func (fake *FakeTelemetryService) TrackUnpublishedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo, uint32) { + fake.trackUnpublishedMutex.RLock() + defer fake.trackUnpublishedMutex.RUnlock() + argsForCall := fake.trackUnpublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeTelemetryService) TrackUnsubscribed(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) { + fake.trackUnsubscribedMutex.Lock() + fake.trackUnsubscribedArgsForCall = append(fake.trackUnsubscribedArgsForCall, struct { + arg1 context.Context + arg2 livekit.ParticipantID + arg3 *livekit.TrackInfo + }{arg1, arg2, arg3}) + stub := fake.TrackUnsubscribedStub + fake.recordInvocation("TrackUnsubscribed", []interface{}{arg1, arg2, arg3}) + fake.trackUnsubscribedMutex.Unlock() + if stub != nil { + fake.TrackUnsubscribedStub(arg1, arg2, arg3) + } +} + +func (fake *FakeTelemetryService) TrackUnsubscribedCallCount() int { + fake.trackUnsubscribedMutex.RLock() + defer fake.trackUnsubscribedMutex.RUnlock() + return len(fake.trackUnsubscribedArgsForCall) +} + +func (fake *FakeTelemetryService) TrackUnsubscribedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) { + fake.trackUnsubscribedMutex.Lock() + defer fake.trackUnsubscribedMutex.Unlock() + fake.TrackUnsubscribedStub = stub +} + +func (fake *FakeTelemetryService) TrackUnsubscribedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) { + fake.trackUnsubscribedMutex.RLock() + defer fake.trackUnsubscribedMutex.RUnlock() + argsForCall := fake.trackUnsubscribedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeTelemetryService) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.participantActiveMutex.RLock() + defer fake.participantActiveMutex.RUnlock() + fake.participantJoinedMutex.RLock() + defer fake.participantJoinedMutex.RUnlock() + fake.participantLeftMutex.RLock() + defer fake.participantLeftMutex.RUnlock() + fake.recordingEndedMutex.RLock() + defer fake.recordingEndedMutex.RUnlock() + fake.recordingStartedMutex.RLock() + defer fake.recordingStartedMutex.RUnlock() + fake.roomEndedMutex.RLock() + defer fake.roomEndedMutex.RUnlock() + fake.roomStartedMutex.RLock() + defer fake.roomStartedMutex.RUnlock() + fake.trackPublishedMutex.RLock() + defer fake.trackPublishedMutex.RUnlock() + fake.trackPublishedUpdateMutex.RLock() + defer fake.trackPublishedUpdateMutex.RUnlock() + fake.trackStatsMutex.RLock() + defer fake.trackStatsMutex.RUnlock() + fake.trackSubscribedMutex.RLock() + defer fake.trackSubscribedMutex.RUnlock() + fake.trackUnpublishedMutex.RLock() + defer fake.trackUnpublishedMutex.RUnlock() + fake.trackUnsubscribedMutex.RLock() + defer fake.trackUnsubscribedMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeTelemetryService) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ telemetry.TelemetryService = new(FakeTelemetryService) diff --git a/pkg/telemetry/telemetryservice.go b/pkg/telemetry/telemetryservice.go index 7a758833..0c8df42c 100644 --- a/pkg/telemetry/telemetryservice.go +++ b/pkg/telemetry/telemetryservice.go @@ -10,6 +10,7 @@ import ( const updateFrequency = time.Second * 10 +//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . TelemetryService type TelemetryService interface { // stats TrackStats(streamType livekit.StreamType, participantID livekit.ParticipantID, trackID livekit.TrackID, stat *livekit.AnalyticsStat)