The client SDK needs to know when an experiment's configuration changes. For example, if the experiment percent exposure changes from 100% to 0%, the SDK assign function will stop assigning variations and always return null.
Description
This PR implements polling of the RAC endpoint to retrieve the most up-to-date configurations (the design doc also considered a push-based approach instead of polling). Once the RAC is retrieved, the SDK stores it in a local in-memory cache:
When invoking the assign function, it uses the configurations from the local cache (except on the first request because the poller hasn't started yet)
Getting assignment
Getting configurations from network request
Got assignment variation-1
Getting assignment
Getting configurations from local cache
Got assignment variation-1
Polling experiment configurations...
Getting assignment
Getting configurations from local cache
Got assignment variation-1
Polling experiment configurations...
Getting assignment
Getting configurations from local cache
Got assignment variation-1
- Verified query params are sent in the HTTP request:
- `apiKey`: "test-api-key"
- `sdkName`: "node-server-sdk"
- `sdkVersion`: "1.0.0"
- The `assign function responds to RAC changes on the backend
Getting assignment
Got assignment variation-1
Getting assignment
Got assignment variation-1
------ CHANGE to ZERO PERCENT EXPOSURE ----
Getting assignment
Got assignment null
Getting assignment
Got assignment null
[//]: # (OPTIONAL)
[//]: # (Add one or multiple labels: enhancement, refactoring, bugfix)
Fixes: #issue
Motivation and Context
The client SDK needs to know when an experiment's configuration changes. For example, if the experiment percent exposure changes from 100% to 0%, the SDK
assign
function will stop assigning variations and always return null.Description
This PR implements polling of the RAC endpoint to retrieve the most up-to-date configurations (the design doc also considered a push-based approach instead of polling). Once the RAC is retrieved, the SDK stores it in a local in-memory cache:
How has this been tested?
assign
function, it uses the configurations from the local cache (except on the first request because the poller hasn't started yet)Getting assignment Getting configurations from local cache Got assignment variation-1
Polling experiment configurations... Getting assignment Getting configurations from local cache Got assignment variation-1
Polling experiment configurations... Getting assignment Getting configurations from local cache Got assignment variation-1
Getting assignment Got assignment variation-1
Getting assignment Got assignment variation-1
------ CHANGE to ZERO PERCENT EXPOSURE ----
Getting assignment Got assignment null
Getting assignment Got assignment null