chore: add FDv2 recovery primitives to SourceManager and Conditions - #1856
chore: add FDv2 recovery primitives to SourceManager and Conditions#1856joker23 wants to merge 1 commit into
Conversation
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk size report |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ab34b76. Configure here.
| * Creates a cancelable timer that resolves with the given {@link ConditionType} | ||
| * when it fires. Wraps {@link cancelableTimedPromise} to convert its | ||
| * reject-on-timeout semantics into resolve-with-type semantics. | ||
| * Wraps {@link cancelableTimedPromise} into a promise that resolves (not rejects) |
There was a problem hiding this comment.
I don't think I am fond of this comment change.
| * - `'recovery'`: reset to the primary synchronizer | ||
| */ | ||
| export type ConditionType = 'fallback' | 'recovery'; | ||
| export type ConditionType = 'fallback' | 'recovery' | 'fdv2Recovery'; |
There was a problem hiding this comment.
I don't think this is the correct modeling.
Summary
Adds
SourceManager.fdv2Recovery()(reversesfdv1Fallback()-- blocks FDv1 slots, unblocks non-FDv1 slots, resets the synchronizer index) and a read-onlySourceManager.isCurrentSynchronizerFDv1Fallbackgetter, plusConditions.createFDv2RecoveryCondition(ttlMs)and a new'fdv2Recovery'condition type.These are primitives only -- nothing on
maincalls them yet. The next PR in this stack wires them intoFDv2DataSource's orchestration loop to schedule a return to FDv2 after an FDv1 fallback TTL expires. Ships with unit tests for both newSourceManagermembers.Note
Overview
Adds recovery primitives for switching back from FDv1 fallback to FDv2 synchronizers. These are not wired into the orchestration loop yet; a follow-up PR will use them in
FDv2DataSource.SourceManagergainsfdv2Recovery()as the inverse offdv1Fallback(): FDv1 fallback slots are blocked, non-FDv1 slots are unblocked, and the synchronizer index resets so the next pick starts at the primary FDv2 slot. A newisCurrentSynchronizerFDv1Fallbackgetter reports whether the active synchronizer is the FDv1 fallback (false when no synchronizer has been selected yet).ConditionsextendsConditionTypewith'fdv2Recovery'and addscreateFDv2RecoveryCondition(ttlMs), a timer that resolves with that type after the TTL—intended to schedule return to FDv2 after an FDv1 fallback period.Unit tests cover slot state transitions, index reset after recovery, and the FDv1-fallback getter behavior.
Reviewed by Cursor Bugbot for commit ab34b76. Bugbot is set up for automated code reviews on this repo. Configure here.