Skip to content

Proposal: flags package for abstract usage of Feature Flags #684

@nelz9999

Description

@nelz9999

Much like the metrics package, I believe Feature Flags (/Toggles/etc...) should be handled similarly:

Metrics Feature 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) bool
  • OptString(context.Context) string
  • OptJSON(context.Context) json.RawMessage
  • OptInt64(context.Context) int64
  • OptFloat64(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.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions