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

[FEATURE] In-memory provider for js (node) and web SDKs #565

Closed
2 of 3 tasks
toddbaert opened this issue Sep 13, 2023 · 3 comments · Fixed by #617
Closed
2 of 3 tasks

[FEATURE] In-memory provider for js (node) and web SDKs #565

toddbaert opened this issue Sep 13, 2023 · 3 comments · Fixed by #617
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@toddbaert
Copy link
Member

toddbaert commented Sep 13, 2023

Requirements

As outlined in the specification, the js-sdk should include an in-memory provider implementation. This implementation should take a simple object that defines flags as well as simple rules in the form of lambdas (see equivalent Java implementation, and existing JS implementation in contrib) and use those to evaluate flags. This is very useful to conusmers of the SDK for testing purposes. Please carefully implement all the behaviors defined in the spec for the in-memory provider.

This is a great issue to take on if you're looking to get started in OpenFeature!

@moredip This would be pretty similar to what you implemented in the JS contrib. I think the main thing missing would be rules-based evaluation (some flag "values" would instead define lambdas to run which are passed the context). If you'd like to work on this issue, just assign it to yourself. Otherwise, I will add the good first issue, etc tags to it which I suspect will result in it quickly being picked up.

Tasks

Preview Give feedback
@toddbaert toddbaert added the enhancement New feature or request label Sep 13, 2023
@luizgribeiro
Copy link
Contributor

I was looking at both js-contrib inMemoryProvider and the Java Provider mentioned and the structure looks pretty different. The JS one uses object literals to assign values to flags while Java's goes deeper with variants and context evaluator. This part caught my attention from the js:

  async resolveObjectEvaluation<U extends JsonValue>(flagKey: string): Promise<ResolutionDetails<U>> {
    throw new GeneralError('support for object flags has not been implemented');
  }

It is not clear to me if the context aware implementation of js-sdk should be backwards compatible or not.
In terms of docs, content and also getting started with openFeature it would be easier if it was.

What do you think that would be the best approach in this case @toddbaert ?

@toddbaert
Copy link
Member Author

toddbaert commented Oct 4, 2023

I don't think we have too many docs specifically talking about the current in-memory provider (and if we do have blogs/docs we can update them). I think the most important thing is to have a provider that conforms to the appendix in the spec, and is robust-enough for use in testing, which is the main purpose of the in-memory provider (replace your "real" provider with in-memory in unit testing).

I would not worry about the backwards compatibility. The current one will still be available on NPM regardless. (though we will likely deprecate it).

@luizgribeiro
Copy link
Contributor

Ok.

I'd like to work on the js-sdk-contrib issue. My idea is to:

  1. Make it spec compliant (flags definition structure used by provider mostly)
  2. Add context aware flag resolution support

It can be done in the js-sdk-contrib repo and the package can be moved to this one afterwards.

If that's ok, assign it to me please

toddbaert added a commit that referenced this issue Oct 11, 2023
## This PR

Implements the following features for `inMemoryProvider`:
- default value for flags
- reason for flag evaluation
- Context based evaluation

### Related Issues

It's part of #565 


---------

Signed-off-by: Luiz Ribeiro <[email protected]>
Co-authored-by: Todd Baert <[email protected]>
Co-authored-by: Michael Beemer <[email protected]>
@toddbaert toddbaert added the good first issue Good for newcomers label Oct 16, 2023
luizgribeiro added a commit to luizgribeiro/openfeature-js-sdk that referenced this issue Oct 26, 2023
toddbaert added a commit to luizgribeiro/openfeature-js-sdk that referenced this issue Nov 21, 2023
github-merge-queue bot pushed a commit that referenced this issue Nov 21, 2023
## This PR

- Adds in memory provider implementation for client (web) sdk
- Move files from server sdk to shared

### Related Issues

Closes #565 

### Notes

It's a first try. Any feedback and enhancement proposals are welcome :)

### How to test

Automated/unit testes were implemented, but e2e tests wouldn't hurt.

---------

Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Todd Baert <[email protected]>
Co-authored-by: Michael Beemer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants