Skip to content

Commit 743cc46

Browse files
authored
Merge pull request #219 from dearrudam/issue-380
Added documentation about the DynamoDB module
2 parents 7eba09f + 892b4c3 commit 743cc46

File tree

7 files changed

+82
-22
lines changed

7 files changed

+82
-22
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
1515
- Define container nomenclature to integrate test
1616
- Update package name convention to `org.jnosql.databases.[DATABASE].[LAYER]`
1717
- Integrate the mapping layer on this repository
18+
- Upgrade the AWS SDK for DynamoDB to version 2.20.65;
1819

1920
=== Fixed
2021

README.adoc

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,62 @@ jnosql.couchdb.username=admin
516516
jnosql.couchdb.password=password
517517
----
518518

519+
== DynamoDB
520+
521+
image::https://user-images.githubusercontent.com/6509926/70553550-f033b980-1b40-11ea-9192-759b3b1053b3.png[Redis Project,align="center" width=50%,height=50%]
522+
523+
https://aws.amazon.com/dynamodb/[Amazon DynamoDB] is a fully managed, serverless, key-value NoSQL database designed to run high-performance applications at any scale. DynamoDB offers built-in security, continuous backups, automated multi-Region replication, in-memory caching, and data import and export tools.
524+
525+
This driver provides support for the *Key-Value* NoSQL API.
526+
527+
=== How To Install
528+
529+
You can use either the Maven or Gradle dependencies:
530+
531+
[source,xml]
532+
----
533+
<dependency>
534+
<groupId>org.eclipse.jnosql.databases</groupId>
535+
<artifactId>jnosql-dynamodb</artifactId>
536+
<version>1.0.0-b6</version>
537+
</dependency>
538+
----
539+
540+
=== Configuration
541+
542+
This API provides the ```DynamoDBConfigurations``` class to programmatically establish the credentials.
543+
Please note that you can establish properties using the https://microprofile.io/microprofile-config/[MicroProfile Config] specification.
544+
545+
[cols="DynamoDB"]
546+
|===
547+
|Configuration property |Description
548+
549+
|`jnosql.dynamodb.endpoint`
550+
|DynamoDB’s URL
551+
552+
|`jnosql.dynamodb.region`
553+
|Configure the region with which the application should communicate.
554+
555+
|`jnosql.dynamodb.profile`
556+
| Define the name of the profile that should be used by this credentials provider.
557+
558+
|`jnosql.dynamodb.awsaccesskey`
559+
|The AWS access key, used to identify the user interacting with AWS.
560+
561+
|`jnosql.dynamodb.secretaccess`
562+
|The AWS secret access key, used to authenticate the user interacting with AWS.
563+
564+
565+
|===
566+
567+
This is an example using DynamoDB's Key-Value API with MicroProfile Config.
568+
569+
[source,properties]
570+
----
571+
jnosql.keyvalue.provider=org.eclipse.jnosql.databases.dynamodb.communication.DynamoDBKeyValueConfiguration
572+
jnosql.keyvalue.database=heroes
573+
----
574+
519575
== Elasticsearch
520576

521577
image::https://jnosql.github.io/img/logos/elastic.svg[Elasticsearch Project,align="center"width=25%,height=25%]
@@ -1155,6 +1211,7 @@ jnosql.document.provider=org.eclipse.jnosql.databases.ravendb.communication.Rave
11551211
jnosql.document.database=heroes
11561212
----
11571213

1214+
11581215
== Redis
11591216

11601217
image::https://jnosql.github.io/img/logos/redis.png[Redis Project,align="center" width=25%,height=25%]

jnosql-dynamodb/Dockerfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

jnosql-dynamodb/dynamoDockerRun.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
AWS_ACCESS_KEY_ID=$(aws --profile default configure get aws_access_key_id)
22
AWS_SECRET_ACCESS_KEY=$(aws --profile default configure get aws_secret_access_key)
33

4-
docker build -t my_app .
54
docker run -it --rm -p 8000:8000 \
65
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
76
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
8-
my_app
7+
amazon/dynamodb-local

jnosql-dynamodb/pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
<version>1.0.0-SNAPSHOT</version>
1919
</parent>
2020

