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

Implement AWS AppConfig client service for Boolean typed feature flag #2

Merged
merged 13 commits into from
May 5, 2024

Conversation

lavenderses
Copy link
Owner

@lavenderses lavenderses commented May 5, 2024

What

Support boolean feature in OpenFeature reuirements with AWS AppConfig

relates #1

How

As described in #1, AWS AppConfig configuration response schema is like following.

{
  "{key name}": {
    // "Add new flag" > "Create flag" > "Off" or "On"
    "enabled": boolean,
    // "Add new flag" > "Create flag" > "Attribute (optional)"
    "{other attribute key 1}": number | string | boolean | regex,
    ...
  }
}

If I try to support other feature flag type such as number, string, using Attribute is required.
So, I decied following specification.

Provider spec

If Application Author created feature flag with name feature-1 in AWS console, he have to add Attribute (this is optional in AWS AppConfig spec, but this provider implementation forces Application Author to configure it) with name flag_value as Application Author's desired type.

(see about attribute in AWS doc.)

For example, if Application Author wants to use feature flag named user_id_for_test as number 123, configuration in AWS console will be following.
Any other attribute except for flag_value will be ignored in this provider implementation.

feature flag name user_id_for_test
attribute flag_value
attribute type number
attribute value 123

And, this provider implementation expects above and response will be like....

{
  "user_id_for_test": {
    "enabled": boolean,
    "flag_value": `Application Author's desired type`
  }
}

Provider feature flag evaluation behevior

  1. Returns feature flag value from AWS config only following items is satisfied.
    a. feature flag is enabled in AWS console. (= AWS AppConfig toggle is "On")
    b. flag_value is exist in attribute.
    c. flag_value type is same as Application Author's expected type.
  2. Returns reason = ERROR and errorCode = FLAG NOT FOUD when flag not found in AWS AppConfig.
  3. Returns reason = DISABLED when this feature flag is not enabled in AWS console. (= AWS AppConfig toggle is "Off")
  4. Returns reason = ERROR and errorCode = PARSE_ERROR when (1-a) does not satisfied
  5. Returns reason = ERROR and errorCode = TYPE_MISMATCH when (1-b) does not satisfied

These logic is implemented in AwsAppConfigParser and AppConfigValueConverter.

See also OpenFeature specification doc.
https://openfeature.dev/specification/types

Notes

N/A

@lavenderses lavenderses added the enhancement New feature or request label May 5, 2024
@lavenderses lavenderses self-assigned this May 5, 2024
@lavenderses lavenderses changed the title Implement AWS AppConfig client serivc for Boolean typed feature flag Implement AWS AppConfig client service for Boolean typed feature flag May 5, 2024
Copy link
Owner Author

@lavenderses lavenderses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lavenderses lavenderses merged commit ce46cc2 into main May 5, 2024
4 checks passed
@lavenderses lavenderses deleted the lavenderses/issue-1 branch May 5, 2024 09:17
@lavenderses lavenderses linked an issue May 5, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS AppConfig client implementation
1 participant