Skip to content

feat: Broadcast Off to FDv2 status listeners when the data system stops - #505

Open
beekld wants to merge 1 commit into
bklimt/SDK-3425/private-condition-clockfrom
bklimt/SDK-3425/broadcast-off-on-stop
Open

beekld wants to merge 1 commit into
bklimt/SDK-3425/private-condition-clockfrom
bklimt/SDK-3425/broadcast-off-on-stop

Conversation

@beekld

@beekld beekld commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Behavior change: compared with the released 7.21.2, FDv2 status listeners that are still reading now receive an Off status when the client closes. Their channels then close as before. 7.21.2 neither broadcast Off nor set it on shutdown. #489 added a blocking broadcast that could hang Close(), and #498 removed it.

This PR adds Broadcaster.CloseWith, which sends a final value to each listener that has room for it in its buffer and then closes every listener channel. It never waits for a listener to read, so a listener that has stopped reading still can't block Close(). That listener misses Off and only sees its channel close.

The data system uses it in Stop() to send the Off status. As a result, a WaitFor(DataSourceStateOff, ...) call that's running when the client closes now returns true.


Note

Overview
On shutdown, FDv2 now pushes an Off data-source status to status listeners that still have buffer space, then closes their channels as before. WaitFor(DataSourceStateOff, …) can return true when the client stops instead of only seeing the channel close.

This is implemented with a new Broadcaster.CloseWith: it non-blockingly tries to enqueue one final value per subscriber (drops it if the buffer is full), then closes all listener channels. Stop() records Off via maybeUpdateStatus and passes that status into broadcasters.Close(status), which uses CloseWith only for the data-source status broadcaster; other broadcasters still use plain Close.

Tests cover CloseWith (delivery when there is room; Stop/CloseWith never waits on a full listener) and FDv2 (listener gets Off then close; WaitFor(Off) succeeds on stop).

Reviewed by Cursor Bugbot for commit af42e38. Bugbot is set up for automated code reviews on this repo. Configure here.

@beekld
beekld added this pull request to stack #503 November 3, 2026 00:47
@beekld
beekld marked this pull request as ready for review November 3, 2026 00:48
@beekld
beekld requested a review from a team as a code owner November 3, 2026 00:48
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.

2 participants