Skip to content

Commit 0055cfd

Browse files
committed
Merge branch 'v2' into eb/v2-initial
# Conflicts: # src/main/java/com/launchdarkly/client/dynamodb/DynamoDbFeatureStoreBuilder.java # src/main/java/com/launchdarkly/client/dynamodb/DynamoDbFeatureStoreCore.java # src/test/java/com/launchdarkly/client/dynamodb/DynamoDbFeatureStoreTest.java
2 parents 9450a23 + 6b23c49 commit 0055cfd

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This assumes that you have already installed the LaunchDarkly Java SDK.
3939

4040
3. When configuring your SDK client, add the DynamoDB feature store:
4141

42-
DynamoDBFeatureStoreBuilder store = DatabaseComponents.dynamoDBFeatureStore("my-table-name")
42+
DynamoDbFeatureStoreBuilder store = DatabaseComponents.dynamoDbFeatureStore("my-table-name")
4343
.caching(FeatureStoreCaching.enabled().ttlSeconds(30));
4444
4545
LDConfig config = new LDConfig.Builder()
@@ -52,18 +52,18 @@ The specified table must already exist in DynamoDB. It must have a partition key
5252

5353
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:
5454

55-
DynamoDBFeatureStoreBuilder store = DatabaseComponents.dynamoDBFeatureStore("my-table-name")
56-
.existingClient(myDynamoDBClientInstance);
55+
DynamoDbFeatureStoreBuilder store = DatabaseComponents.dynamoDbFeatureStore("my-table-name")
56+
.existingClient(myDynamoDbClientInstance);
5757

5858
Caching behavior
5959
----------------
6060

6161
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:
6262

63-
DynamoDBFeatureStoreBuilder store = DatabaseComponents.dynamoDBFeatureStore("my-table-name")
63+
DynamoDbFeatureStoreBuilder store = DatabaseComponents.dynamoDbFeatureStore("my-table-name")
6464
.caching(FeatureStoreCaching.disabled());
6565

66-
For other ways to control the behavior of the cache, see `DynamoDBFeatureStoreBuilder.caching()`.
66+
For other ways to control the behavior of the cache, see `DynamoDbFeatureStoreBuilder.caching()`.
6767

6868
About LaunchDarkly
6969
-----------

