Skip to content

feat: Add FDv2 source manager#298

Merged
kinyoklion merged 1 commit into
mainfrom
rlamb/sdk-2186/fdv2-source-manager
Jun 11, 2026
Merged

feat: Add FDv2 source manager#298
kinyoklion merged 1 commit into
mainfrom
rlamb/sdk-2186/fdv2-source-manager

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Jun 10, 2026

Copy link
Copy Markdown
Member

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:

  • Initializers run once each, in order, and exhaust: each call to nextInitializer closes 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.
  • Synchronizer slots cycle rather than exhaust: nextAvailableSynchronizer scans 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), and recreateCurrentSynchronizer produces a fresh instance of the current slot without advancing — used when a source must drop its connection and re-establish it (goodbye, restart).

isPrimarySynchronizer and availableSynchronizerCount feed the fallback/recovery condition selection (#297).

FDv1 fallback slots start blocked and are only activated by a server fallback directive: engageFdv1Fallback makes 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 close shuts 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 (plus SynchronizerSlot / 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 with nextAvailableSynchronizer() (forward scan with wrap, skip blocked slots). Recovery helpers include blockCurrentSynchronizer(), resetSynchronizerIndex(), and recreateCurrentSynchronizer() for reconnect without changing slot. engageFdv1Fallback() blocks FDv2 slots and unblocks FDv1 fallback slots (which start blocked). Exposes isPrimarySynchronizer, availableSynchronizerCount, and hasFdv1Fallback for 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.

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.
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1716d97. Configure here.

@kinyoklion kinyoklion marked this pull request as ready for review June 10, 2026 23:26
@kinyoklion kinyoklion requested a review from a team as a code owner June 10, 2026 23:26
@kinyoklion kinyoklion merged commit 43d899e into main Jun 11, 2026
10 checks passed
@kinyoklion kinyoklion deleted the rlamb/sdk-2186/fdv2-source-manager branch June 11, 2026 20:04
kinyoklion pushed a commit that referenced this pull request Jun 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.14.0](launchdarkly_common_client-v1.13.0...launchdarkly_common_client-v1.14.0)
(2026-06-29)


### Features

* add an initial connection mode to the FDv2 data system config
([#318](#318))
([5b980ab](5b980ab))
* Add FDv2 payload application via FlagManager.applyChanges
([#299](#299))
([66c2554](66c2554))
* Add FDv2 payload handling to the data source event handler
([#305](#305))
([761ed9d](761ed9d))
* Add FDv2 source manager
([#298](#298))
([43d899e](43d899e))
* Add FDv2 streaming source factories and query-parameter authentication
([7b46ac6](7b46ac6))
* Add FDv2 synchronizer fallback and recovery conditions
([#297](#297))
([17f7b4e](17f7b4e))
* Add the FDv2 data source orchestrator
([#307](#307))
([eb9a35f](eb9a35f))
* Add the FDv2 data system and expose it through configuration
([#310](#310))
([61a1e59](61a1e59))
* Centralize platform credential handling in CredentialConfig
([#300](#300))
([c677c3d](c677c3d))
* honor the FDv1 fallback directive on success, error, and goodbye
([#312](#312))
([1c35867](1c35867))
* Translate FDv2 payloads at the data source layer
([7b46ac6](7b46ac6))
* Update launchdarkly_event_source_client to version 2.2.0
([#302](#302))
([cb6a5c0](cb6a5c0))
* Update launchdarkly_event_source_client to version 3.0.0
([#317](#317))
([15861f8](15861f8))


### Bug Fixes

* Close the final initializer on exhaustion; document the source manager
contract
([#304](#304))
([b20c35e](b20c35e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Version and changelog metadata only; no application logic changes in
the diff.
> 
> **Overview**
> Release Please bumps **`launchdarkly_common_client`** from **1.13.0**
to **1.14.0** with no runtime code changes in this PR.
> 
> Updates **`.release-please-manifest.json`**,
**`packages/common_client/pubspec.yaml`**, and adds a **1.14.0** section
to **`CHANGELOG.md`** that documents the FDv2 data system work,
credential centralization, event-source client upgrades, and related
fixes already merged on main.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
458f0b6. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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