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

Dynamic Config Resolver #459

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

andrew4699
Copy link
Contributor

@andrew4699 andrew4699 commented Nov 20, 2024

Description

Introduces the notion of a DynamicFeatureConfigResolver, which can be used to dynamically resolve featureConfiguration values at runtime. This is intended for integration with feature flag systems (Statsig, LaunchDarkly, etc) but this PR does not provide the implementations, rather just a hook to make it possible.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit tests
  • Tested end-to-end with a sample implementation

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • If adding new functionality, I have discussed my implementation with the community using the linked GitHub issue


@ParameterizedTest
@MethodSource("getTestConfigs")
public void testPrecedenceIsDynamicThenStaticPerRealmThenStaticGlobal(TestConfig testConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about catalog-level? I'd assume the catalog-level properties take precedence over everything, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on this it already should. I assumed there were tests already for that.

* integration with feature flag systems which are intended for fetching configs at runtime.
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
public interface DynamicFeatureConfigResolver extends Discoverable {
Copy link
Contributor

Choose a reason for hiding this comment

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

TBH, I feel that this type should be unnecessary. Unfortunately, we just added the featureConfiguration field as a map, rather than having the DefaultConfigurationStore instantiated and populated by Jackson during application startup. Now the configuration can't really change to add, e.g., a type configuration key so that we could use different PolarisConfigurationStore implementations. The PolarisConfigurationStore interface was always intended to support dynamic implementations - which is why the PolarisCallContext is part of the signature.

I'm just trying to figure out if there isn't a way to make the implementation swappable, while still supporting the backward-compatible configuration. I mean, there's no real harm in adding another interface, but it just feels unnecessary and the consequence of poor decision making earlier on. I hate the idea of that poor decision making having to follow us around forever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another option would be to make the whole implementation swappable as you mentioned, which could be implemented in a backward compatible way: if a custom type is specified, use it, otherwise use the default. I don't think this change makes that impossible in the future. In fact, you can simply make DynamicFeatureConfigResolver implement the entire configuration store.

@snazy
Copy link
Member

snazy commented Nov 22, 2024

What are the things that need / depend on this change?

@andrew4699
Copy link
Contributor Author

What are the things that need / depend on this change?

Hey @snazy I'm not sure I understand the intent of the question. This is the only change I have planned regarding dynamic configs, as this provides the hook necessary for implementors.

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.

3 participants