Skip to content

Commit eff615c

Browse files
committed
Merge branch 'eb/v2-initial'
# Conflicts: # build.gradle # src/main/java/com/launchdarkly/client/dynamodb/DynamoDbFeatureStoreBuilder.java # src/test/java/com/launchdarkly/client/dynamodb/DynamoDbFeatureStoreTest.java
2 parents 15fbd7f + 254c257 commit eff615c

File tree

7 files changed

+163
-215
lines changed

7 files changed

+163
-215
lines changed

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ LaunchDarkly SDK for Java - DynamoDB integration
77

88
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.
99

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.
10+
This library requires at least version 2.1 of the AWS SDK for Java, and at least version 4.6.0 of the LaunchDarkly Java SDK. The minimum Java version is 8 (because that is the minimum Java version of the AWS SDK 2.x).
1311

1412
For more information, see also: [Using a persistent feature store](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
1513

@@ -25,15 +23,15 @@ This assumes that you have already installed the LaunchDarkly Java SDK.
2523
<dependency>
2624
<groupId>com.launchdarkly</groupId>
2725
<artifactId>launchdarkly-client-dynamodb-store</artifactId>
28-
<version>1.0.0</version>
26+
<version>2.0.0</version>
2927
</dependency>
3028

3129
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.)
3230

3331
<dependency>
34-
<groupId>com.amazonaws</groupId>
35-
<artifactId>com.amazonaws:aws-java-sdk-dynamodb</artifactId>
36-
<version>1.11.327</version>
32+
<groupId>software.amazon.awssdk</groupId>
33+
<artifactId>dynamodb</artifactId>
34+
<version>2.1.4</version>
3735
</dependency>
3836

