bigbluebutton-Github/bbb-graphql-middleware/internal/hasura/retransmiter/retransmiter.go
Gustavo Trott 3c71aab4bc
refactor (gql-middlware): Refactored code to simplify channel handling and remove unnecessary routines (#20640)
* Refactor gql-middleware channels and remove dedicated channel to establish init connection

* remove unnecessary routin to wait mutations to complete before invalidate Hasura connection
2024-07-05 13:35:08 -03:00

32 lines
1.0 KiB
Go

package retransmiter
import (
"github.com/iMDT/bbb-graphql-middleware/internal/common"
log "github.com/sirupsen/logrus"
)
func RetransmitSubscriptionStartMessages(hc *common.HasuraConnection) {
log := log.WithField("_routine", "RetransmitSubscriptionStartMessages").WithField("browserConnectionId", hc.BrowserConn.Id).WithField("hasuraConnectionId", hc.Id)
hc.BrowserConn.ActiveSubscriptionsMutex.RLock()
for _, subscription := range hc.BrowserConn.ActiveSubscriptions {
//Not retransmitting Mutations
if subscription.Type == common.Mutation {
continue
}
if subscription.LastSeenOnHasuraConnection != hc.Id {
log.Tracef("retransmiting subscription start: %v", subscription.Message)
if subscription.Type == common.Streaming && subscription.StreamCursorCurrValue != nil {
hc.BrowserConn.FromBrowserToHasuraChannel.Send(common.PatchQuerySettingLastCursorValue(subscription))
} else {
hc.BrowserConn.FromBrowserToHasuraChannel.Send(subscription.Message)
}
}
}
hc.BrowserConn.ActiveSubscriptionsMutex.RUnlock()
}