aws-powertools / powertools-lambda

MIT No Attribution
73 stars 4 forks source link

Feature flags: Support non-boolean values #71

Closed ran-isenberg closed 2 years ago

ran-isenberg commented 3 years ago

Today, the utility feature flags support boolean flags. The utility support only boolean values at the moment, hence the wording "flag". The utility can support more complex rule match values. I'd like to be able to provide a session context and get back according to the rule engine a more complex object such as Dict, list etc.

alexsh-ca commented 3 years ago

Great idea. Perhaps the parameters utility can be integrated with this somehow? The feature flags utility documentation states that "You can use Parameters utility for static flags while this utility can do both static and dynamic feature flags." So perhaps it's a matter of extending the Parameters utility so it can also be dynamic, like feature flags?

ran-isenberg commented 3 years ago

@alexsh-ca Thanks for the support! I think the feature flags could use some re-branding if we add this feature. To me, it's much more than a feature flags utility. It's a full fledged configuration utility- you have smart feature flags and you have the RAW configuration getter. Another feature would be "smart" configuration, not just True/False. One complete package, something similar to what other solution offers in their SDK (LaunchDarkly come into mind) .

So they way I see it, is we add a new function and a new subsection for the complex engine in the json file and perhaps an updated schema (maybe add a new field for when_match field type etc.).

ran-isenberg commented 3 years ago

@heitorlessa see https://github.com/awslabs/aws-lambda-powertools-python/pull/804 for a working POC

michaelbrewer commented 3 years ago

Note that LaunchDarkly python library is completely un typed

ran-isenberg commented 3 years ago

@michaelbrewer what do you mean? to my understanding, LaunchDarkly's API returns 'ANY' for an evaluated feature value. I was able to achieve this behavior in this PR.

michaelbrewer commented 3 years ago

Just saying that powertools includes helpful type hinting. Where as LaunchDarkly just has none

heitorlessa commented 2 years ago

Hey @ran-isenberg thanks again for the initial implementation! This is available on 1.24 ;)

https://awslabs.github.io/aws-lambda-powertools-python/latest/utilities/feature_flags/#beyond-boolean-feature-flags