Comments (7)
Apologies if this was already discussed and I realise I might be a bit late to this, but have you considered using functional options? It's an idiomatic and common way of passing options in Go.
As an example, I can point to OpenTelemetry's implementation for instrumentation options.
For OpenFeature, it could look something like this:
val, err := client.BooleanValue(
"someFlag",
false,
openfeature.EvaluationContext{},
openfeature.WithHooks(...),
openfeature.WithHints(...),
)
All options would be optional, and It achieves something similar to what is being proposed here. One drawback of the current proposed approach would have to deal with multiple EvaluationOptions
objects being passed (either ignoring or merging them).
from go-sdk.
@victorkt @skyerus ... what's not to like about this option?! Makes sense to me. I give it a +1.
Thanks for the suggestion.
from go-sdk.
I prefer the variadic approach, it makes for a cleaner interface
from go-sdk.
I've opened PRs for two potential improvements to the client API, we need to decide which approach is preferable (I prefer the second), or perhaps some combination of the two.
-
#63
This separates the flag calls into two, the first is a simplified call without theEvaluationOptions
parameter, the second is as before. This retains the enforcement of including theEvaluationContext
in all flag resolution calls. -
#64
This also separates the flag calls into two, both of which now haveEvaluationOptions
as a variadic parameter in order to simulate an "optional" parameter.
The original is now a simplified call without theEvaluationContext
parameter with the addition of a newWithContext
func that includes theEvaluationContext
parameter.
@james-milligan @beeme1mr @toddbaert
from go-sdk.
@toddbaert does your approval of #63 mean that's your preferred approach? James & I prefer the other approach
from go-sdk.
We settled on a middle ground approach of retaining the EvaluationContext
as a first class parameter and making the EvaluationOptions
variadic
from go-sdk.
Thanks for the eloquent explanation and example.
While I haven't seen this approach used in function calls (only seen in constructors e.g. func NewFoo()
), I don't see why we couldn't.
I actually think this is cleaner than our current variadic EvaluationOptions
, I'm all for it.
Interested to hear some other opinions on the matter though @james-milligan @toddbaert @beeme1mr @davejohnston
from go-sdk.
Related Issues (20)
- Update README to be consistent with other SDKs
- Changes to support spec `v0.6.0` compliance HOT 4
- implement named client support: open-feature/spec@4cf8229 HOT 1
- implement initialization/shutdown: open-feature/spec@a4ffec3
- Implement event support HOT 1
- Conform to spec `v0.7.0` HOT 6
- event handlers should run immediately if the associated provider is in the state associated with that handler already
- [FEATURE] Follow official Go guidance on how to organize a module? HOT 9
- [FEATURE] Follow up for 227 HOT 2
- [BUG] Panic when following getting started tutorial HOT 2
- [FEATURE] Blocking provider mutator HOT 1
- [FEATURE] Expose domain specific provider metadata getter HOT 1
- [FEATURE] Upgrade to Go version 1.20
- [FEATURE] Implement transaction context HOT 5
- [FEATURE] Implement domain scoping HOT 2
- [FEATURE] Make provider interface "stateless", SDK maintains provider state
- Should retrieving a value really provide an error? HOT 5
- [FEATURE] Move to log/slog logging HOT 2
- [BUG] Awkward usage when trying to evaluate a boolean flag in a complex conditional HOT 8
- [FEATURE] New test-oriented client HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-sdk.