feat: Add FDv2 source manager#298
Open
kinyoklion wants to merge 1 commit into
Open
Conversation
Tracks the initializer and synchronizer lifecycle for the FDv2 orchestrator: initializers run once each in order; synchronizer slots cycle with wrap-around, can be blocked after terminal errors, re-created in place for reconnects, and reset to the primary for recovery. FDv1 fallback slots start blocked and are activated by a server fallback directive, disabling the FDv2 tier. Nothing consumes this yet.
Member
Author
|
bugbot review |
Member
Author
|
bugbot review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
1 issue from previous review remains unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 1716d97. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this adds
The source manager tracks which FDv2 data source is active and handles source transitions for the orchestrator (a later PR). Nothing consumes it yet, so behavior is unchanged.
It manages two tiers with different lifecycles:
nextInitializercloses the previous active source and produces the next one until the list runs out. The orchestrator uses this to bring the SDK to a usable state from cache or a poll.nextAvailableSynchronizerscans forward from the current position with wrap-around, skipping blocked slots. A slot is blocked after a terminal error (blockCurrentSynchronizer), the scan position resets to the primary for recovery (resetSynchronizerIndex), andrecreateCurrentSynchronizerproduces a fresh instance of the current slot without advancing — used when a source must drop its connection and re-establish it (goodbye, restart).isPrimarySynchronizerandavailableSynchronizerCountfeed the fallback/recovery condition selection (#297).FDv1 fallback slots start blocked and are only activated by a server fallback directive:
engageFdv1Fallbackmakes the FDv1 slots available and blocks the FDv2 tier, disabling it rather than removing it so the configuration survives for a later recovery to FDv2.Every transition closes the previously active source, and
closeshuts the manager down so no further sources can be created.Testing
Unit tests cover initializer ordering and exhaustion, synchronizer cycling with wrap-around, blocked-slot skipping, the all-blocked case, recovery reset, in-place re-creation, FDv1 fallback engagement (FDv2 tier disabled, FDv1 tier activated), and that close prevents further source creation and closes the active source.
SDK-2186
Note
Low Risk
New isolated module with tests only; no integration into existing data source paths until a follow-up PR.
Overview
Adds a new FDv2
SourceManager(plusSynchronizerSlot/ slot state) that will drive orchestrator source transitions. It is not wired in yet, so runtime behavior is unchanged.Initializers are advanced sequentially via
nextInitializer()(each step closes the prior active source) until the factory list is exhausted. Synchronizers live in slots that rotate withnextAvailableSynchronizer()(forward scan with wrap, skip blocked slots). Recovery helpers includeblockCurrentSynchronizer(),resetSynchronizerIndex(), andrecreateCurrentSynchronizer()for reconnect without changing slot.engageFdv1Fallback()blocks FDv2 slots and unblocks FDv1 fallback slots (which start blocked). ExposesisPrimarySynchronizer,availableSynchronizerCount, andhasFdv1Fallbackfor later fallback logic.Unit tests cover ordering, cycling, blocking, FDv1 engagement, recreate, and shutdown.
Reviewed by Cursor Bugbot for commit 1716d97. Bugbot is set up for automated code reviews on this repo. Configure here.