Skip to content

Commit

Permalink
Merge pull request #17 from GoodforGod/dev
Browse files Browse the repository at this point in the history
[3.0.0]
  • Loading branch information
GoodforGod authored Sep 4, 2021
2 parents 5430e92 + c74ea6c commit 992cf33
Show file tree
Hide file tree
Showing 41 changed files with 695 additions and 667 deletions.
82 changes: 34 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This project includes integration between Micronaut and ArangoDB.
[**Gradle**](https://mvnrepository.com/artifact/com.github.goodforgod/micronaut-arangodb)
```groovy
dependencies {
compile 'com.github.goodforgod:micronaut-arangodb:2.4.0'
compile 'com.github.goodforgod:micronaut-arangodb:3.0.0'
}
```

Expand All @@ -21,7 +21,7 @@ dependencies {
<dependency>
<groupId>com.github.goodforgod</groupId>
<artifactId>micronaut-arangodb</artifactId>
<version>2.4.0</version>
<version>3.0.0</version>
</dependency>
```

Expand All @@ -39,12 +39,6 @@ arangodb:
password: 1234 # or no pass if auth is not required
```
To use the drivers, just add a dependency to your application.
```groovy
compile 'com.arangodb:arangodb-java-driver'
```

### Accessors
Both async *ArangoDBAsync* and sync *ArangoDB* accessors are then available for dependency injection.
Expand Down Expand Up @@ -128,8 +122,8 @@ Check [ArangoDB official](https://www.arangodb.com/docs/stable/drivers/java-refe

```yaml
arangodb:
hosts: localhost:8080,localhost:8081 # default to host - localhost:8081
timeout: 3000 # default - 10000 in milliseconds
hosts: localhost:8080,localhost:8081 # default to host - localhost:8080
timeout: 10000ms # default - 10000 in milliseconds
chunksize: 3000 # default - 30000
max-connections: 30 # default - 1
connection-ttl: 200 # default - null
Expand All @@ -141,7 +135,7 @@ Hosts can be passed to configuration as Strings (useful when passed via environm
```yaml
arangodb:
hosts: localhost:8080,localhost:8081 # default to host - localhost:8081
hosts: localhost:8080,localhost:8081 # default to host - localhost:8080
```
Or can be passed as list (useful for manual configuring):
Expand Down Expand Up @@ -189,13 +183,13 @@ on startup you can set it via property.
```yaml
arangodb:
create-database-timeout-in-millis: 500 # default - 10000
create-database-timeout: 10000ms # default - 10000
```
In case you want to create database asynchronously you can specify that via this property:
```yaml
arangodb:
create-database-async: true # default - false
create-database-async: true # default - false
```
### Health Check
Expand All @@ -216,7 +210,7 @@ Example of ArangoDB health:
"name": "arangodb",
"status": "UP",
"details": {
"version": "3.6.1",
"version": "3.7.13",
"database": "_system"
}
}
Expand All @@ -232,7 +226,7 @@ You can explicitly *turn off* health check.
arangodb:
health:
enabled: false # default - true
timeout-in-millis: 5000 # default - 5000
timeout: 5000ms # default - 5000
retry: 2 # default - 2
```
Expand All @@ -250,43 +244,33 @@ ArangoDB Cluster Health output example:
```json
{
"name": "service",
"status": "UP",
"name": "service-name",
"status": "DOWN",
"details": {
"arangodb (cluster)": {
"name": "arangodb (cluster)",
"status": "UP",
"arangodb-cluster": {
"name": "service-name",
"status": "DOWN",
"details": {
"clusterId": "89b7e1a8-53f5-44ea-bb5c-9e7cb201417c",
"nodes": [
{
"name": "Coordinator0002",
"status": "GOOD"
},
"clusterId": "752f578b-8884-47ef-8984-894ae110d259",
"version": "3.7.13",
"database": "_system",
"cluster": [
{
"name": "Coordinator0001",
"status": "GOOD"
"status": "UP",
"nodes": [
"Coordinator0002",
"DBServer0002",
"DBServer0001",
"Agent",
"Agent Leader",
"Agent"
]
},
{
"name": "DBServer0001",
"status": "GOOD"
},
{
"name": "DBServer0002",
"status": "GOOD"
},
{
"name": "AGENT (AGNT-4206f181-8791-4c3f-952d-79d9aa58b7c2)",
"leading": true,
"status": "GOOD"
},
{
"name": "AGENT (AGNT-2cc832bf-a8b7-4f8a-823a-15d778594bc1)",
"status": "GOOD"
},
{
"name": "AGENT (AGNT-78172be0-1adc-47ea-8152-3a3b0ab0b10e)",
"status": "GOOD"
"status": "DOWN",
"nodes": [
"Coordinator0001"
]
}
]
}
Expand All @@ -305,7 +289,7 @@ arangodb:
health:
cluster:
enabled: true # default - false
timeout-in-millis: 5000 # default - 5000
timeout: 5000ms # default - 5000
retry: 2 # default - 2
```
Expand All @@ -319,6 +303,8 @@ check here for [TestContainers](https://www.testcontainers.org/).
## Micronaut Compatability
Starting from version *3.0.0* library ships for *Micronaut 3*.
Starting from version *2.0.0* library ships for *Micronaut 2*.
Starting from version *2.1.0* Java 11+ is required (previous version 1.8+ compatible).
Expand Down
51 changes: 27 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

id "io.micronaut.library" version "2.0.3"
id "org.sonarqube" version "3.3"
id "com.diffplug.spotless" version "5.11.0"
id "com.diffplug.spotless" version "5.14.3"
}

repositories {
Expand All @@ -20,9 +20,10 @@ targetCompatibility = 11

spotless {
java {
encoding "UTF-8"
encoding("UTF-8")
importOrder()
removeUnusedImports()
eclipse().configFile "${projectDir}/config/codestyle.xml"
eclipse().configFile("${projectDir}/config/codestyle.xml")
}
}

Expand All @@ -35,7 +36,7 @@ sonarqube {
}

micronaut {
version("2.5.12")
version("3.0.0")
processing {
incremental(true)
module(project.name)
Expand All @@ -52,6 +53,7 @@ dependencies {

implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "io.micronaut:micronaut-management"
implementation "io.projectreactor:reactor-core"

testAnnotationProcessor "io.micronaut:micronaut-inject-java"

Expand All @@ -67,6 +69,7 @@ dependencies {
}

test {
failFast(true)
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
Expand All @@ -79,17 +82,6 @@ test {
}
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.incremental = true
options.fork = true
}

java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down Expand Up @@ -135,11 +127,29 @@ publishing {
}
}

java {
withJavadocJar()
withSourcesJar()
}

tasks.withType(JavaCompile) {
options.encoding("UTF-8")
options.incremental(true)
options.fork = true
}

check.dependsOn jacocoTestReport
jacocoTestReport {
reports {
xml.enabled true
html.destination file("${buildDir}/jacocoHtml")
xml.enabled(true)
html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
}
}

javadoc {
options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption("html5", true)
}
}

Expand All @@ -149,10 +159,3 @@ if (project.hasProperty("signing.keyId")) {
sign publishing.publications.mavenJava
}
}

javadoc {
options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption("html5", true)
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
groupId=com.github.goodforgod
artifactId=micronaut-arangodb
artifactVersion=2.4.1
artifactVersion=3.0.0


##### GRADLE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package io.micronaut.configuration.arango;

import static io.micronaut.configuration.arango.ArangoSettings.SYSTEM_DATABASE;

import com.arangodb.entity.LoadBalancingStrategy;
import com.arangodb.internal.ArangoDefaults;
import com.arangodb.internal.InternalArangoDBBuilder;
import io.micronaut.configuration.arango.ssl.ArangoSSLConfiguration;
import io.micronaut.context.exceptions.ConfigurationException;
import io.micronaut.core.util.CollectionUtils;
import io.micronaut.core.util.StringUtils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

import static io.micronaut.configuration.arango.ArangoSettings.SYSTEM_DATABASE;

/**
* Abstract ArangoDB configuration class.
*
Expand All @@ -34,7 +36,7 @@ public abstract class AbstractArangoConfiguration {
private List<String> hosts;
private int port = ArangoDefaults.DEFAULT_PORT;
private String database = SYSTEM_DATABASE;
private int timeout = 10000;
private Duration timeout = Duration.ofSeconds(10);
private int chunksize = ArangoDefaults.CHUNK_DEFAULT_CONTENT_SIZE;
private int maxConnections = ArangoDefaults.MAX_CONNECTIONS_VST_DEFAULT;
private Long connectionTtl;
Expand All @@ -45,7 +47,7 @@ public abstract class AbstractArangoConfiguration {

private boolean createDatabaseIfNotExist = false;
private boolean createDatabaseAsync = false;
private int createDatabaseTimeoutInMillis = 10000;
private Duration createDatabaseTimeout = Duration.ofSeconds(10);

protected AbstractArangoConfiguration(ArangoSSLConfiguration sslConfiguration) {
this.sslConfiguration = sslConfiguration;
Expand All @@ -68,7 +70,7 @@ public Properties getProperties() {
if (StringUtils.isNotEmpty(getPassword())) {
properties.setProperty(ArangoProperties.PASSWORD, getPassword());
}
properties.setProperty(ArangoProperties.TIMEOUT, String.valueOf(getTimeout()));
properties.setProperty(ArangoProperties.TIMEOUT, String.valueOf(getTimeout().toMillis()));
properties.setProperty(ArangoProperties.USE_SSL, String.valueOf(getSslConfiguration().isEnabled()));
properties.setProperty(ArangoProperties.CHUNK_SIZE, String.valueOf(getChunksize()));
properties.setProperty(ArangoProperties.MAX_CONNECTIONS, String.valueOf(getMaxConnections()));
Expand Down Expand Up @@ -127,15 +129,17 @@ public void setCreateDatabaseAsync(boolean createDatabaseAsync) {
/**
* @return database create timeout in millis
*/
public int getCreateDatabaseTimeoutInMillis() {
return createDatabaseTimeoutInMillis;
public Duration getCreateDatabaseTimeout() {
return createDatabaseTimeout;
}

/**
* @param createDatabaseTimeoutInMillis database create timeout in millis
* @param createDatabaseTimeout database create timeout in millis
*/
public void setCreateDatabaseTimeoutInMillis(int createDatabaseTimeoutInMillis) {
this.createDatabaseTimeoutInMillis = createDatabaseTimeoutInMillis;
public void setCreateDatabaseTimeout(Duration createDatabaseTimeout) {
if (createDatabaseTimeout.isNegative())
throw new ConfigurationException("Timeout for create database can not be less than 0");
this.createDatabaseTimeout = createDatabaseTimeout;
}

public String getHost() {
Expand Down Expand Up @@ -223,11 +227,13 @@ public void setPassword(String password) {
* @see com.arangodb.ArangoDB.Builder#timeout(Integer)
* @return value
*/
public int getTimeout() {
public Duration getTimeout() {
return timeout;
}

public void setTimeout(int timeout) {
public void setTimeout(Duration timeout) {
if (timeout.isNegative())
throw new ConfigurationException("Timeout for driver can not be less than 0");
this.timeout = timeout;
}

Expand Down
Loading

0 comments on commit 992cf33

Please sign in to comment.