SDK quick linksLaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:
| Resource | Location |
|---|---|
| SDK API documentation | SDK API docs |
| Supported SDK Versions | Akamai SDK Akamai SDK for EdgeKV |
| GitHub repository | LaunchDarkly Akamai SDK |
- The Akamai SDK gets all flags at the edge for a given context, and bootstraps them onto a cached payload
- The client-side SDK initializes the bootstrapped payload
- The client-side SDK evaluates the flags and sends events back to LaunchDarkly
Using this SDK with Akamai EdgeKV requires LaunchDarkly’s Akamai integrationIf you are using Akamai EdgeKV, configure the Akamai integration to use this SDK successfully. To learn more, read Akamai.The Akamai integration is only available to customers on select plans. To learn more, read about our pricing. To upgrade your plan, contact Sales.If you are using Akamai’s EdgeWorkers, but not using the Akamai EdgeKV, the Akamai integration is not required.
Get started
After you complete the Create an Akamai integration process in an existing project, follow these instructions to start using the LaunchDarkly Akamai SDK if you are using Akamai EdgeKV:- Install the SDK
- Initialize the client
- Evaluate a flag
- Understand resource limits and caching options
Install the SDK
Install the Akamai SDK as a dependency in your application using your application’s dependency manager:init method in your application code:
Initialize the client
After you install and import the SDK, initialize the client with your LaunchDarkly SDK client-side ID and the namespace and group from your Akamai EdgeKV. These should be the same namespace and group that you used to configure the Akamai integration. Here’s how to initialize the client:Evaluate a flag
Using the client, check which variation a particular context will receive for a given feature flag:Understand resource limits and caching options
Every time you evaluate a flag, the SDK fetches the flag data from the EdgeKV store. Your Akamai resource tier may limit how many of these queries you can make while a single worker handler is being executed. To help alleviate this limit, the Akamai SDK includes a cache, which it checks before fetching flag data from the EdgeKV store. This cache is populated on the initial usage of the SDK, and then periodically as it expires. By default, the cache time to live (TTL) is 100ms, but you can configure this using thecacheTtlMs option in LDOptions. You can also choose:
- a different value, by specifying the duration in ms,
- an indefinite cache by specifying
0, or - no cache, by specifying a negative value.
Using Akamai EdgeWorkers with your own feature store
Expand for instructions if you are using Akamai EdgeWorkers with a non-EdgeKV store
Expand for instructions if you are using Akamai EdgeWorkers with a non-EdgeKV store
Most customers use the Akamai EdgeKV and the Akamai integration. If you are using Akamai’s EdgeWorkers, but not using the Akamai EdgeKV store, you can use the LaunchDarkly Akamai SDK to access your own feature store instead. However, the package and method names are slightly different. Additionally, you are responsible for putting flag data into your EdgeWorker. LaunchDarkly does not provide an integration for this.To install and configure the Akamai SDK if you are using Akamai EdgeWorkers with a non-EdgeKV store:
-
Install the Akamai SDK as a dependency in your application using your application’s dependency manager:
-
Import the
initmethod in your application code: -
Create a new class that implements
EdgeProvider. It should take a key, formatted asLD-Env-{your LaunchDarkly client-side ID for this environment}. It should return a promise to return flag data. To learn more about how to retrieve and store flag data, read Create a flag data file. To learn more, readEdgeProvider. Here’s an example: -
After you install and import the SDK, initialize the client with your LaunchDarkly SDK client-side ID and an instance of the class you created in the previous step.
Here’s how:
-
Using the client, check which variation a particular context will receive for a given feature flag:
Promises and async
All asynchronous SDK methods that return aPromise are compatible with then/catch or async/await. You can use either.