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

refactor: Add ConfidenceInstance and FlagReaderForProvider interfaces #147

Closed
wants to merge 2 commits into from

Conversation

fabriziodemaria
Copy link
Member

@fabriziodemaria fabriziodemaria commented Jun 20, 2024

  • Confidence has two builder outputs:
    • Regular build that returns a ConfidenceInstance, for users to resolve and upload events;
    • A buildForProvider (meant to be used only by the Confidence Provider), which returns a FlagReaderForProvider: this latter interface allows to call resolve while passing in a different SDK_ID. It also allows to create child resolvers internally, which is instead NOT allowed by the user-facing ConfidenceInstance (the latter only allows to create EventSenders as children)

Alternative to #146

Comment on lines -46 to -63
@Test
public void testCloseChildShouldNotAffectParent()
throws IOException, ExecutionException, InterruptedException {
final Confidence child = root.withContext(Map.of("child-key", ConfidenceValue.of("child")));
child.close();
root.resolveFlags("test", false).get();
root.track("test", ConfidenceValue.of(Map.of("messageKey", ConfidenceValue.of("parent"))));
}

@Test
public void testCloseParentShouldAffectChild() throws IOException {
final Confidence child = root.withContext(Map.of("child-key", ConfidenceValue.of("child")));
root.close();
assertThrows(IllegalStateException.class, () -> child.resolveFlags("test", false).get());
assertThrows(IllegalStateException.class, () -> root.resolveFlags("test", false).get());
assertTrue(fakeEngine.closed);
assertTrue(fakeFlagResolverClient.closed);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

The child of root.withContext is only an EventSender, doesn't allow resolves. I think this is a limitation we actually wanted to introduce?

@fabriziodemaria fabriziodemaria marked this pull request as draft June 24, 2024 15:07
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.

None yet

1 participant