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

feat: Update in-process resolver to support flag metadata #1102 #1122

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrfwow
Copy link

@chrfwow chrfwow commented Jan 2, 2025

This PR

Adds support for flag metadata in the in-process resolver

Related Issues

Fixes #1102

return fallBackMetadata;
}

ImmutableMetadata.ImmutableMetadataBuilder metadataBuilder = ImmutableMetadata.builder();
Copy link
Author

Choose a reason for hiding this comment

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

I would prefer to have a mergeMetdata or addMetadata method in the ImmutableMetadataBuilder

@@ -79,7 +81,7 @@ public void eventHandling() throws Throwable {
final MutableStructure syncMetadata = new MutableStructure();
syncMetadata.add(key, val);

InProcessResolver inProcessResolver = getInProcessResolverWth(new MockStorage(new HashMap<>(), sender),
InProcessResolver inProcessResolver = getInProcessResolverWith(new MockStorage(new HashMap<>(), sender),
Copy link
Author

Choose a reason for hiding this comment

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

I assume this was a typo

@toddbaert toddbaert closed this Jan 6, 2025
@toddbaert toddbaert reopened this Jan 6, 2025
@toddbaert toddbaert marked this pull request as ready for review January 6, 2025 19:37
@toddbaert toddbaert requested a review from a team as a code owner January 6, 2025 19:37
@toddbaert toddbaert marked this pull request as draft January 6, 2025 19:38
@toddbaert toddbaert force-pushed the feat/Update-in-process-resolver-to-support-flag-metadata branch 3 times, most recently from 1fa47fc to 1285149 Compare January 6, 2025 20:52
@toddbaert toddbaert force-pushed the feat/Update-in-process-resolver-to-support-flag-metadata branch from 1285149 to c08e7bc Compare January 6, 2025 20:52
@toddbaert toddbaert mentioned this pull request Jan 6, 2025
@toddbaert
Copy link
Member

toddbaert commented Jan 6, 2025

@chrfwow this is definitely a step in the right direction - I think there's probably some null check missing related to the metadata causing the e2e failures: Run 1: Cannot invoke "dev.openfeature.sdk.Structure.asMap()" because "structure" is null

Working with @beeme1mr and a few others in in slack, we've decided another thing we'd want here is a very basic mechanism for reducing duplication: the ability to add metadata for the entire flag set at the "top level" which all flags inherit:

{
  "metadata": {
    "foo": "bar"
  },
  "flags": {
    "flag1": {
      // ...
      "metadata": {
        // "foo":  "bar" is automatically included, but can be overridden if defined in `flag1`
      }
    }
  }
}

The same thing is implemented here: open-feature/js-sdk-contrib#1120

See: https://github.com/open-feature/flagd-schemas/blob/37baa2cdea48a5ac614ba3e718b7d02ad4120611/json/flags.json#L53

cc @beeme1mr

@JsonProperty("defaultVariant") String defaultVariant,
@JsonProperty("variants") Map<String, Object> variants,
@JsonProperty("targeting") @JsonDeserialize(using = StringSerializer.class) String targeting,
@JsonProperty("metadata") Map<String, Object> metadata
Copy link
Member

Choose a reason for hiding this comment

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

[question] Currently, we do need to provide an empty map everywhere to be backward compatible. Could we also omit this parameter and make it optional? more a question out of curiosity ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[flagd] Update in-process resolver to support flag metadata
8 participants