java-sdk
java-sdk copied to clipboard
Provide better mechanism for "readiness"
We're using auto-polling and want to prevent our application's readiness check from going healthy until a config has been cached. However, there's not a great way to determine that because the client becomes initialized after maxInitWaitTimeSeconds regardless of if it has fetched a config, the onClientReady hook is also fired despite having no config, and from what I can find there are no public methods to get the cached config or last refresh time from the client.
We're currently working around it by calling ConfigCatClient.forceRefresh and inspecting the result, however that creates an unnecessary network call most of the time.
It would be nice if one or more was possible:
- Method(s) to get the cached config entry and/or json string
- Await-able method(s) to get the cached config entry and/or json string
- Method to get the last successful fetch time
- New hook/change behavior to have a "ready" hook that is only fired after the client is actually ready (which to me implies it has loaded a config)
Hi @croemmich, Thank you for reaching out!
I'd be moving further with the ready hook that accepts a parameter that could indicate in which state the SDK was initialized. Besides that, a method that returns a Future<InitState> that completes when the ready hook fires would also be beneficial. We have already done this in some of our other SDKs.
In other SDKs, we use these states:
noFlagDatahasLocalOverrideFlagDataOnlyhasCachedFlagDataOnlyhasUpToDateFlagData
What do you think?
Hi @croemmich,
I wanted to let you know that we released the v9.2.0 SDK version.
This version contains the following changes you may interested in:
- Your contribution, the
ReentrantReadWriteLockreplacement in theConfigCatHooks. - An updated
onClientReadyhook has aConsumer<ClientCacheState>parameter to provide information about the client state. - A new
waitForReadyAsyncmethod returns aCompletableFuture<ClientCacheState>, completed when the client is initialized.
I hope these changes will help you. If you have any questions, let us know!
This issue is marked stale because it has no activity in the last 3 weeks. The issue will be closed in one week. Please remove the stale flag to keep it open.
This issue was closed due to no activity.