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

[Discussion] EvaluationOptions confusion #133

Closed
james-milligan opened this issue Aug 24, 2022 · 7 comments
Closed

[Discussion] EvaluationOptions confusion #133

james-milligan opened this issue Aug 24, 2022 · 7 comments

Comments

@james-milligan
Copy link
Contributor

The Evaluation Options structure is currently a little confusing when implementing a provider.

Currently the structure is as follows (taken from the golang-sdk, but mirrored in other languages):

type EvaluationOptions struct {
	hooks     []Hook
	hookHints HookHints
}

This structure is currently being passed from the Client to the FeatureProvider, this is intentional as the hookHints may be used to alter the behaviour of the given provider, such as mutating the resulting flag value before it is passed back into the client.
However, the FeatureProvider should not be altering the existing hooks, nor should it be calling their respective methods, so passing the hooks/hookHints as an argument may be a little confusing and breaks the separation of interest between the Client and FeatureProvider.

I propose that either an additional field should be added to the Evaluation Options structure, such as providerHints for use in the FeatureProvider, or for a similar structure to be passed to the provider directly to reduce confusion.

type EvaluationOptions struct {
	hooks     []Hook
	hookHints HookHints
        providerHints ProviderHints
}
type ProviderHints struct {
	mapOfHints map[string]interface{}
}

Personally I think that only passing relevant information to the FeatureProvider would be favourable in this situation, especially if the EvaluationOptions has the possibility of becoming bloated with hooks/hookHints that should not be used downstream from the Client

@james-milligan
Copy link
Contributor Author

@toddbaert
Copy link
Member

toddbaert commented Aug 24, 2022

I fully agree with the problem statement. I think we're leaking things to providers that we shouldn't (hooks, hookhints).

As for the solution, I would be open to either passing only providerHints as you suggest, or simply removing this argument entirely in the FeatureProvider interface (we may be solving problems we don't yet have).

Let's allow others to weight in.

@skyerus
Copy link
Contributor

skyerus commented Aug 24, 2022

My preference would be to remove the argument entirely if the provider has no need for it to avoid any future confusion.

@toddbaert
Copy link
Member

We could just rename hookHints to something more general, and then pass this bucket object to both hooks and providers as a way to supply arbitrary data to both. I'm still open to any of the above.

@justinabrahms
Copy link
Member

I vote to remove the argument. If a provider wants access to it, they can do that via provider hooks.

@beeme1mr
Copy link
Member

I vote to remove the argument. If a provider wants access to it, they can do that via provider hooks.

I completely agree and was just about to write the same thing. Simply removing the options arguments from the resolvers would make the separation more clear.

@james-milligan, could you please open a PR for this?

@benjiro
Copy link
Member

benjiro commented Aug 24, 2022

Yup totally agree with the problem statement. That's a +1 vote for me.

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

No branches or pull requests

6 participants