Skip to content
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

feat(api): implement launch darkly node sdk #3441

Merged
merged 3 commits into from
May 23, 2023

Conversation

p-fernandez
Copy link
Contributor

What change does this PR introduce?

Implements a Feature Flags service that instantiates a selected provider service, in the current case, the Launch Darkly service. Is implemented in a way that won't block execution if the feature flags provider is not set.

Why was this change needed?

Abstraction of the feature flags provider.

Other information (Screenshots)

@linear
Copy link

linear bot commented May 17, 2023

NV-2323 Implement Launch Darkly Node SDK

We created to create a provider abstraction that would help us to replace easily the FF provider if needed.

Definition of done

  • Clean implementation of a feature flags provider.

private service: IFeatureFlagsService;

constructor() {
// TODO: In the future we can replace the object key here for an environment variable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would allow users to implement or choose their own feature flags provider.

Comment on lines 10 to 15
const featureFlagsService = {
provide: FeatureFlagsService,
useFactory: async () => {
return new FeatureFlagsService();
},
};
Copy link
Contributor

Choose a reason for hiding this comment

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

probably we don't need this provider and can pass the FeatureFlagsService to the providers array

},
};

const providers = [LaunchDarklyService, featureFlagsService];
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering whether these two should be added to the application-generic package instead

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, in that way we can also use it inside the worker, ws and other services

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a fear of application-generic becoming a trash can where everything shared ends up there.
I am biased regarding the usage of feature flags in the worker, as it is the lowest level of our system, and I consider feature flags discrimination should be as early as possible in the API layer. On the other side I would understand the need to use feature flags for the WS app. Though one could say that should be controlled in the client (Web app) and to retrieve the logic from the client we have 2 options: to call to our API and have a one place of responsibility or use the Launch Darkly client SDK package.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is how the application-generic is used right now 🥲
I feel like it might be useful for all the apps, I can imagine a situation where we want the request to go through the API layer and just feature flag something in the Worker layer, let's say new calculations for the timed digest functionality, for some users we will calculate it with "old logic" and for others using the "new logic" (just the example).

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe let's start like this, and then if we will see the need then we can move to the application-generic


constructor() {
// TODO: In the future we can replace the object key here for an environment variable
const service = featureFlagsProviders[FeatureFlagsProvidersEnum.LAUNCH_DARKLY];
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to let the user have the ability to choose a provider, maybe it will be a good idea to introduce an environment variable with the provider name e.g
FEATURE_FLAG_PROVIDER=LaunchDarkly.
And update the current environment variable key LAUNCH_DARKLY_SDK_KEY to a generic name like FEATURE_FLAG_SDK_KEY, that way the user could choose from existing sdk's a provide that he wants to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly is what I'd like to do in the future. 👍🏻

@p-fernandez p-fernandez force-pushed the nv-2323-implement-launch-darkly-node-sdk branch from 752a446 to 5c48630 Compare May 22, 2023 14:22
@p-fernandez p-fernandez added this pull request to the merge queue May 23, 2023
Merged via the queue into next with commit 21193b1 May 23, 2023
32 checks passed
@p-fernandez p-fernandez deleted the nv-2323-implement-launch-darkly-node-sdk branch May 23, 2023 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants