-
Notifications
You must be signed in to change notification settings - Fork 45
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!: context enrichment via contextEnricher, not from init #991
Conversation
* SyncMetadata. | ||
* Set on initial connection and updated with every reconnection. | ||
* see: | ||
* https://buf.build/open-feature/flagd/docs/main:flagd.sync.v1#flagd.sync.v1.FlagSyncService.GetMetadata | ||
* | ||
* @return Object map representing sync metadata | ||
*/ | ||
protected Map<String, Object> getSyncMetadata() { | ||
return Collections.unmodifiableMap(syncMetadata); | ||
protected Structure getSyncMetadata() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a much safer type which we already use for this sort of thing.
@@ -149,6 +158,7 @@ private void onConnectionEvent(ConnectionEvent connectionEvent) { | |||
boolean previous = connected; | |||
boolean current = connected = connectionEvent.isConnected(); | |||
syncMetadata = connectionEvent.getSyncMetadata(); | |||
enrichedContext = contextEnricher.apply(connectionEvent.getSyncMetadata()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every time the resolver connects, we update the cached context by re-running the passed enricher.
@@ -177,6 +177,12 @@ By default, the provider is configured to | |||
use [least recently used (lru)](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/LRUMap.html) | |||
caching with up to 1000 entries. | |||
|
|||
##### Context enrichment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be used to select a subset of fields from the getMetadata
response. By default, all of it is injected into the context.
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/SyncMetadataHook.java
Outdated
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/SyncMetadataHook.java
Outdated
Show resolved
Hide resolved
ffa1893
to
faa9e80
Compare
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
…s/flagd/SyncMetadataHook.java Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
faa9e80
to
20300ab
Compare
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
contextEnricher
option added which does the above, and moreContinuation of #967.