src/main/java/com/launchdarkly/client/dynamodb/DatabaseComponents.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
public abstract class DatabaseComponents {
99
/**
1010
* Creates a builder for a DynamoDB feature store. You can modify any of the store's properties with
11-
* {@link DynamoDBFeatureStoreBuilder} methods before adding it to your client configuration with
11+
* {@link DynamoDbFeatureStoreBuilder} methods before adding it to your client configuration with
1212
* {@link LDConfig.Builder#featureStoreFactory(com.launchdarkly.client.FeatureStoreFactory)}.
1313
*
1414
* @param tableName The table name in DynamoDB. This table must already exist (see package
1515
* documentation).
1616
* @return the builder
1717
*/
18-
public static DynamoDBFeatureStoreBuilder dynamoDBFeatureStore(String tableName) {
19-
return new DynamoDBFeatureStoreBuilder(tableName);
18+
public static DynamoDbFeatureStoreBuilder dynamoDbFeatureStore(String tableName) {
19+
return new DynamoDbFeatureStoreBuilder(tableName);
2020
}
2121
}

src/main/java/com/launchdarkly/client/dynamodb/DynamoDBFeatureStoreBuilder.java renamed to src/main/java/com/launchdarkly/client/dynamodb/DynamoDbFeatureStoreBuilder.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Builder/factory class for the DynamoDB feature store.
1919
* <p>
20-
* Create this builder by calling {@link DatabaseComponents#dynamoDBFeatureStore(String)}, then
20+
* Create this builder by calling {@link DatabaseComponents#dynamoDbFeatureStore(String)}, then
2121
* optionally modify its properties with builder methods, and then include it in your client
2222
* configuration with {@link LDConfig.Builder#featureStoreFactory(FeatureStoreFactory)}.
2323
* <p>
@@ -26,7 +26,7 @@
2626
* control over the DynamoDB client, you can construct one of your own and pass it in with the
2727
* {@link #existingClient(DynamoDbClient)} method.
2828
*/
29-
public class DynamoDBFeatureStoreBuilder implements FeatureStoreFactory {
29+
public class DynamoDbFeatureStoreBuilder implements FeatureStoreFactory {
3030
private final String tableName;
3131

3232
private String prefix;
@@ -35,15 +35,15 @@ public class DynamoDBFeatureStoreBuilder implements FeatureStoreFactory {
3535

3636
private FeatureStoreCaching caching = FeatureStoreCaching.DEFAULT;
3737

38-
DynamoDBFeatureStoreBuilder(String tableName) {
38+
DynamoDbFeatureStoreBuilder(String tableName) {
3939
this.tableName = tableName;
4040
clientBuilder = DynamoDbClient.builder();
4141
}
4242

4343
@Override
4444
public FeatureStore createFeatureStore() {
4545
DynamoDbClient client = (existingClient != null) ? existingClient : clientBuilder.build();
46-
DynamoDBFeatureStoreCore core = new DynamoDBFeatureStoreCore(client, tableName, prefix);
46+
DynamoDbFeatureStoreCore core = new DynamoDbFeatureStoreCore(client, tableName, prefix);
4747
CachingStoreWrapper wrapper = new CachingStoreWrapper.Builder(core).caching(caching).build();
4848
return wrapper;
4949
}
@@ -54,7 +54,7 @@ public FeatureStore createFeatureStore() {
5454
* @param config an AWS client configuration object
5555
* @return the builder
5656
*/
57-
public DynamoDBFeatureStoreBuilder clientOverrideConfiguration(ClientOverrideConfiguration config) {
57+
public DynamoDbFeatureStoreBuilder clientOverrideConfiguration(ClientOverrideConfiguration config) {
5858
clientBuilder.overrideConfiguration(config);
5959
return this;
6060
}
@@ -66,7 +66,7 @@ public DynamoDBFeatureStoreBuilder clientOverrideConfiguration(ClientOverrideCon
6666
* @param credentialsProvider a source of credentials
6767
* @return the builder
6868
*/
69-
public DynamoDBFeatureStoreBuilder credentials(AwsCredentialsProvider credentialsProvider) {
69+
public DynamoDbFeatureStoreBuilder credentials(AwsCredentialsProvider credentialsProvider) {
7070
clientBuilder.credentialsProvider(credentialsProvider);
7171
return this;
7272
}
@@ -79,7 +79,7 @@ public DynamoDBFeatureStoreBuilder credentials(AwsCredentialsProvider credential
7979
* @param endpointUri the custom endpoint URI
8080
* @return the builder
8181
*/
82-
public DynamoDBFeatureStoreBuilder endpoint(URI endpointUri) {
82+
public DynamoDbFeatureStoreBuilder endpoint(URI endpointUri) {
8383
clientBuilder.endpointOverride(endpointUri);
8484
return this;
8585
}
@@ -91,7 +91,7 @@ public DynamoDBFeatureStoreBuilder endpoint(URI endpointUri) {
9191
* @param region the AWS region
9292
* @return the builder
9393
*/
94-
public DynamoDBFeatureStoreBuilder region(Region region) {
94+
public DynamoDbFeatureStoreBuilder region(Region region) {
9595
clientBuilder.region(region);
9696
return this;
9797
}
@@ -104,7 +104,7 @@ public DynamoDBFeatureStoreBuilder region(Region region) {
104104
* @param prefix the namespace prefix
105105
* @return the builder
106106
*/
107-
public DynamoDBFeatureStoreBuilder prefix(String prefix) {
107+
public DynamoDbFeatureStoreBuilder prefix(String prefix) {
108108
this.prefix = prefix;
109109
return this;
110110
}
@@ -117,7 +117,7 @@ public DynamoDBFeatureStoreBuilder prefix(String prefix) {
117117
* @param existingClient an existing DynamoDB client instance
118118
* @return the builder
119119
*/
120-
public DynamoDBFeatureStoreBuilder existingClient(DynamoDbClient existingClient) {
120+
public DynamoDbFeatureStoreBuilder existingClient(DynamoDbClient existingClient) {
121121
this.existingClient = existingClient;
122122
return this;
123123
}
@@ -130,7 +130,7 @@ public DynamoDBFeatureStoreBuilder existingClient(DynamoDbClient existingClient)
130130
* @param caching a {@link FeatureStoreCaching} object specifying caching parameters
131131
* @return the builder
132132
*/
133-
public DynamoDBFeatureStoreBuilder caching(FeatureStoreCaching caching) {
133+
public DynamoDbFeatureStoreBuilder caching(FeatureStoreCaching caching) {
134134
this.caching = caching;
135135
return this;
136136
}

src/main/java/com/launchdarkly/client/dynamodb/DynamoDBFeatureStoreCore.java renamed to src/main/java/com/launchdarkly/client/dynamodb/DynamoDbFeatureStoreCore.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
* stored as a single item, this mechanism will not work for extremely large flags or segments.
5959
* </ul>
6060
*/
61-
class DynamoDBFeatureStoreCore implements FeatureStoreCore {
62-
private static final Logger logger = LoggerFactory.getLogger(DynamoDBFeatureStoreCore.class);
61+
class DynamoDbFeatureStoreCore implements FeatureStoreCore {
62+
private static final Logger logger = LoggerFactory.getLogger(DynamoDbFeatureStoreCore.class);
6363

6464
static final String partitionKey = "namespace";
6565
static final String sortKey = "key";
@@ -72,7 +72,7 @@ class DynamoDBFeatureStoreCore implements FeatureStoreCore {
7272

7373
private Runnable updateHook;
7474

75-
DynamoDBFeatureStoreCore(DynamoDbClient client, String tableName, String prefix) {
75+
DynamoDbFeatureStoreCore(DynamoDbClient client, String tableName, String prefix) {
7676
this.client = client;
7777
this.tableName = tableName;
7878
this.prefix = "".equals(prefix) ? null : prefix;
@@ -151,7 +151,7 @@ public void initInternal(Map<VersionedDataKind<?>, Map<String, ? extends Version
151151
public <T extends VersionedData> T upsertInternal(VersionedDataKind<T> kind, T item) {
152152
Map<String, AttributeValue> encodedItem = marshalItem(kind, item);
153153

154-
if (updateHook != null) {
154+
if (updateHook != null) { // instrumentation for tests
155155
updateHook.run();
156156
}
157157

src/main/java/com/launchdarkly/client/dynamodb/package-info.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store
66
* <p>
77
* To use the DynamoDB feature store with the LaunchDarkly client, you will first obtain a
8-
* builder by calling {@link DatabaseComponents#dynamoDBFeatureStore(String)}, then optionally
8+
* builder by calling {@link DatabaseComponents#dynamoDbFeatureStore(String)}, then optionally
99
* modify its properties, and then include it in your client configuration. For example:
1010
*
1111
* <pre>
1212
* import com.launchdarkly.client.*;
1313
* import com.launchdarkly.client.dynamodb.*;
1414
15-
* DynamoDBFeatureStoreBuilder store = DatabaseComponents.dynamoDBFeatureStore("my-table-name")
15+
* DynamoDbFeatureStoreBuilder store = DatabaseComponents.dynamoDbFeatureStore("my-table-name")
1616
* .caching(FeatureStoreCaching.enabled().ttlSeconds(30));
1717
* LDConfig config = new LDConfig.Builder()
1818
* .featureStoreFactory(store)
@@ -26,10 +26,10 @@
2626
* AWS credentials and region from AWS environment variables and/or local configuration files.
2727
* There are options in the builder for changing some configuration options, or you can
2828
* configure the DynamoDB client yourself and pass it to the builder with
29-
* {@link DynamoDBFeatureStoreBuilder#existingClient(com.amazonaws.services.dynamodbv2.AmazonDynamoDB)}.
29+
* {@link DynamoDbFeatureStoreBuilder#existingClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient)}.
3030
* <p>
3131
* If you are using the same DynamoDB table as a feature store for multiple LaunchDarkly
32-
* environments, use the {@link com.launchdarkly.client.dynamodb.DynamoDBFeatureStoreBuilder#prefix(String)}
32+
* environments, use the {@link com.launchdarkly.client.dynamodb.DynamoDbFeatureStoreBuilder#prefix(String)}
3333
* option and choose a different prefix string for each, so they will not interfere with each
3434
* other's data.
3535
*/

src/test/java/com/launchdarkly/client/dynamodb/DynamoDBFeatureStoreTest.java renamed to src/test/java/com/launchdarkly/client/dynamodb/DynamoDbFeatureStoreTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import java.util.List;
1212
import java.util.Map;
1313

14-
import static com.launchdarkly.client.dynamodb.DynamoDBFeatureStoreCore.partitionKey;
15-
import static com.launchdarkly.client.dynamodb.DynamoDBFeatureStoreCore.sortKey;
14+
import static com.launchdarkly.client.dynamodb.DynamoDbFeatureStoreCore.partitionKey;
15+
import static com.launchdarkly.client.dynamodb.DynamoDbFeatureStoreCore.sortKey;
1616

1717
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
1818
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
@@ -42,12 +42,12 @@
4242
* docker run -p 8000:8000 amazon/dynamodb-local
4343
* </pre>
4444
*/
45-
public class DynamoDBFeatureStoreTest extends FeatureStoreDatabaseTestBase<FeatureStore> {
45+
public class DynamoDbFeatureStoreTest extends FeatureStoreDatabaseTestBase<FeatureStore> {
4646

4747
private static final String TABLE_NAME = "LD_DYNAMODB_TEST_TABLE";
4848
private static final URI DYNAMODB_ENDPOINT = URI.create("http://localhost:8000");
4949

50-
public DynamoDBFeatureStoreTest(boolean cached) {
50+
public DynamoDbFeatureStoreTest(boolean cached) {
5151
super(cached);
5252

5353
createTableIfNecessary();
@@ -82,12 +82,12 @@ protected void clearAllData() {
8282
requests.add(WriteRequest.builder().deleteRequest(builder -> builder.key(item)).build());
8383
}
8484

85-
DynamoDBFeatureStoreCore.batchWriteRequests(client, TABLE_NAME, requests);
85+
DynamoDbFeatureStoreCore.batchWriteRequests(client, TABLE_NAME, requests);
8686
}
8787

8888
@Override
8989
protected boolean setUpdateHook(FeatureStore storeUnderTest, final Runnable hook) {
90-
DynamoDBFeatureStoreCore core = (DynamoDBFeatureStoreCore)((CachingStoreWrapper)storeUnderTest).getCore();
90+
DynamoDbFeatureStoreCore core = (DynamoDbFeatureStoreCore)((CachingStoreWrapper)storeUnderTest).getCore();
9191
core.setUpdateHook(hook);
9292
return true;
9393
}
@@ -117,8 +117,8 @@ private void createTableIfNecessary() {
117117
client.createTable(request);
118118
}
119119

120-
private DynamoDBFeatureStoreBuilder baseBuilder() {
121-
return new DynamoDBFeatureStoreBuilder(TABLE_NAME)
120+
private DynamoDbFeatureStoreBuilder baseBuilder() {
121+
return new DynamoDbFeatureStoreBuilder(TABLE_NAME)
122122
.endpoint(DYNAMODB_ENDPOINT)
123123
.region(Region.US_EAST_1)
124124
.caching(cached ? FeatureStoreCaching.enabled().ttlSeconds(30) : FeatureStoreCaching.disabled())

0 commit comments

Comments
 (0)