Skip to content

Give the broadcaster a shutdown path - #180

Merged
nickschuch merged 1 commit into
mainfrom
fix/broadcaster-shutdown
Sep 4, 2026
Merged

Give the broadcaster a shutdown path#180
nickschuch merged 1 commit into
mainfrom
fix/broadcaster-shutdown

Conversation

@nickschuch

Copy link
Copy Markdown
Contributor

The broadcaster's run goroutine looped forever with no way to stop, and Subscribe/Unsubscribe blocked on unbuffered channels handed to it. This was latent while nothing cancelled the process context, but now that a signal cancels it the sidecar's shutdown drives this path: server.Shutdown waits for the streaming handlers to return, and they only return once their subscriber channel closes.

Run now takes a context and, on cancellation, closes every subscriber channel and returns, so blocked stream handlers unblock and server.Shutdown completes instead of waiting out its timeout. Subscribe, Unsubscribe and ProcessTrace select on a done channel so they no longer block once the loop has stopped; Subscribe hands back a closed channel after shutdown. The broadcaster is built from the errgroup context, and the tests pass one that ends with the test.

Adds a shutdown test asserting subscribers are closed and the API stops blocking, and moves the existing tests onto a cancellable context.

The broadcaster's run goroutine looped forever with no way to stop, and
Subscribe/Unsubscribe blocked on unbuffered channels handed to it. This was
latent while nothing cancelled the process context, but now that a signal
cancels it the sidecar's shutdown drives this path: server.Shutdown waits for
the streaming handlers to return, and they only return once their subscriber
channel closes.

Run now takes a context and, on cancellation, closes every subscriber channel
and returns, so blocked stream handlers unblock and server.Shutdown completes
instead of waiting out its timeout. Subscribe, Unsubscribe and ProcessTrace
select on a done channel so they no longer block once the loop has stopped;
Subscribe hands back a closed channel after shutdown. The broadcaster is built
from the errgroup context, and the tests pass one that ends with the test.

Adds a shutdown test asserting subscribers are closed and the API stops
blocking, and moves the existing tests onto a cancellable context.
@nickschuch
nickschuch merged commit 9fd8332 into main Sep 4, 2026
5 checks passed
@nickschuch
nickschuch deleted the fix/broadcaster-shutdown branch September 4, 2026 03:58
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