Add support for isExpired in configuration store to gate CDN requests… #61
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.
… (FF-2048)
labels: mergeable
Fixes: #issue
Motivation and Context
Customers with very short sessions (for example, chrome extensions) experience many more CDN requests than those with longer sessions. It is their interest to have more control over the rate of refreshes and balance that against being tolerant against stale flags.
For example, an owner of a chrome extension may know that during the lifetime of a financial transaction on a website where the extension is used repeatedly, a cool down period of 2 minutes will allow for a CDN request on the first open of the chrome extension to get the latest flags, while pausing CDN requests for subsequent requests in that period whenever the extension is re-opened.
We will provide an
isExpired
API to theConfigurationStore
and only perform CDN requests when the store declares itself as expired.The default case will likely be that
isExpired
returnstrue
always and the SDK behavior will be unchanged.Upstream clients will implement
isExpired
using the available APIs on their platforms and the desired policies. Paired with these changes will be support for acooldown
period which will be a user provided SDK init parameter that governs how often a client should be stale, even when the poller executes its callback.chrome extension
The other classes will implement the functions in similar ways, or choose to return whatever else is appropriate.
Description
Upstream clients will implement
isExpired
using the available APIs on their platforms.How has this been tested?
New unit tests
Questions for reviewers
Ultimately the "cooldown period" upstream clients will implement is not exact.
This approach continues running the poller and it acts as the clock - cool down periods significantly shorter than the period of the poller don't make much sense. However they will still be useful for stopping the initial request from happening during repeated short sessions - such as with the use case of the chrome extension.
The cooldown period will be implemented in the JS SDK for the configuration stores that need it.
isExpired
convey the correct meaning?It's important to get it right so users who implement their own persistent store have an understanding of its role in the SDK's operation.