21-
2221
<artifactId>jnosql-dynamodb</artifactId>
22+
<description>The Eclipse JNoSQL layer implementation AWS DynamoDB</description>
23+
24+
<properties>
25+
<dynamodb.version>2.20.65</dynamodb.version>
26+
</properties>
2327

2428
<dependencies>
2529
<dependency>
@@ -38,7 +42,7 @@
3842
<dependency>
3943
<groupId>software.amazon.awssdk</groupId>
4044
<artifactId>dynamodb</artifactId>
41-
<version>2.15.40</version>
45+
<version>${dynamodb.version}</version>
4246
</dependency>
4347
<dependency>
4448
<groupId>org.testcontainers</groupId>

jnosql-dynamodb/src/test/java/org/eclipse/jnosql/databases/dynamodb/communication/DynamoDBKeyValueEntityManagerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939

4040
@EnabledIfSystemProperty(named = NAMED, matches = MATCHES)
4141
public class DynamoDBKeyValueEntityManagerTest {
42-
43-
private BucketManager keyValueEntityManager;
42+
43+
private BucketManager keyValueEntityManager;
4444

4545
private BucketManagerFactory keyValueEntityManagerFactory;
46-
46+
4747
private DynamoDBKeyValueConfiguration configuration;
4848

4949
private User userOtavio = new User("otavio");
@@ -54,7 +54,7 @@ public class DynamoDBKeyValueEntityManagerTest {
5454

5555
@BeforeEach
5656
public void init() {
57-
keyValueEntityManagerFactory = DynamoDBTestUtils.get();
57+
keyValueEntityManagerFactory = DynamoDBTestUtils.INSTANCE.get();
5858
keyValueEntityManager = keyValueEntityManagerFactory.apply("users-entity");
5959
}
6060

@@ -115,10 +115,10 @@ public void shouldRemoveMultiKey() {
115115
Iterable<Value> users = values;
116116
assertEquals(0L, StreamSupport.stream(keyValueEntityManager.get(keys).spliterator(), false).count());
117117
}
118-
118+
119119
@AfterAll
120120
public static void shutDown() {
121-
DynamoDBTestUtils.shutDown();
121+
DynamoDBTestUtils.INSTANCE.shutDown();
122122
}
123123

124124
}

jnosql-dynamodb/src/test/java/org/eclipse/jnosql/databases/dynamodb/communication/DynamoDBTestUtils.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@
1717
import org.eclipse.jnosql.communication.Settings;
1818
import org.eclipse.jnosql.communication.keyvalue.BucketManagerFactory;
1919
import org.testcontainers.containers.GenericContainer;
20+
import org.testcontainers.containers.wait.strategy.Wait;
21+
import org.testcontainers.containers.wait.strategy.WaitStrategy;
2022

21-
public class DynamoDBTestUtils {
23+
import java.util.function.Supplier;
2224

23-
private static GenericContainer dynamodb =
24-
new GenericContainer("amazon/dynamodb-local:latest")
25-
.withExposedPorts(8000)
26-
.withEnv("AWS_ACCESS_KEY_ID", "aws --profile default configure get aws_access_key_id")
27-
.withEnv("AWS_SECRET_ACCESS_KEY", "aws --profile default configure get aws_secret_access_key");
28-
//.withCommand("--rm");
25+
public enum DynamoDBTestUtils implements Supplier<BucketManagerFactory> {
2926

30-
// .waitingFor(Wait.forHttp("/")
31-
// .forStatusCode(200));
27+
INSTANCE;
3228

29+
private final GenericContainer dynamodb =
30+
new GenericContainer("amazon/dynamodb-local:latest")
31+
.withExposedPorts(8000)
32+
.waitingFor(Wait.defaultWaitStrategy());
3333

34-
public static BucketManagerFactory get() {
34+
public BucketManagerFactory get() {
3535
dynamodb.start();
3636
DynamoDBKeyValueConfiguration configuration = new DynamoDBKeyValueConfiguration();
3737
String endpoint = "http://" + dynamodb.getHost() + ":" + dynamodb.getFirstMappedPort();
3838
return configuration.apply(Settings.builder()
3939
.put(DynamoDBConfigurations.ENDPOINT, endpoint).build());
4040
}
4141

42-
public static void shutDown() {
42+
public void shutDown() {
4343
dynamodb.close();
4444
}
4545
}

0 commit comments

Comments
 (0)