Add cache generalization & Snapshots for synchronous support #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the purpose of your pull request
This PR contains the following:
Enables the generalized caching feature.
Removes deprecated functions:
getVariationId()
andgetAllVariationIds()
, alternative:getValueDetails()
/getAllValueDetails()
.refresh()
, alternative:forceRefresh()
.PollingModes.autoPoll()
that had anonConfigChanged
callback parameter. Alternative for subscribing to config changes: Hooks.***Sync()
method that usedDispatchSemaphore
for synchronizing mainly asynchronous operations. For an alternative, see the next bullet point.Introduces the concept of Snapshots. They are for capturing the actual state of the feature flag data used by the SDK. A snapshot allows synchronous operations on the captured context.
Snapshots are created from the actual state of the SDK; therefore it's crucial to know whether the SDK has valid feature flag data to work on. To determine whether it's safe to create snapshots, the SDK already provides an
onClientReady
hook. It's being changed to accept astate
parameter to give details about the SDK's initialization state.These are the possible
state
values:noFlagData
: This means the SDK has no feature flag data to work on (it didn't get anything from the cache or from the network)hasLocalOverrideFlagDataOnly
: The SDK was initialized withlocalOnly
flag overrides.hasCachedFlagDataOnly
: The SDK has feature flag data from only the cache. It can happen when the SDK is configured withPollingModes.manualPoll()
and there wasn't aclient.forceRefresh()
call yet. Another example could be an SDK configured withPollingModes.autoPoll()
, but it can't reach the ConfigCat CDN so it falls back to the cache.hasUpToDateFlagData
: The SDK is initialized with up-to-date feature flag data.This functionality was extended with a new awaitable method
waitForReady()
that asynchronously waits for theonClientReady
hook to fire and also returns with the SDK's initialization state.Related issues (only if applicable)
n/a
Requirement checklist (only if applicable)