Skip to content

Commit

Permalink
still-to-improve fix to prevent congestion of the ws output queue
Browse files Browse the repository at this point in the history
  • Loading branch information
benleb committed May 2, 2023
1 parent be9eadb commit cf1d074
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/trapri/trapri.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ func TokenTransactionFormatter(gb *gloomberg.Gloomberg, queueTokenTransactions c
for ttx := range queueTokenTransactions {
go formatTokenTransaction(gb, ttx, terminalPrinterQueue)

// send to ws
queueWsOutTokenTransactions <- ttx
// send to ws if webserver enabled & the queue is not congested
if viper.GetBool("web.enabled") {
if len(queueWsOutTokenTransactions) < cap(queueWsOutTokenTransactions)-10 {
queueWsOutTokenTransactions <- ttx
} else {
gbl.Log.Warnf("🧱 ws out queue is congested")
}
}
}
}

Expand Down

0 comments on commit cf1d074

Please sign in to comment.