on main help sign in
fix(pubsub): respect channelBufferSize parameter in Subsribe

`NewBrokerWithOptions` accepted `channelBufferSize` parameter, but never stored or used it, so `Subsribe`` always used the hardcoded `bufferSize` constant (64).

commitabeaff09a811234805d566db38131cf5cbbda94b authorYeonuk Hwang <charlie.hwang131@gmail.com> dateSat 9 May 2026, 00:20 (5 months ago) parentf970188
1 file changed+11−9
internal/pubsub/broker.go+11−9
internal/pubsub/broker.go+11−9
@@ -8,11 +8,12 @@ import (
88const bufferSize = 64
99
1010type Broker[T any] struct {
11− subs map[chan Event[T]]struct{}
12− mu sync.RWMutex
13− done chan struct{}
14− subCount int
15− maxEvents int
11+ subs map[chan Event[T]]struct{}
12+ mu sync.RWMutex
13+ done chan struct{}
14+ subCount int
15+ maxEvents int
16+ channelBufferSize int
1617}
1718
1819func NewBroker[T any]() *Broker[T] {
@@ -21,9 +22,10 @@ func NewBroker[T any]() *Broker[T] {
2122
2223func NewBrokerWithOptions[T any](channelBufferSize, maxEvents int) *Broker[T] {
2324 return &Broker[T]{
24− subs: make(map[chan Event[T]]struct{}),
25− done: make(chan struct{}),
26− maxEvents: maxEvents,
25+ subs: make(map[chan Event[T]]struct{}),
26+ done: make(chan struct{}),
27+ maxEvents: maxEvents,
28+ channelBufferSize: channelBufferSize,
2729 }
2830}
2931
@@ -58,7 +60,7 @@ func (b *Broker[T]) Subscribe(ctx context.Context) <-chan Event[T] {
5860 default:
5961 }
6062
61− sub := make(chan Event[T], bufferSize)
63+ sub := make(chan Event[T], b.channelBufferSize)
6264 b.subs[sub] = struct{}{}
6365 b.subCount++
6466