Skip to content

Commit 2bead61

Browse files
authored
updates for Java SDK 6.0.0 (#19)
1 parent 91ce1d8 commit 2bead61

File tree

11 files changed

+298
-210
lines changed

11 files changed

+298
-210
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55

66
This library provides a DynamoDB-backed persistence mechanism (data store) for the [LaunchDarkly Java SDK](https://github.com/launchdarkly/java-server-sdk), replacing the default in-memory data store.
77

8-
This version of the library requires at least version 5.10.0 of the LaunchDarkly Java SDK, and at least version 2.1 of the AWS SDK for Java. The minimum Java version is 8.
9-
10-
For Java SDK 5.0 through 5.9, use the latest 3.x version of this library. For Java SDK 4.x, use the latest 2.x version.
11-
12-
If you need to use Java 7, or if you are already using AWS SDK 1.x for some other purpose, you can use the 1.x releases of this library (which are developed on the "aws-v1" branch of the repository).
8+
This version of the library requires at least version 6.0.0 of the LaunchDarkly Java SDK, and at least version 2.1 of the AWS SDK for Java. For versions of the library to use with earlier SDK versions, see the changelog. The minimum Java version is 8.
139

1410
See the [API documentation](https://launchdarkly.github.io/java-server-sdk-dynamodb) for details on classes and methods.
1511

@@ -26,7 +22,7 @@ This assumes that you have already installed the LaunchDarkly Java SDK.
2622
<dependency>
2723
<groupId>com.launchdarkly</groupId>
2824
<artifactId>launchdarkly-java-server-sdk-dynamodb-store</artifactId>
29-
<version>3.0.0</version>
25+
<version>5.0.0</version>
3026
</dependency>
3127

3228
3. 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.)

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ allprojects {
3838
}
3939

4040
ext.versions = [
41-
"sdk": "5.10.0", // the *lowest* version we're compatible with
41+
"sdk": "6.0.0-SNAPSHOT", // the *lowest* version we're compatible with
4242
"dynamodb": "2.10.32"
4343
]
4444

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=4.0.0
1+
version=5.0.0-SNAPSHOT
22
ossrhUsername=
33
ossrhPassword=
44

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.launchdarkly.sdk.server.integrations;
22

3-
import com.launchdarkly.sdk.server.interfaces.BigSegmentStoreFactory;
4-
import com.launchdarkly.sdk.server.interfaces.PersistentDataStoreFactory;
3+
import com.launchdarkly.sdk.server.Components;
4+
import com.launchdarkly.sdk.server.subsystems.BigSegmentStore;
5+
import com.launchdarkly.sdk.server.subsystems.ComponentConfigurer;
6+
import com.launchdarkly.sdk.server.subsystems.PersistentDataStore;
57

68
/**
79
* Integration between the LaunchDarkly SDK and DynamoDB.
@@ -12,33 +14,27 @@ public abstract class DynamoDb {
1214
/**
1315
* Returns a builder object for creating a DynamoDB-backed data store.
1416
* <p>
15-
* This can be used either for the main data store that holds feature flag data, or for the Big
16-
* Segment store, or both. If you are using both, they do not have to have the same parameters.
17-
* For instance, in this example the main data store uses a table called "table1" and the Big
18-
* Segment store uses a table called "table2":
17+
* This is for the main data store that holds feature flag data. To configure a
18+
* Big Segment store, use {@link #bigSegmentStore(String)} instead.
19+
* <p>
20+
* You can use methods of the builder to specify any non-default DynamoDB options
21+
* you may want, before passing the builder to {@link Components#persistentDataStore(ComponentConfigurer)}.
22+
* In this example, the data store uses a table called "table1" and a namespace prefix of "prefix1":
1923
*
2024
* <pre><code>
2125
* LDConfig config = new LDConfig.Builder()
2226
* .dataStore(
2327
* Components.persistentDataStore(
24-
* DynamoDb.dataStore("table1")
25-
* )
26-
* )
27-
* .bigSegments(
28-
* Components.bigSegments(
29-
* DynamoDb.dataStore("table2")
28+
* DynamoDb.dataStore("table1").prefix("prefix1")
3029
* )
3130
* )
3231
* .build();
3332
* </code></pre>
3433
*
35-
* Note that the builder is passed to one of two methods,
36-
* {@link com.launchdarkly.sdk.server.Components#persistentDataStore(PersistentDataStoreFactory)} or
37-
* {@link com.launchdarkly.sdk.server.Components#bigSegments(BigSegmentStoreFactory)}, depending on
38-
* the context in which it is being used. This is because each of those contexts has its own
39-
* additional configuration options that are unrelated to the DynamoDb options. For instance, the
40-
* {@link com.launchdarkly.sdk.server.Components#persistentDataStore(PersistentDataStoreFactory)}
41-
* builder has options for caching:
34+
* Note that the SDK also has its own options related to data storage that are configured
35+
* at a different level, because they are independent of what database is being used. For
36+
* instance, the builder returned by {@link Components#persistentDataStore(ComponentConfigurer)}
37+
* has options for caching:
4238
*
4339
* <pre><code>
4440
* LDConfig config = new LDConfig.Builder()
@@ -57,16 +53,58 @@ public abstract class DynamoDb {
5753
* AWS credentials and region from AWS environment variables and/or local configuration files.
5854
* There are options in the builder for changing some configuration options, or you can
5955
* configure the DynamoDB client yourself and pass it to the builder with
60-
* {@link DynamoDbDataStoreBuilder#existingClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient)}.
56+
* {@link DynamoDbStoreBuilder#existingClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient)}.
6157
* <p>
6258
* If you are using the same DynamoDB table as a data store for multiple LaunchDarkly
63-
* environments, use the {@link DynamoDbDataStoreBuilder#prefix(String)} option and choose a
59+
* environments, use the {@link DynamoDbStoreBuilder#prefix(String)} option and choose a
6460
* different prefix string for each, so they will not interfere with each other's data.
65-
*
61+
*
6662
* @param tableName the table name in DynamoDB (must already exist)
6763
* @return a data store configuration object
6864
*/
69-
public static DynamoDbDataStoreBuilder dataStore(String tableName) {
70-
return new DynamoDbDataStoreBuilder(tableName);
65+
public static DynamoDbStoreBuilder<PersistentDataStore> dataStore(String tableName) {
66+
return new DynamoDbStoreBuilder.ForDataStore(tableName);
67+
}
68+
69+
/**
70+
* Returns a builder object for creating a DynamoDB-backed Big Segment store.
71+
* <p>
72+
* You can use methods of the builder to specify any non-default DynamoDB options
73+
* you may want, before passing the builder to {@link Components#bigSegments(ComponentConfigurer)}.
74+
* In this example, the store is configured to use a table called "table2" and a
75+
* namespace prefix of "prefix2":
76+
* <pre><code>
77+
* LDConfig config = new LDConfig.Builder()
78+
* .bigSegments(
79+
* Components.bigSegments(
80+
* DynamoDb.bigSegmentStore("table2").prefix("prefix2")
81+
* )
82+
* )
83+
* .build();
84+
* </code></pre>
85+
* <p>
86+
* Note that the SDK also has its own options related to Big Segments that are configured
87+
* at a different level, because they are independent of what database is being used. For
88+
* instance, the builder returned by {@link Components#bigSegments(ComponentConfigurer)}
89+
* has an option for the status polling interval:
90+
* <pre><code>
91+
* LDConfig config = new LDConfig.Builder()
92+
* .dataStore(
93+
* Components.bigSegments(
94+
* DynamoDb.bigSegmentStore("table2")
95+
* ).statusPollInterval(Duration.ofSeconds(30))
96+
* )
97+
* .build();
98+
* </code></pre>
99+
*
100+
* Note that the specified table must already exist in DynamoDB. It must have a partition key
101+
* of "namespace", and a sort key of "key".
102+
*
103+
* @param tableName the table name in DynamoDB (must already exist)
104+
* @return a Big Segment store configuration object
105+
* @since 3.0.0
106+
*/
107+
public static DynamoDbStoreBuilder<BigSegmentStore> bigSegmentStore(String tableName) {
108+
return new DynamoDbStoreBuilder.ForBigSegments(tableName);
71109
}
72110
}

src/main/java/com/launchdarkly/sdk/server/integrations/DynamoDbBigSegmentStoreImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package com.launchdarkly.sdk.server.integrations;
22

3-
import static com.launchdarkly.sdk.server.interfaces.BigSegmentStoreTypes.createMembershipFromSegmentRefs;
3+
import static com.launchdarkly.sdk.server.subsystems.BigSegmentStoreTypes.createMembershipFromSegmentRefs;
44

55
import com.launchdarkly.logging.LDLogger;
6-
import com.launchdarkly.sdk.server.interfaces.BigSegmentStore;
7-
import com.launchdarkly.sdk.server.interfaces.BigSegmentStoreTypes;
6+
import com.launchdarkly.sdk.server.subsystems.BigSegmentStore;
7+
import com.launchdarkly.sdk.server.subsystems.BigSegmentStoreTypes;
88

99
import java.util.List;
1010

1111
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
1212
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
1313
import software.amazon.awssdk.services.dynamodb.model.GetItemResponse;
1414

15-
public class DynamoDbBigSegmentStoreImpl extends DynamoDbStoreImplBase implements BigSegmentStore {
15+
final class DynamoDbBigSegmentStoreImpl extends DynamoDbStoreImplBase implements BigSegmentStore {
1616
private final static String MEMBERSHIP_KEY = "big_segments_user";
1717
private final static String INCLUDED_ATTR = "included";
1818
private final static String EXCLUDED_ATTR = "excluded";

src/main/java/com/launchdarkly/sdk/server/integrations/DynamoDbDataStoreBuilder.java

Lines changed: 0 additions & 145 deletions
This file was deleted.

src/main/java/com/launchdarkly/sdk/server/integrations/DynamoDbDataStoreImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.launchdarkly.sdk.server.integrations;
22

33
import com.launchdarkly.logging.LDLogger;
4-
import com.launchdarkly.sdk.server.interfaces.DataStoreTypes.DataKind;
5-
import com.launchdarkly.sdk.server.interfaces.DataStoreTypes.FullDataSet;
6-
import com.launchdarkly.sdk.server.interfaces.DataStoreTypes.KeyedItems;
7-
import com.launchdarkly.sdk.server.interfaces.DataStoreTypes.SerializedItemDescriptor;
8-
import com.launchdarkly.sdk.server.interfaces.PersistentDataStore;
4+
import com.launchdarkly.sdk.server.subsystems.DataStoreTypes.DataKind;
5+
import com.launchdarkly.sdk.server.subsystems.DataStoreTypes.FullDataSet;
6+
import com.launchdarkly.sdk.server.subsystems.DataStoreTypes.KeyedItems;
7+
import com.launchdarkly.sdk.server.subsystems.DataStoreTypes.SerializedItemDescriptor;
8+
import com.launchdarkly.sdk.server.subsystems.PersistentDataStore;
99

1010
import java.util.AbstractMap;
1111
import java.util.ArrayList;

0 commit comments

Comments
 (0)