Skip to content

Commit

Permalink
Merge pull request #25 from GoodforGod/dev
Browse files Browse the repository at this point in the history
[4.0.1]
  • Loading branch information
GoodforGod authored May 7, 2023
2 parents 5eb271a + e987c3a commit 3e17564
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ This project includes integration between Micronaut and ArangoDB.

[**Gradle**](https://mvnrepository.com/artifact/com.github.goodforgod/micronaut-arangodb)
```groovy
implementation "com.github.goodforgod:micronaut-arangodb:4.0.0"
implementation "com.github.goodforgod:micronaut-arangodb:4.0.1"
```

[**Maven**](https://mvnrepository.com/artifact/com.github.goodforgod/micronaut-arangodb)
```xml
<dependency>
<groupId>com.github.goodforgod</groupId>
<artifactId>micronaut-arangodb</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
</dependency>
```

Expand Down Expand Up @@ -134,15 +134,15 @@ arangodb:
password: password # default - null
database: _system # default - _system
protocol: HTTP2_JSON # default - HTTP2_JSON
timeout: 10000ms # default - 10000 in milliseconds
jwt: YourToken # default - null
chunksize: 3000 # default - 30000
timeout: 60s # default - 60000 in milliseconds (1 min)
connection-max: 30 # default - 1
connection-ttl: 200 # default - null
connection-ttl: 2000ms # default - null
keep-alive-interval: 2000ms # default - null
verify-host: true # default - true
keep-alive-interval: 200 # default - null
acquire-host-list: true # default - false
acquire-host-list-interval: 360000 # default - 3600000 (hour)
acquire-host-list-interval: 1h # default - 3600000 in millis (1 hour)
load-balancing-strategy: ONE_RANDOM # default - NONE (check LoadBalancingStrategy for more)
response-queue-time-samples: 10 # default - 10
```
Expand Down
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=4.0.0
artifactVersion=4.0.1


##### GRADLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public Optional<String> getJwt() {

@Override
public Optional<Integer> getTimeout() {
return Optional.of(configuration.getTimeout().toMillisPart());
return Optional.of(configuration.getTimeout())
.map(d -> Math.toIntExact(d.toMillis()));
}

@Override
Expand All @@ -93,12 +94,14 @@ public Optional<Integer> getMaxConnections() {

@Override
public Optional<Long> getConnectionTtl() {
return Optional.ofNullable(configuration.getConnectionTtl());
return Optional.ofNullable(configuration.getConnectionTtl())
.map(Duration::toMillis);
}

@Override
public Optional<Integer> getKeepAliveInterval() {
return Optional.ofNullable(configuration.getKeepAliveInterval());
return Optional.ofNullable(configuration.getKeepAliveInterval())
.map(d -> Math.toIntExact(d.toSeconds()));
}

@Override
Expand All @@ -108,7 +111,8 @@ public Optional<Boolean> getAcquireHostList() {

@Override
public Optional<Integer> getAcquireHostListInterval() {
return Optional.of(configuration.getAcquireHostListInterval());
return Optional.of(configuration.getAcquireHostListInterval())
.map(d -> Math.toIntExact(d.toMillis()));
}

@Override
Expand Down Expand Up @@ -143,14 +147,14 @@ public void setEnabled(boolean enabled) {
private List<String> hosts;
private String database = SYSTEM_DATABASE;
private Protocol protocol = ArangoDefaults.DEFAULT_PROTOCOL;
private Duration timeout = Duration.ofSeconds(10);
private int chunksize = ArangoDefaults.DEFAULT_CHUNK_SIZE;
private int connectionMax = ArangoDefaults.MAX_CONNECTIONS_HTTP2_DEFAULT;
private Long connectionTtl;
private Integer keepAliveInterval;
private Duration timeout = Duration.ofSeconds(60);
private Duration connectionTtl;
private Duration keepAliveInterval;
private Boolean verifyHost = ArangoDefaults.DEFAULT_VERIFY_HOST;
private boolean acquireHostList = ArangoDefaults.DEFAULT_ACQUIRE_HOST_LIST;
private int acquireHostListInterval = ArangoDefaults.DEFAULT_ACQUIRE_HOST_LIST_INTERVAL;
private Duration acquireHostListInterval = Duration.ofMillis(ArangoDefaults.DEFAULT_ACQUIRE_HOST_LIST_INTERVAL);
private LoadBalancingStrategy loadBalancingStrategy = ArangoDefaults.DEFAULT_LOAD_BALANCING_STRATEGY;
private int responseQueueTimeSamples = ArangoDefaults.DEFAULT_RESPONSE_QUEUE_TIME_SAMPLES;

Expand Down Expand Up @@ -191,14 +195,15 @@ public Properties getProperties() {
properties.setProperty(ArangoProperties.CHUNK_SIZE, String.valueOf(getChunksize()));
properties.setProperty(ArangoProperties.MAX_CONNECTIONS, String.valueOf(getConnectionMax()));
if (getConnectionTtl() != null) {
properties.setProperty(ArangoProperties.CONNECTION_TTL, String.valueOf(getConnectionTtl()));
properties.setProperty(ArangoProperties.CONNECTION_TTL, String.valueOf(getConnectionTtl().toMillis()));
}
if (getKeepAliveInterval() != null) {
properties.setProperty(ArangoProperties.KEEP_ALIVE_INTERVAL, String.valueOf(getKeepAliveInterval()));
properties.setProperty(ArangoProperties.KEEP_ALIVE_INTERVAL, String.valueOf(getKeepAliveInterval().toSeconds()));
}

properties.setProperty(ArangoProperties.ACQUIRE_HOST_LIST, String.valueOf(getAcquireHostList()));
properties.setProperty(ArangoProperties.ACQUIRE_HOST_LIST_INTERVAL, String.valueOf(getAcquireHostListInterval()));
properties.setProperty(ArangoProperties.ACQUIRE_HOST_LIST_INTERVAL,
String.valueOf(getAcquireHostListInterval().toMillis()));
properties.setProperty(ArangoProperties.LOAD_BALANCING_STRATEGY, String.valueOf(getLoadBalancingStrategy()));
properties.setProperty(ArangoProperties.RESPONSE_QUEUE_TIME_SAMPLES, String.valueOf(getResponseQueueTimeSamples()));
return properties;
Expand Down Expand Up @@ -393,23 +398,23 @@ public void setConnectionMax(int connectionMax) {
* @see com.arangodb.ArangoDB.Builder#connectionTtl(Long)
* @return value
*/
public Long getConnectionTtl() {
public Duration getConnectionTtl() {
return connectionTtl;
}

public void setConnectionTtl(Long connectionTtl) {
public void setConnectionTtl(Duration connectionTtl) {
this.connectionTtl = connectionTtl;
}

/**
* @see com.arangodb.ArangoDB.Builder#keepAliveInterval(Integer)
* @return value
*/
public Integer getKeepAliveInterval() {
public Duration getKeepAliveInterval() {
return keepAliveInterval;
}

public void setKeepAliveInterval(Integer keepAliveInterval) {
public void setKeepAliveInterval(Duration keepAliveInterval) {
this.keepAliveInterval = keepAliveInterval;
}

Expand All @@ -428,11 +433,11 @@ public void setAcquireHostList(boolean acquireHostList) {
* @see com.arangodb.ArangoDB.Builder#acquireHostListInterval(Integer)
* @return value
*/
public int getAcquireHostListInterval() {
public Duration getAcquireHostListInterval() {
return acquireHostListInterval;
}

public void setAcquireHostListInterval(int acquireHostListInterval) {
public void setAcquireHostListInterval(Duration acquireHostListInterval) {
this.acquireHostListInterval = acquireHostListInterval;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.arangodb.entity.DatabaseEntity;
import io.micronaut.context.ApplicationContext;
import io.testcontainers.arangodb.containers.ArangoContainer;
import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -60,9 +61,9 @@ void createConnectionSuccessWithCorrectAuth() {

configuration.setProtocol(Protocol.VST);
configuration.setAcquireHostList(true);
configuration.setConnectionTtl(10000L);
configuration.setKeepAliveInterval(10000);
configuration.setConnectionTtl(10000L);
configuration.setConnectionTtl(Duration.ofMillis(10000L));
configuration.setKeepAliveInterval(Duration.ofMillis(10000));
configuration.setConnectionTtl(Duration.ofMillis(10000L));
configuration.setHosts(List.of("localhost:8080", "localhost:8081"));
configuration.setJwt("123");
configuration.setResponseQueueTimeSamples(123);
Expand Down

0 comments on commit 3e17564

Please sign in to comment.