on main help sign in
feat(logs): add a log line for dropped events
commitb223e24ed8f65117f02bb2fafd1cf3184b731b21 authorKieran Klukas <kieran@dunkirk.sh> dateMon 11 May 2026, 18:23 (5 months ago) parent0585f49
1 file changed+7−4
internal/pubsub/broker.go+7−4
internal/pubsub/broker.go+7−4
@@ -2,13 +2,15 @@ package pubsub
22
33import (
44 "context"
5+ "log/slog"
56 "sync"
67)
78
89// bufferSize is the per-subscriber channel capacity for any broker
910// created via NewBroker. Publish is non-blocking, so a full buffer
10−// silently drops events; sized to cover a long streaming assistant
11−// turn (~one UpdatedEvent per token) even under TUI render stalls.
11+// drops events (with a warning log); sized to cover a long streaming
12+// assistant turn (~one UpdatedEvent per token) even under TUI render
13+// stalls.
1214const bufferSize = 4096
1315
1416type Broker[T any] struct {
@@ -108,8 +110,9 @@ func (b *Broker[T]) Publish(t EventType, payload T) {
108110 select {
109111 case sub <- event:
110112 default:
111− // Channel is full, subscriber is slow - skip this event
112− // This prevents blocking the publisher
113+ // Channel is full, subscriber is slow — skip this event.
114+ // This prevents blocking the publisher.
115+ slog.Warn("Pubsub buffer full; dropping event", "type", t)
113116 }
114117 }
115118}