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 structure type feature flag client #4

Merged
merged 9 commits into from
May 5, 2024

Conversation

lavenderses
Copy link
Owner

@lavenderses lavenderses commented May 5, 2024

What

Implement conversion to Value, supporting Structure type feature flag value.

close #3

How

Expecting JSON format string value in flag_value.
Because of AWS AppConfig feature flag schema limitation (flag value cannot be nested), the spec for structure-type feature flag in this provider implementation is putting JSON string to flag_value attribute.

JSON Structure could be nested object. The value might be primitive like A, or nested JSON like B.

// A
{
  "{key name}": {
    "enable": true,
    // NOTE that this `flag_value` is primitive like number / string / boolean
    "flag_value": 12345
  }
}
// B
{
  "{key name}": {
    "enable": true,
    // NOTE that this `flag_value` is nested JSON
    "flag_value": {
      "foo": {
        "bar": 12345,
      },
      "qux": "quux"
    }
  }
}

So, the logic is converting feature flag string value to JsonNode, and then walk through DFS-ly and build nested Value. This is AppConfigParser#convertJsonNodeAsValueRecursively implementation.
See example in tests in AppConfigParserTest.ConvertJsonNodeAsValueRecursively class.

Note

This might confusing because some case might exist that geting feature flag value as structure unexpectedly, not as string.
But, this might never happen.
For example, some Application Authors want to get feature flag value as string (A in above example), not as structure.
In this case, they will call Evaluation API with getStringValue. So, type mismatching will not occur.

Notes

N/A

@lavenderses lavenderses added enhancement New feature or request requirements Implementation for OpenFeature Provider requirements labels May 5, 2024
@lavenderses lavenderses self-assigned this 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 4d20efe into main May 5, 2024
4 checks passed
@lavenderses lavenderses deleted the lavenderses/issue-3 branch May 5, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request requirements Implementation for OpenFeature Provider requirements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support JSON / YAML schema object flag as Value
1 participant