Comments (9)
The 5.0.0 release is finally out, and the API for this new feature is slightly different from the beta releases. There are two ways you can listen for flag changes. First, to be notified of any flag configuration change, regardless of whether that change actually affects the value for any particular user:
client.getFlagTracker().addFlagChangeListener(changeEvent -> {
System.out.println("Someone has modified this flag: " + changeEvent.getKey());
});
For this type of event, the only information given is the flag key; it is just a notification that some type of change has happened, so you may want to re-evaluate that flag for whatever users you are interested in.
The other method is for more specifically monitoring the value of a specific flag for a specific user:
LDUser user = new LDUser("some-user-key");
client.getFlagTracker().addFlagValueChangeListener("special-flag", user, changeEvent -> {
System.out.println("The value has changed from " + changeEvent.getOldValue()
+ " to " + changeEvent.getNewValue());
});
If you have a flag that does not have any user targeting rules, but is just on or off for everyone, so the user properties do not matter, you would still use this method— just as you always have to provide some user properties when you call boolVariation
, stringVariation
, etc.
For more information, see FlagTracker.
from java-server-sdk.
That seems generally useful. Would an event listener pattern work for you?
from java-server-sdk.
Sounds good! Maybe some event listener for which you get an event with the feature flags that were changed or something like that?
from java-server-sdk.
Hi @jkodumal, any idea if this is something that will be worked on soon? Would you need help? Thanks!
from java-server-sdk.
This is something that we were looking to start in a few weeks, but we'd be happy to receive contributions and work with you on it if you need this sooner.
from java-server-sdk.
Any update on this? Was thinking of writing it myself.
from java-server-sdk.
This fell off of our roadmap at some point - sorry for the lack of follow-up. I think in order for us to implement this, we would need to define the use cases a little better, for instance:
- Does "the flag has changed" mean that the flag's value is now different when evaluated with a specific user; or does it mean that some property of the flag was changed in the LD app, regardless of whether that actually causes a value change for any user?
- What if the flag's own properties have not changed, but some prerequisite flag (or user segment) that it depends on has changed, so that you may now get a different result?
In order to be able to address the second point, I think this would probably have to be written by us rather than an external developer, because it would depend on details of the flag and segment data model which are intentionally not public (I mean, you can always see what the JSON structure of them is, but we keep them non-public in the Java code so that data model changes won't break things).
On the other hand, if all that matters is the simplest case in the first point (i.e. you just want to know if a flag has been edited), the implementation would be simpler: basically, you would use a FeatureStore
implementation that delegates all methods to the underlying feature store, and triggers the "flag has changed" logic whenever upsert
is called. But that would not be a particularly useful implementation for anyone who uses prerequisites and/or segments.
from java-server-sdk.
This feature will be in the 5.0.0 release. A beta release of 5.0.0-rc1 is coming this week, so watch the releases in this repository if you're interested in trying it out early.
from java-server-sdk.
For anyone who is curious, the beta release— which includes this notification feature— is out now, and we are hoping to release the real 5.0.0 within a couple of weeks.
from java-server-sdk.
Related Issues (20)
- Launch Darkly Metrics conflating Version numbers. HOT 3
- Getting numerous Error posting diagnostic event (giving up permanently): HTTP error 401 (invalid SDK key) HOT 2
- Synk reports the low version of okHttp3 dependency HOT 3
- Vulnerability in snakeyaml HOT 3
- LaunchDarkly Client initialing failed even add LaunchDarkly Certificate to java key store. HOT 9
- Add shaded libraries as dependencies to `-thin` jar HOT 2
- `isInitialized` & `dataStore.isInitialized()` HOT 3
- Please provide ability to `LDClient` in non-blocking manner HOT 4
- fat jar brings in duplicate copy of `launchdarkly-logging` HOT 3
- Allow lazily computed defaultValues in LDClient to improve code readability HOT 6
- java-server-sdk is vulnerable to CVE-2022-1471 RCE HOT 3
- Builder object is not exist in V6 but is taken as an example in the docs HOT 6
- Evaluation can throw when the same segment is used in multiple rules within a single flag HOT 6
- StreamClosedByServerException: Stream closed by server HOT 13
- Vulnerability CVE-2022-1471 is introduced via SnakeYaml 1.32. Upgrading to 2.0 should fix it. HOT 3
- Have a robust in memory datastore fallback when the persistent data store connection is not working HOT 2
- update to guava 32.0.0 to resolve CVE-2023-2976 HOT 6
- ApiException.getMessage throws NullPointerException when IOException occurs HOT 1
- Stream continuously reset HOT 2
- Support for use of java-server-sdk library in GraalVM native image applications HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-server-sdk.