Some misc clean up. (#3156)

* Some misc clean up.

- Have been seeing counterfeiter warnings about efficiency for a while
  with go:generate declaration multiple times in the same package.
  Address that: https://github.com/maxbrunsfeld/counterfeiter?tab=readme-ov-file#step-2b---add-counterfeitergenerate-directives
- A bit more readability on parameters passed to `sendLeave`

* spacing

* revert some deletes as the complaint was in analytics service only

* Declare in package only once.

Although the warning is about go:generate multiple times when directly
giving the interface to generate, have `go:generate` multiple times in a
package even with `-generate` ends up generating once per invocation.
Once per package is enough to run the generation just once.
This commit is contained in:
Raja Subramanian
2024-11-04 11:26:41 +05:30
committed by GitHub
parent 35bef35d66
commit 365e63230d
7 changed files with 30 additions and 15 deletions
+26 -5
View File
@@ -963,7 +963,12 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
p.clearMigrationTimer()
if sendLeave {
p.sendLeaveRequest(reason, isExpectedToResume, false, false)
p.sendLeaveRequest(
reason,
isExpectedToResume,
false, // isExpectedToReconnect
false, // sendOnlyIfSupportingLeaveRequestWithAction
)
}
if p.supervisor != nil {
@@ -1070,7 +1075,12 @@ func (p *ParticipantImpl) MaybeStartMigration(force bool, onStart func()) bool {
onStart()
}
p.sendLeaveRequest(types.ParticipantCloseReasonMigrationRequested, true, false, true)
p.sendLeaveRequest(
types.ParticipantCloseReasonMigrationRequested,
true, // isExpectedToResume
false, // isExpectedToReconnect
true, // sendOnlyIfSupportingLeaveRequestWithAction
)
p.CloseSignalConnection(types.SignallingCloseReasonMigration)
p.clearMigrationTimer()
@@ -1818,8 +1828,14 @@ func (p *ParticipantImpl) setupDisconnectTimer() {
}
func (p *ParticipantImpl) onAnyTransportFailed() {
// clients support resuming of connections when websocket becomes disconnected
p.sendLeaveRequest(types.ParticipantCloseReasonPeerConnectionDisconnected, true, false, true)
p.sendLeaveRequest(
types.ParticipantCloseReasonPeerConnectionDisconnected,
true, // isExpectedToResume
false, // isExpectedToReconnect
true, // sendOnlyIfSupportingLeaveRequestWithAction
)
// clients support resuming of connections when signalling becomes disconnected
p.CloseSignalConnection(types.SignallingCloseReasonTransportFailure)
// detect when participant has actually left.
@@ -2656,7 +2672,12 @@ func (p *ParticipantImpl) GetCachedDownTrack(trackID livekit.TrackID) (*webrtc.R
}
func (p *ParticipantImpl) IssueFullReconnect(reason types.ParticipantCloseReason) {
p.sendLeaveRequest(reason, false, true, false)
p.sendLeaveRequest(
reason,
false, // isExpectedToResume
true, // isExpectedToReconnect
false, // sendOnlyIfSupportingLeaveRequestWithAction
)
scr := types.SignallingCloseReasonUnknown
switch reason {