-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Much like the metrics package, I believe Feature Flags (/Toggles/etc...) should be handled similarly:
MetricsFeature Flags are dependencies, and should be passed to the components that need them in the same way you'd construct and pass a database handle, or reference to another component.
Would the project be open to receiving a contribution of a flags package, contained in it a couple of helper and concrete implementation packages: default (always returns the same value); random (randomly delivers results from a discrete list of options); launchdarkly (because this the service I use in my own projects).
The set of interfaces would probably be a bit wider than the 3 main interfaces in metrics, maybe something akin to this:
OptBool(context.Context) boolOptString(context.Context) stringOptJSON(context.Context) json.RawMessageOptInt64(context.Context) int64OptFloat64(context.Context) float64
This would standardize on using context.Context to hold any targeting information. (E.g. LaunchDarkly uses their own User struct for deciding on which option to return.)