Skip to content

chore: adds LDTransactionalFeatureStore, LDTransactionalDataSourceUpdates, and FDv2 DataSource impls. #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tanderson-ld
Copy link
Contributor

@tanderson-ld tanderson-ld commented Apr 25, 2025

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

This PR moves changes for FDv2 from the temporary holding branch to main. All picked code has been previously reviewed and was picked from the temporary holding branch using file pick commands.

Resolved conflicts with @abarker-launchdarkly's recent initMetadata changes. Please verify those conflict resolutions @abarker-launchdarkly .

@tanderson-ld tanderson-ld requested a review from a team as a code owner April 25, 2025 21:26
Copy link
Contributor

github-actions bot commented Apr 25, 2025

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Size: 23840 bytes
Size limit: 25000

Copy link
Contributor

github-actions bot commented Apr 25, 2025

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Size: 20702 bytes
Size limit: 21000

Copy link
Contributor

github-actions bot commented Apr 25, 2025

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Size: 15786 bytes
Size limit: 20000

@tanderson-ld tanderson-ld force-pushed the ta/fdv2-code-move-part2 branch from 76369ec to eb45ed6 Compare April 28, 2025 15:16
@tanderson-ld tanderson-ld changed the title chore: adds applyChanges to LDFeatureStore and impls. Adds TransactionalPersistentStore. chore: adds LDTransactionalFeatureStore and impls. May 7, 2025
@tanderson-ld tanderson-ld changed the title chore: adds LDTransactionalFeatureStore and impls. chore: adds LDTransactionalFeatureStore, LDTransactionalDataSourceUpdates, and FDv2 DataSource impls. May 7, 2025
@tanderson-ld tanderson-ld force-pushed the ta/fdv2-code-move-part2 branch from e3f5ac5 to b0d426c Compare May 7, 2025 16:01
@tanderson-ld tanderson-ld requested a review from kinyoklion May 7, 2025 20:38
Copy link
Member

@kinyoklion kinyoklion left a comment

Choose a reason for hiding this comment

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

I have some concern that ordering is much more important now, so we may need to validate when callbacks can happen and when they can be applied.

In the old stuff you would have a stream and you know you will get puts and then later patches and the way the event source works we really aren't going to break that. Polling included the entire payload, so even http requests completing out of order wasn't a problem.

Now data could come from many sources that are less coordinated.

import Requestor from '../../src/data_sources/Requestor';
import TestLogger, { LogLevel } from '../Logger';

describe('given an event processor', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
describe('given an event processor', () => {
describe('given a polling processor', () => {

requestor.requestAllData = jest.fn((cb) => cb(undefined, jsonData));

processor.start(mockDataCallback, mockStatusCallback);
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

I would instead set this up to await a couple calls, then let the test timeout indicate failure. Potentially using the async queue and awaiting a couple take calls. This gives it a total of 5 seconds to happen, the test timeout, but doesn't cause it to require at least 500ms. Also this test may flake under high load as is.

basis: boolean,
data: LDFeatureStoreDataStorage,
callback: () => void,
initMetadata?: InitMetadata,
Copy link
Member

Choose a reason for hiding this comment

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

Did you need the type alias for some reason?

});
}

stop() {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about this. Do all the callbacks get disconnected from this, in the situation we don't want to use it anymore?

It is a little different for client-side, but I saw this assumption is causing problems in the client-side SDK where a poll completes after stop and the data propagates.

In this case maybe the unintended propagation would be fine? But maybe it could cause an unexpected basis to apply a delta to?

const startTime = Date.now();
this._logger?.debug('Polling LaunchDarkly for feature flag updates');
this._requestor.requestAllData((err, body) => {
const elapsed = Date.now() - startTime;
Copy link
Member

Choose a reason for hiding this comment

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

We likely want a _stopped check inside the callback, so we do not apply data/status from a stopped data source.

];
}

function computeDependencies(namespace: string, item: LDFeatureStoreItem) {
Copy link
Member

Choose a reason for hiding this comment

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

This code was just moved, correct?

Copy link
Member

Choose a reason for hiding this comment

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

Or is it a duplicate?

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