From b638dafe5fb2b6fcdd6d9b64502a7808f3e81eb5 Mon Sep 17 00:00:00 2001 From: adamdottv <2363879+adamdottv@users.noreply.github.com> Date: Tue, 6 May 2025 14:22:37 -0500 Subject: feat: better logs page --- internal/pubsub/broker.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'internal/pubsub') diff --git a/internal/pubsub/broker.go b/internal/pubsub/broker.go index 88a59f60a..5aadd8ed5 100644 --- a/internal/pubsub/broker.go +++ b/internal/pubsub/broker.go @@ -5,7 +5,7 @@ import ( "sync" ) -const bufferSize = 64 +const bufferSize = 1000 type Broker[T any] struct { subs map[chan Event[T]]struct{} @@ -115,7 +115,23 @@ func (b *Broker[T]) Publish(t EventType, payload T) { for _, sub := range subscribers { select { case sub <- event: + // Successfully sent + case <-b.done: + // Broker is shutting down + return default: + // Channel is full, but we don't want to block + // Log this situation or consider other strategies + // For now, we'll create a new goroutine to ensure delivery + go func(ch chan Event[T], evt Event[T]) { + select { + case ch <- evt: + // Successfully sent + case <-b.done: + // Broker is shutting down + return + } + }(sub, event) } } } -- cgit v1.2.3