3937
4. Import the LaunchDarkly package and the package for this library:

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ repositories {
2222
allprojects {
2323
group = 'com.launchdarkly'
2424
version = "${version}"
25-
sourceCompatibility = 1.7
26-
targetCompatibility = 1.7
25+
sourceCompatibility = 1.8
26+
targetCompatibility = 1.8
2727
}
2828

2929
ext {
@@ -44,7 +44,7 @@ libraries.internal = [
4444
// in the uberjar; the caller must provide them on the classpath at runtime.
4545
libraries.external = [
4646
"com.launchdarkly:launchdarkly-client:4.6.0",
47-
"com.amazonaws:aws-java-sdk-dynamodb:1.11.327",
47+
"software.amazon.awssdk:dynamodb:2.1.4",
4848
"org.slf4j:slf4j-api:1.7.21"
4949
]
5050

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=1.0.0-SNAPSHOT
1+
version=2.0.0-SNAPSHOT
22
ossrhUsername=
33
ossrhPassword=

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

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package com.launchdarkly.client.dynamodb;
22

3-
import com.amazonaws.ClientConfiguration;
4-
import com.amazonaws.auth.AWSCredentialsProvider;
5-
import com.amazonaws.client.builder.AwsClientBuilder;
6-
import com.amazonaws.regions.Regions;
7-
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
8-
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
9-
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
103
import com.launchdarkly.client.FeatureStore;
114
import com.launchdarkly.client.FeatureStoreCacheConfig;
125
import com.launchdarkly.client.FeatureStoreFactory;
@@ -15,6 +8,12 @@
158

169
import java.net.URI;
1710

11+
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
12+
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
13+
import software.amazon.awssdk.regions.Region;
14+
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
15+
import software.amazon.awssdk.services.dynamodb.DynamoDbClientBuilder;
16+
1817
/**
1918
* Builder/factory class for the DynamoDB feature store.
2019
* <p>
@@ -25,25 +24,25 @@
2524
* The AWS SDK provides many configuration options for a DynamoDB client. This class has
2625
* corresponding methods for some of the most commonly used ones. If you need more sophisticated
2726
* control over the DynamoDB client, you can construct one of your own and pass it in with the
28-
* {@link #existingClient(AmazonDynamoDB)} method.
27+
* {@link #existingClient(DynamoDbClient)} method.
2928
*/
3029
public class DynamoDbFeatureStoreBuilder implements FeatureStoreFactory {
3130
private final String tableName;
3231

3332
private String prefix;
34-
private AmazonDynamoDB existingClient;
35-
private AmazonDynamoDBClientBuilder clientBuilder;
33+
private DynamoDbClient existingClient;
34+
private DynamoDbClientBuilder clientBuilder;
3635

3736
private FeatureStoreCacheConfig caching = FeatureStoreCacheConfig.DEFAULT;
3837

3938
DynamoDbFeatureStoreBuilder(String tableName) {
4039
this.tableName = tableName;
41-
clientBuilder = AmazonDynamoDBClient.builder();
40+
clientBuilder = DynamoDbClient.builder();
4241
}
4342

4443
@Override
4544
public FeatureStore createFeatureStore() {
46-
AmazonDynamoDB client = (existingClient != null) ? existingClient : clientBuilder.build();
45+
DynamoDbClient client = (existingClient != null) ? existingClient : clientBuilder.build();
4746
DynamoDbFeatureStoreCore core = new DynamoDbFeatureStoreCore(client, tableName, prefix);
4847
CachingStoreWrapper wrapper = CachingStoreWrapper.builder(core).caching(caching).build();
4948
return wrapper;
@@ -55,8 +54,8 @@ public FeatureStore createFeatureStore() {
5554
* @param config an AWS client configuration object
5655
* @return the builder
5756
*/
58-
public DynamoDbFeatureStoreBuilder clientConfiguration(ClientConfiguration config) {
59-
clientBuilder.setClientConfiguration(config);
57+
public DynamoDbFeatureStoreBuilder clientOverrideConfiguration(ClientOverrideConfiguration config) {
58+
clientBuilder.overrideConfiguration(config);
6059
return this;
6160
}
6261

@@ -67,49 +66,36 @@ public DynamoDbFeatureStoreBuilder clientConfiguration(ClientConfiguration confi
6766
* @param credentialsProvider a source of credentials
6867
* @return the builder
6968
*/
70-
public DynamoDbFeatureStoreBuilder credentials(AWSCredentialsProvider credentialsProvider) {
71-
clientBuilder.setCredentials(credentialsProvider);
69+
public DynamoDbFeatureStoreBuilder credentials(AwsCredentialsProvider credentialsProvider) {
70+
clientBuilder.credentialsProvider(credentialsProvider);
7271
return this;
7372
}
7473

7574
/**
76-
* Sets the service endpoint and AWS region to use. Normally, you will not use this, as AWS
77-
* determines the service endpoint based on your region. However, you can set it explicitly if
78-
* you are running your own DynamoDB instance.
75+
* Sets the service endpoint to use. Normally, you will not use this, as AWS determines the
76+
* service endpoint based on your region. However, you can set it explicitly if you are
77+
* running your own DynamoDB instance.
7978
*
8079
* @param endpointUri the custom endpoint URI
81-
* @param region the AWS region name
8280
* @return the builder
8381
*/
84-
public DynamoDbFeatureStoreBuilder endpointAndRegion(URI endpointUri, String region) {
85-
clientBuilder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpointUri.toString(), region));
82+
public DynamoDbFeatureStoreBuilder endpoint(URI endpointUri) {
83+
clientBuilder.endpointOverride(endpointUri);
8684
return this;
8785
}
8886

8987
/**
9088
* Sets the AWS region to use. If you do not set this, AWS will attempt to determine it from
9189
* environment variables and/or local configuration files.
9290
*
93-
* @param region the AWS region name
91+
* @param region the AWS region
9492
* @return the builder
9593
*/
96-
public DynamoDbFeatureStoreBuilder region(String region) {
97-
clientBuilder.setRegion(region);
94+
public DynamoDbFeatureStoreBuilder region(Region region) {
95+
clientBuilder.region(region);
9896
return this;
9997
}
10098

101-
/**
102-
* Sets the AWS region to use. If you do not set this, AWS will attempt to determine it from
103-
* environment variables and/or local configuration files.
104-
*
105-
* @param region the AWS region enum
106-
* @return the builder
107-
*/
108-
public DynamoDbFeatureStoreBuilder region(Regions region) {
109-
clientBuilder.withRegion(region);
110-
return this;
111-
}
112-
11399
/**
114100
* Sets an optional namespace prefix for all keys stored in DynamoDB. Use this if you are sharing
115101
* the same database table between multiple clients that are for different LaunchDarkly
@@ -131,15 +117,15 @@ public DynamoDbFeatureStoreBuilder prefix(String prefix) {
131117
* @param existingClient an existing DynamoDB client instance
132118
* @return the builder
133119
*/
134-
public DynamoDbFeatureStoreBuilder existingClient(AmazonDynamoDB existingClient) {
120+
public DynamoDbFeatureStoreBuilder existingClient(DynamoDbClient existingClient) {
135121
this.existingClient = existingClient;
136122
return this;
137123
}
138124

139125
/**
140126
* Specifies whether local caching should be enabled and if so, sets the cache properties. Local
141127
* caching is enabled by default; see {@link FeatureStoreCacheConfig#DEFAULT}. To disable it, pass
142-
* {@link FeatureStoreCaching#disabled()} to this method.
128+
* {@link FeatureStoreCacheConfig#disabled()} to this method.
143129
*
144130
* @param caching a {@link FeatureStoreCacheConfig} object specifying caching parameters
145131
* @return the builder

0 commit comments

Comments
 (0)