-
Notifications
You must be signed in to change notification settings - Fork 62
feat!: context enrichment via contextEnricher, not from init #991
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
Conversation
| */ | ||
| 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.
| 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.
| 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 <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
…s/flagd/SyncMetadataHook.java Signed-off-by: Todd Baert <[email protected]>
faa9e80 to
20300ab
Compare
Signed-off-by: Todd Baert <[email protected]>
contextEnricheroption added which does the above, and moreContinuation of #967.