Skip to content

Commit

Permalink
Merge pull request #52 from kuzzleio/1.2.1-proposal
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
Shiranuit authored Apr 16, 2021
2 parents 27348a6 + abb684a commit e73c44b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .ci/doc/test-snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

if [ ${1: -3} == ".kt" ]
then
cp /mnt/build/libs/sdk-jvm-[0-9+].[0-9+].[0-9+]-without-dependencies.jar /mnt/.ci/doc/kotlin-project/libs/ && cp $1 /mnt/.ci/doc/kotlin-project/src/main/java/SnippetTest.kt && cd /mnt/.ci/doc/kotlin-project/ && ./gradlew build && java -classpath 'libs/sdk-jvm-1.2.0-without-dependencies.jar:' -jar build/libs/project-1.jar
cp /mnt/build/libs/sdk-jvm-[0-9+].[0-9+].[0-9+]-without-dependencies.jar /mnt/.ci/doc/kotlin-project/libs/ && cp $1 /mnt/.ci/doc/kotlin-project/src/main/java/SnippetTest.kt && cd /mnt/.ci/doc/kotlin-project/ && ./gradlew build && java -classpath 'libs/sdk-jvm-1.2.1-without-dependencies.jar:' -jar build/libs/project-1.jar
else
cp /mnt/build/libs/sdk-jvm-[0-9+].[0-9+].[0-9+]-without-dependencies.jar /mnt/.ci/doc/java-project/libs/ && cp $1 /mnt/.ci/doc/java-project/src/main/java/SnippetTest.java && cd /mnt/.ci/doc/java-project/ && ./gradlew build && java -classpath 'libs/jvm-1.2.0-without-dependencies.jar:' -jar build/libs/project-1.jar
cp /mnt/build/libs/sdk-jvm-[0-9+].[0-9+].[0-9+]-without-dependencies.jar /mnt/.ci/doc/java-project/libs/ && cp $1 /mnt/.ci/doc/java-project/src/main/java/SnippetTest.java && cd /mnt/.ci/doc/java-project/ && ./gradlew build && java -classpath 'libs/jvm-1.2.1-without-dependencies.jar:' -jar build/libs/project-1.jar
fi
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ https://bintray.com/kuzzle/maven
<dependency>
<groupId>io.kuzzle</groupId>
<artifactId>sdk-jvm</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<type>pom</type>
</dependency>
```
Expand All @@ -54,19 +54,19 @@ https://bintray.com/kuzzle/maven
### Gradle

```groovy
compile 'io.kuzzle:sdk-jvm:1.2.0'
compile 'io.kuzzle:sdk-jvm:1.2.1'
```

For amd64:

```groovy
compile 'io.kuzzle:sdk-jvm:1.2.0'
compile 'io.kuzzle:sdk-jvm:1.2.1'
```

### Ivy

```html
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.2.0'>
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.2.1'>
<artifact name='sdk-jvm' ext='pom' ></artifact>
</dependency>
```
Expand Down
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ plugins {

val artifactName = "sdk-jvm"
val artifactGroup = "io.kuzzle"
val artifactVersion = "1.2.0"
val artifactVersion = "1.2.1"

val pomUrl = "https://github.com/kuzzleio/sdk-jvm"
val pomScmUrl = "https://github.com/kuzzleio/sdk-jvm"
Expand All @@ -35,7 +35,7 @@ val pomDeveloperId = "kuzzleio"
val pomDeveloperName = "kuzzle"

group = "io.kuzzle.sdk"
version = "1.2.0"
version = "1.2.1"
val ktorVersion = "1.5.2"

repositories {
Expand Down Expand Up @@ -90,12 +90,12 @@ application {
}

tasks.withType<Jar> {
archiveFileName.set("sdk-jvm-1.2.0-without-dependencies.jar")
archiveFileName.set("sdk-jvm-1.2.1-without-dependencies.jar")
}

tasks {
register("fatJar", Jar::class.java) {
archiveFileName.set("sdk-jvm-1.2.0.jar")
archiveFileName.set("sdk-jvm-1.2.1.jar")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes("Main-Class" to application.mainClassName)
Expand Down
2 changes: 1 addition & 1 deletion doc/1/controllers/document/upsert/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Applies partial changes to a document. If the document doesn't alre
# upsert

<SinceBadge version="Kuzzle 2.8.0"/>
<SinceBadge version="1.2.0" />
<SinceBadge version="1.2.1" />

Applies partial changes to a document. If the document doesn't already exist, a new document is created.

Expand Down
6 changes: 3 additions & 3 deletions doc/1/getting-started/java/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To build the project, add the following lines:
<dependency>
<groupId>io.kuzzle</groupId>
<artifactId>sdk-jvm</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<type>pom</type>
</dependency>
```
Expand All @@ -75,14 +75,14 @@ repositories {
}
}
dependencies {
compile 'io.kuzzle:sdk-jvm:1.2.0'
compile 'io.kuzzle:sdk-jvm:1.2.1'
}
```

### Ivy

```html
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.2.0'>
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.2.1'>
<artifact name='sdk-jvm' ext='pom' ></artifact>
</dependency>
```
Expand Down
6 changes: 3 additions & 3 deletions doc/1/getting-started/kotlin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To build the project, add the following lines:
<dependency>
<groupId>io.kuzzle</groupId>
<artifactId>sdk-jvm</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<type>pom</type>
</dependency>
```
Expand All @@ -87,14 +87,14 @@ repositories {
}
}
dependencies {
compile 'io.kuzzle:sdk-jvm:1.2.0'
compile 'io.kuzzle:sdk-jvm:1.2.1'
}
```

### Ivy

```html
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.2.0'>
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.2.1'>
<artifact name='sdk-jvm' ext='pom' ></artifact>
</dependency>
```
Expand Down
41 changes: 30 additions & 11 deletions src/main/kotlin/io/kuzzle/sdk/protocol/WebSocket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,24 @@ open class WebSocket : AbstractProtocol {
this.reconnectionRetries = reconnectionRetries
}

private fun tryToReconnect() {
if (retryCount < reconnectionRetries) {
private fun tryToReconnect(): Boolean {
if (!autoReconnect)
return false

state = ProtocolState.RECONNECTING
trigger("networkStateChange", state.toString())

while (retryCount < reconnectionRetries) {
retryCount++
state = ProtocolState.RECONNECTING
trigger("networkStateChange", state.toString())
Thread.sleep(reconnectionDelay)
thread(start = true) {
try {
connect()
return true
} catch (e: Exception) {
// Nothing to do, just retry
}
}
return false
}

@KtorExperimentalAPI
Expand All @@ -81,6 +89,7 @@ open class WebSocket : AbstractProtocol {
// @TODO Create enums for events
state = ProtocolState.OPEN
trigger("networkStateChange", ProtocolState.OPEN.toString())
retryCount = 0
thread(start = true) {
while (ws != null) {
val payload = queue.poll()
Expand All @@ -92,6 +101,7 @@ open class WebSocket : AbstractProtocol {
}
}
wait.complete(null)
var reconnected = false
try {
for (frame in incoming) {
when (frame) {
Expand All @@ -102,11 +112,13 @@ open class WebSocket : AbstractProtocol {
}
}
} catch (e: Exception) {
tryToReconnect()
reconnected = tryToReconnect()
}
if (!reconnected) {
state = ProtocolState.CLOSE
trigger("networkStateChange", ProtocolState.CLOSE.toString())
ws = null
}
state = ProtocolState.CLOSE
trigger("networkStateChange", ProtocolState.CLOSE.toString())
ws = null
}
GlobalScope.launch {
try {
Expand Down Expand Up @@ -135,8 +147,15 @@ open class WebSocket : AbstractProtocol {
is ConnectException,
is SocketException,
is IOException -> {
tryToReconnect()
wait.complete(null)
if (state != ProtocolState.RECONNECTING) {
if (!tryToReconnect()) {
wait.completeExceptionally(e)
} else {
wait.complete(null)
}
} else {
wait.completeExceptionally(e)
}
} else -> throw e
}
}
Expand Down

0 comments on commit e73c44b

Please sign in to comment.