Skip to content

Commit

Permalink
APP-2747 Add logging to send for debugging webRTC(#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayvuyyuru authored Dec 28, 2023
1 parent abab544 commit 95b4ebb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rpc/wrtc_call_queue_mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.uber.org/multierr"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand Down Expand Up @@ -300,16 +301,21 @@ type mongodbNewCallEventHandler struct {
receiveOnce sync.Once
}

func (newCall *mongodbNewCallEventHandler) Send(event mongodbCallEvent) bool {
func (newCall *mongodbNewCallEventHandler) Send(event mongodbCallEvent, logger *zap.SugaredLogger) bool {
var sent bool
newCall.receiveOnce.Do(func() {
// should always work
select {
case newCall.eventChan <- event:
sent = true
default:
logger.Infow("Hit default select in send",
"Event", event.Call)
}
})
logger.Infow("returning from send",
"Event", event.Call,
"Sent", sent)
return sent
}

Expand Down Expand Up @@ -599,6 +605,7 @@ func (queue *mongoDBWebRTCCallQueue) processNextSubscriptionEvent(next mongoutil
return
}
event := mongodbCallEvent{Call: callResp}
queue.logger.Infof("Number of answer channels: %d", len(answerChans))
for answerChan := range answerChans {
// We will send on this channel just once and it will eventually
// unsubscribe. We are not concerned with looping over channels
Expand All @@ -607,7 +614,7 @@ func (queue *mongoDBWebRTCCallQueue) processNextSubscriptionEvent(next mongoutil
// though, we want to send the events as fast as possible as mentioned
// above and cannot block on the send to see if the receiver locked
// the document.
if answerChan.Send(event) {
if answerChan.Send(event, queue.logger) {
return
}
}
Expand Down

0 comments on commit 95b4ebb

Please sign in to comment.