Skip to content

feat: implement multiprovider #669

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

Merged
merged 70 commits into from
Apr 25, 2025

Conversation

jblacker
Copy link
Contributor

@jblacker jblacker commented Apr 24, 2025

This PR

Adds an implementation of multi-provider for combining multiple providers into a single provider.

Related Issues

Implements #599

Notes

I implemented this based on the JavaScript version of the OpenFeature SDK. More strategies can be added at any time. Additionally, I branched off of @bbland1 so some of their commits are also part of this branch.

This PR supersedes #668

Follow-up Tasks

  • Implement Hooks support (although the inner provider's hooks will still be triggered)
  • Implement proper eventing support
  • Finish implementing slog support
  • Write e2e tests

How to test

Create multiple FeatureProviders and pass them to the NewMultiProvider method along with a strategy and any options.
Verify the results are as expected based on the strategy selected.

bbland1 and others added 30 commits April 23, 2025 21:59
…where it should be when strategies pushed

Signed-off-by: bbland1 <[email protected]>
…e used to define custom strategies

Signed-off-by: bbland1 <[email protected]>
…rategies similar to TS and passing that type into the provider

Signed-off-by: bbland1 <[email protected]>
Helper methods added

Signed-off-by: Jordan Blacker <[email protected]>
Signed-off-by: Jordan Blacker <[email protected]>
- Rename UniqueNameProvider -> NamedProvider: More accurate description of type as it's not enforced
- Updated signature of NewMultiProvider function: Using a map enforces unique names, use options pattern & config object for future extension
- Relocated NamedProvider to strategies as it's not needed externally
- Update shape of MultiProvider: Added logging, made all fields private, used map internally
- Moved aggregate-errors into errors package
- Added alias for ProviderMap shape & added helper functions
- Use pointers since we're passing stuff around and want to avoid unnecessary clones of objects & extra garbage collection
- Updated other various signatures throughout as needed
- Update tests & remove tests that no longer apply

Signed-off-by: Jordan Blacker <[email protected]>
@jblacker
Copy link
Contributor Author

It looks like the test failures are all coming from different providers. What's the process for handling this situation?

@beeme1mr
Copy link
Member

It looks like the test failures are all coming from different providers. What's the process for handling this situation?

I'm going to rerun the test to see if it's flaky.

@toddbaert
Copy link
Member

I'm looking into the e2e failures, they might be unrelated to your change.

@beeme1mr
Copy link
Member

Hey @jblacker, I wasn't able to merge this today due to the failing tests. My theory is that your pr bumps the OpenFeature sdk to the version that added state management. I think some of the provider tests do not handle this properly. Unfortunately, I didn't have a chance to test this theory today.

@jblacker
Copy link
Contributor Author

Oh interesting. I would not have expected that different modules with their own go.mod & go.sum would allow running with a different dependency version. Not sure how that's possible, but I did dig through the logs to look into your theory and I think you're right.

go clean -testcache && go list -f '{{.Dir}}/...' -m | xargs -I{} go test -tags=e2e {}
go: downloading go.opentelemetry.io/otel v1.34.0
go: downloading github.com/open-feature/go-sdk v1.14.1

This is the third line called after make e2e is called. That's well before it gets to the multi-provider module, so it's running those flagd tests with v1.14.1, when the go.mod specifies 1.9.0. I saw that all other modules are set to v1.11.0. I can downgrade this module to keep things moving.

Signed-off-by: Jordan Blacker <[email protected]>
Signed-off-by: Jordan Blacker <[email protected]>
- Replace openfeature's test provider from v1.14 with the `InMemoryProvider`
- Comment out ProviderFatalCode from `strategies.cleanErrorMessage`

Signed-off-by: Jordan Blacker <[email protected]>
Signed-off-by: Jordan Blacker <[email protected]>
@jblacker jblacker force-pushed the 599/implement-multiprovider branch from c412ed2 to 71a9f29 Compare April 25, 2025 23:21
@beeme1mr
Copy link
Member

It looks like that helped but now there's an issue with the multi-provider e2e testing. I'm surprised that this change affects other packages. We'll need to invest time into improving our tooling.

@jblacker
Copy link
Contributor Author

jblacker commented Apr 25, 2025

Forgot to sign off and had to clean it up. And fixed that last broken test. We should be good to go now. I ended up downgrading the SDK to the highest version another module was using, which was v1.13.1

@beeme1mr beeme1mr merged commit d35f4d6 into open-feature:main Apr 25, 2025
5 checks passed
@beeme1mr
Copy link
Member

Thanks @jblacker! Would you be interested in joining the org? There's no obligation but it's the first step in the contributor ladder and it makes it easier to collaborate on GitHub.

@jblacker
Copy link
Contributor Author

Yeah, definitely! Let me know what I need to do to get started

@jblacker jblacker deleted the 599/implement-multiprovider branch April 26, 2025 00:09
@beeme1mr beeme1mr linked an issue Apr 26, 2025 that may be closed by this pull request
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.

Implement Multi-Provider
9 participants