Comments (6)
This has been proposed as a feature before, and the reason we haven't done it is that there's a conflict with the behavior of the analytics event system.
Specifically: when we report analytics for flag evaluations, we include not just the evaluated value, but also the default value. This shows up on your dashboard— so that you can see what value your applications are providing as a fallback in case flags aren't available, and adjust that in your code if you realize that it's not appropriate for that flag.
And that means that there isn't really such a thing as an evaluation where the SDK doesn't need to know the default value at all... which defeats the purpose of having something be lazily computed. The callback would always be called.
from java-server-sdk.
We did consider the option of simply not having the SDK report a default value if this feature is used, but at the time we felt that being able to see that value on the dashboard was a core feature.
from java-server-sdk.
That makes sense, thanks for the explanation. Feel free to close this
I was thinking of creating a wrapper around the client that takes a Supplier
instead of a native java value, but then realized it'll break at runtime if the Supplier
returns null. So another idea could be allowing null
as a defaultValue
in the SDK, but I'm assuming that has some bad tradeoffs
from java-server-sdk.
I was thinking of creating a wrapper around the client that takes a Supplier instead of a native java value
Could you say more about what that wrapper would actually do?
Again, the problem as I see it is that there is (currently) never a case in which the SDK doesn't use the default value parameter for something, even if it is only for analytics events. So if you tried to implement lazy computation of the default value using a Supplier, it wouldn't really be lazy; the Supplier would get called every single time.
Also, on rereading your original description of the issue, I'm not sure I understand your point about the current usage being "less readable". If you don't want to include a multi-line expression in your flag evaluation call, then you can simply move that logic into a helper method for computing the default value. That would be, as far as I can tell, 100% equivalent to what you're proposing with the Supplier— just a bit simpler.
from java-server-sdk.
Yeah I agree helper functions are good enough, although some might think it's nice to have the computation inline with a short lambda
Doesn't sound worth breaking the dashboard view you mentioned though
from java-server-sdk.
Well, maybe it's moot but I think I'm still missing your point. I mean - given that we can't really do lazy computation, the rationale would have to be that the syntax looks nicer. But if you're talking about a short lambda, then your original rationale of "it's less readable when there are multiple lines of computations" doesn't seem to apply. I mean, client.boolVariation(flagKey, user, () -> some kind of brief computation)
looks almost exactly the same as client.boolVariation(flagKey, user, some kind of brief computation)
. Like, literally all you would be doing is adding () ->
in front of the same expression.
If you do feel like discussing this further at all, I think an example of what you would want the usage to look like would be helpful.
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
- 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.