Closed gaurav-rana closed 6 hours ago
Passing features not through String
type but through JsonObject
type was suggested in the PR. We can't remove old way through String
type because it leads to rewriting all tests, but to add also passing through JsonObject
type is OK.
So, JsonObject
type from Gson
library was added to public class GbContext
of the GrowthBook Java SDK. It can lead to forcing users of the SDK to include Gson
dependency in their apps. In order not to include Gson
in target builds if features are passed through String
type compileOnly
can be used:
compileOnly 'com.google.code.gson:gson:2.9.1'
The pull request is not merged in main
branch yet but the changes can be accessed using this:
<dependency>
<groupId>com.github.growthbook</groupId>
<artifactId>growthbook-sdk-java</artifactId>
<version>release~0.9.7-SNAPSHOT</version>
</dependency>
Great Thanks!
I'm waiting for the release 0.9.7
before i upgrade the SDK in my app.
0.9.7
version is available on JitPack
Thanks, closing this as completed.
The current GBContext implementation is suboptimal for java backend integrations. We have to create a new GBContext for each request, and because the CustomGbContextBuilder only supports StringType featureJson, we have to pass featureJson as string and it parses the JSON (converting from String to JSONType) for each and every request. This can be avoided by letting the application maintain JSON and set JSON directly.
Flame graph with the current GBContext:
As we can see, around 42% of total CPU is spent inside parsing this JSON for each and every request, this overhead can be clearly avoided by letting the client set the JSON directly instead of string.
I've added the support in this PR https://github.com/growthbook/growthbook-sdk-java/pull/76