Added coloured logs and fixed a concurrency bug in the localpubsub adapter

This commit is contained in:
2024-02-06 18:44:45 -07:00
parent e44c858ab3
commit 53e2254795
10 changed files with 61 additions and 25 deletions

View File

@ -9,6 +9,7 @@ import (
"time"
"github.com/labstack/echo/v4"
"goth.stack/lib/pubsub"
)
type SSEServerType struct {
@ -58,7 +59,7 @@ func (s *SSEServerType) ClientCount(channel string) int {
return len(s.clients[channel])
}
func SendSSE(ctx context.Context, messageBroker PubSub, channel string, message string) error {
func SendSSE(ctx context.Context, messageBroker pubsub.PubSub, channel string, message string) error {
// Create a channel to receive an error from the goroutine
errCh := make(chan error, 1)
@ -102,7 +103,7 @@ func CreateTickerAndKeepAlive(c echo.Context, duration time.Duration) *time.Tick
return ticker
}
func HandleIncomingMessages(c echo.Context, pubsub PubSubMessage, client chan string) {
func HandleIncomingMessages(c echo.Context, pubsub pubsub.PubSubMessage, client chan string) {
for {
select {
case <-c.Request().Context().Done():