Skip to content

feat: add EvictSlowClients option to prevent slow subscribers blockin… - #192

Open
jeetvdevvee wants to merge 2 commits into
r3labs:masterfrom
jeetvdevvee:master
Open

feat: add EvictSlowClients option to prevent slow subscribers blockin…#192
jeetvdevvee wants to merge 2 commits into
r3labs:masterfrom
jeetvdevvee:master

Conversation

@jeetvdevvee

Copy link
Copy Markdown

feat: add EvictSlowClients option to prevent slow subscribers blocking stream.run()

When a subscriber's 64-slot connection buffer is full, the original
fan-out loop blocks the entire stream.run() goroutine, freezing all
other connected clients until the slow client catches up or disconnects.

Add EvictSlowClients bool field to Stream. When true, a non-blocking
select/default evicts the stalled subscriber via removeSubscriber()
instead of blocking. When false (default), the event is dropped for
that subscriber but the goroutine continues — still an improvement
over the original blocking behavior.

…g stream.run()

When a subscriber's 64-slot connection buffer is full, the original
fan-out loop blocks the entire stream.run() goroutine, freezing all
other connected clients until the slow client catches up or disconnects.

Add EvictSlowClients bool field to Stream. When true, a non-blocking
select/default evicts the stalled subscriber via removeSubscriber()
instead of blocking. When false (default), the event is dropped for
that subscriber but the goroutine continues — still an improvement
over the original blocking behavior.

removeSubscriber() is used instead of close() to avoid deadlocking
the run goroutine on its own deregister channel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant