|
| 1 | +LaunchDarkly SDK for Java - DynamoDB integration |
| 2 | +================================================ |
| 3 | + |
| 4 | +[](https://circleci.com/gh/launchdarkly/java-dynamodb-store) |
| 5 | +[](http://javadoc.io/doc/com.launchdarkly/launchdarkly-client-dynamodb-store) |
| 6 | +[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Flaunchdarkly%2Fjava-dynamodb-store?ref=badge_shield) |
| 7 | + |
| 8 | +This library provides a DynamoDB-backed persistence mechanism (feature store) for the [LaunchDarkly Java SDK](https://github.com/launchdarkly/java-client), replacing the default in-memory feature store. |
| 9 | + |
| 10 | +The minimum version of the LaunchDarkly Java SDK for use with this library is 4.6.0. It is compatible with Java 7 and above. |
| 11 | + |
| 12 | +It uses version 1.11 of the AWS SDK for Java; a future release will use version 2.x. |
| 13 | + |
| 14 | +For more information, see also: [Using a persistent feature store](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store). |
| 15 | + |
| 16 | +Quick setup |
| 17 | +----------- |
| 18 | + |
| 19 | +This assumes that you have already installed the LaunchDarkly Java SDK. |
| 20 | + |
| 21 | +0. Add this library to your project: |
| 22 | + |
| 23 | + <dependency> |
| 24 | + <groupId>com.launchdarkly</groupId> |
| 25 | + <artifactId>launchdarkly-client-dynamodb-store</artifactId> |
| 26 | + <version>1.0.0</version> |
| 27 | + </dependency> |
| 28 | + |
| 29 | +1. If you do not already have the AWS SDK in your project, add the DynamoDB part of it. (This needs to be added separately, rather than being included in the LaunchDarkly jar, because AWS classes are exposed in the public interface.) |
| 30 | + |
| 31 | + <dependency> |
| 32 | + <groupId>com.amazonaws</groupId> |
| 33 | + <artifactId>com.amazonaws:aws-java-sdk-dynamodb</artifactId> |
| 34 | + <version>1.11.327</version> |
| 35 | + </dependency> |
| 36 | + |
| 37 | +2. Import the LaunchDarkly package and the package for this library: |
| 38 | + |
| 39 | + import com.launchdarkly.client.*; |
| 40 | + import com.launchdarkly.client.dynamodb.*; |
| 41 | + |
| 42 | +3. When configuring your SDK client, add the DynamoDB feature store: |
| 43 | + |
| 44 | + DynamoDbFeatureStoreBuilder store = DatabaseComponents.dynamoDbFeatureStore("my-table-name") |
| 45 | + .caching(FeatureStoreCaching.enabled().ttlSeconds(30)); |
| 46 | + |
| 47 | + LDConfig config = new LDConfig.Builder() |
| 48 | + .featureStoreFactory(store) |
| 49 | + .build(); |
| 50 | + |
| 51 | + LDClient client = new LDClient("YOUR SDK KEY", config); |
| 52 | + |
| 53 | +The specified table must already exist in DynamoDB. It must have a partition key called "namespace" and a sort key called "key". |
| 54 | + |
| 55 | +By default, the DynamoDB client will try to get your AWS credentials and region name from environment variables and/or local configuration files, as described in the AWS SDK documentation. There are methods in `DynamoDBFeatureStoreBuilder` for changing the configuration options. Alternatively, if you already have a fully configured DynamoDB client object, you can tell LaunchDarkly to use that: |
| 56 | + |
| 57 | + DynamoDbFeatureStoreBuilder store = DatabaseComponents.dynamoDbFeatureStore("my-table-name") |
| 58 | + .existingClient(myDynamoDbClientInstance); |
| 59 | + |
| 60 | +Caching behavior |
| 61 | +---------------- |
| 62 | + |
| 63 | +To reduce traffic to DynamoDB, there is an optional in-memory cache that retains the last known data for a configurable amount of time. This is on by default; to turn it off (and guarantee that the latest feature flag data will always be retrieved from DynamoDB for every flag evaluation), configure the store as follows: |
| 64 | + |
| 65 | + DynamoDbFeatureStoreBuilder store = DatabaseComponents.dynamoDbFeatureStore("my-table-name") |
| 66 | + .caching(FeatureStoreCaching.disabled()); |
| 67 | + |
| 68 | +For other ways to control the behavior of the cache, see `DynamoDbFeatureStoreBuilder.caching()`. |
| 69 | + |
| 70 | +About LaunchDarkly |
| 71 | +----------- |
| 72 | + |
| 73 | +* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can: |
| 74 | + * Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases. |
| 75 | + * Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?). |
| 76 | + * Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file. |
| 77 | + * Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline. |
| 78 | +* LaunchDarkly provides feature flag SDKs for |
| 79 | + * [Java](http://docs.launchdarkly.com/docs/java-sdk-reference "Java SDK") |
| 80 | + * [JavaScript](http://docs.launchdarkly.com/docs/js-sdk-reference "LaunchDarkly JavaScript SDK") |
| 81 | + * [PHP](http://docs.launchdarkly.com/docs/php-sdk-reference "LaunchDarkly PHP SDK") |
| 82 | + * [Python](http://docs.launchdarkly.com/docs/python-sdk-reference "LaunchDarkly Python SDK") |
| 83 | + * [Go](http://docs.launchdarkly.com/docs/go-sdk-reference "LaunchDarkly Go SDK") |
| 84 | + * [Node.JS](http://docs.launchdarkly.com/docs/node-sdk-reference "LaunchDarkly Node SDK") |
| 85 | + * [Electron](http://docs.launchdarkly.com/docs/electron-sdk-reference "LaunchDarkly Electron SDK") |
| 86 | + * [.NET](http://docs.launchdarkly.com/docs/dotnet-sdk-reference "LaunchDarkly .Net SDK") |
| 87 | + * [Ruby](http://docs.launchdarkly.com/docs/ruby-sdk-reference "LaunchDarkly Ruby SDK") |
| 88 | + * [iOS](http://docs.launchdarkly.com/docs/ios-sdk-reference "LaunchDarkly iOS SDK") |
| 89 | + * [Android](http://docs.launchdarkly.com/docs/android-sdk-reference "LaunchDarkly Android SDK") |
| 90 | +* Explore LaunchDarkly |
| 91 | + * [launchdarkly.com](http://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information |
| 92 | + * [docs.launchdarkly.com](http://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDKs |
| 93 | + * [apidocs.launchdarkly.com](http://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation |
| 94 | + * [blog.launchdarkly.com](http://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates |
| 95 | + * [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies |
| 96 | + |
0 commit comments