Skip to content

Commit cdef580

Browse files
authored
Update README and prepare for the 0.20.0 release (#296)
1 parent 17384a6 commit cdef580

File tree

3 files changed

+45
-80
lines changed

3 files changed

+45
-80
lines changed

.github/workflows/publish-snapshot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
cache-disabled: true
1717

1818
- name: Publish snapshot to Maven Central
19-
run: ./gradlew publishToMavenCentral -Pversion=0.17.0-SNAPSHOT --no-configuration-cache
19+
run: ./gradlew publishToMavenCentral -Pversion=0.21.0-SNAPSHOT --no-configuration-cache
2020
env:
2121
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.signingKey}}
2222
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.signingPassword}}

README.md

+42-77
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# rsocket-kotlin
22

33
RSocket Kotlin multi-platform implementation based on
4-
[kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) and [ktor-io](https://github.com/ktorio/ktor).
4+
[kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) and [kotlinx-io](https://github.com/Kotlin/kotlinx-io).
55

66
RSocket is a binary application protocol providing Reactive Streams semantics for use on byte stream transports such as
77
TCP, WebSockets, QUIC and Aeron.
@@ -15,27 +15,13 @@ It enables the following symmetric interaction models via async message passing
1515

1616
Learn more at http://rsocket.io
1717

18-
## Supported platforms and transports :
18+
## Supported platforms and transports:
1919

20-
Local (in memory) transport is supported on all targets.
21-
Most of other transports are implemented using [ktor](https://github.com/ktorio/ktor) to ensure Kotlin multiplatform.
22-
So it depends on `ktor` client/server engines for available transports and platforms.
23-
24-
### Client transports:
25-
26-
| | TCP | WebSocket |
27-
|-----------------------------|-----------------------------------------|------------|
28-
| JVM | ✅ via ktor | ✅ via ktor |
29-
| JS | ✅ via nodeJS (not supported in browser) | ✅ via ktor |
30-
| Native<br/>(except windows) | ✅ via ktor | ✅ via ktor |
31-
32-
### Server transports:
33-
34-
| | TCP | WebSocket |
35-
|-----------------------------|-----------------------------------------|------------|
36-
| JVM | ✅ via ktor | ✅ via ktor |
37-
| JS | ✅ via nodeJS (not supported in browser) ||
38-
| Native<br/>(except windows) | ✅ via ktor | ✅ via ktor |
20+
Local (in memory) transport is supported for all targets.
21+
Starting from [Ktor 3.1 release](https://blog.jetbrains.com/kotlin/2025/02/ktor-3-1-0-release/),
22+
all ktor-client, ktor-server and ktor-network modules are supported for all targets.
23+
So all Ktor related transports (TCP and WebSocket) are supported by rsocket-kotlin for all targets.
24+
Additionally, there is experimental JVM-only support for Netty TCP and QUIC transpots.
3925

4026
## Using in your projects
4127

@@ -49,18 +35,18 @@ repositories {
4935

5036
### Ktor plugins
5137

52-
rsocket-kotlin provides [client](https://ktor.io/docs/http-client-plugins.html)
53-
and [server](https://ktor.io/docs/plugins.html) plugins for [ktor](https://ktor.io)
38+
rsocket-kotlin provides [client](https://ktor.io/docs/client-plugins.html)
39+
and [server](https://ktor.io/docs/server-plugins.html) plugins for [ktor](https://ktor.io)
5440

5541
Dependencies:
5642

5743
```kotlin
5844
dependencies {
59-
//for client
60-
implementation("io.rsocket.kotlin:rsocket-ktor-client:0.16.0")
45+
// for client
46+
implementation("io.rsocket.kotlin:ktor-client-rsocket:0.20.0")
6147

62-
//for server
63-
implementation("io.rsocket.kotlin:rsocket-ktor-server:0.16.0")
48+
// for server
49+
implementation("io.rsocket.kotlin:ktor-server-rsocket:0.20.0")
6450
}
6551
```
6652

@@ -69,38 +55,24 @@ Example of client plugin usage:
6955
```kotlin
7056
//create ktor client
7157
val client = HttpClient {
72-
install(WebSockets) //rsocket requires websockets plugin installed
58+
install(WebSockets) // rsocket requires websockets plugin installed
7359
install(RSocketSupport) {
74-
//configure rSocket connector (all values have defaults)
60+
// configure rSocket connector (all values have defaults)
7561
connector {
76-
maxFragmentSize = 1024
77-
7862
connectionConfig {
79-
keepAlive = KeepAlive(
80-
interval = 30.seconds,
81-
maxLifetime = 2.minutes
82-
)
83-
84-
//payload for setup frame
63+
// payload for setup frame
8564
setupPayload {
8665
buildPayload {
8766
data("""{ "data": "setup" }""")
8867
}
8968
}
9069

91-
//mime types
70+
// mime types
9271
payloadMimeType = PayloadMimeType(
9372
data = WellKnownMimeType.ApplicationJson,
9473
metadata = WellKnownMimeType.MessageRSocketCompositeMetadata
9574
)
9675
}
97-
98-
//optional acceptor for server requests
99-
acceptor {
100-
RSocketRequestHandler {
101-
requestResponse { it } //echo request payload
102-
}
103-
}
10476
}
10577
}
10678
}
@@ -126,37 +98,26 @@ Example of server plugin usage:
12698
```kotlin
12799
//create ktor server
128100
embeddedServer(CIO) {
129-
install(WebSockets) //rsocket requires websockets plugin installed
101+
install(WebSockets) // rsocket requires websockets plugin installed
130102
install(RSocketSupport) {
131-
//configure rSocket server (all values have defaults)
132-
133-
server {
134-
maxFragmentSize = 1024
135-
136-
//install interceptors
137-
interceptors {
138-
forConnection(::SomeConnectionInterceptor)
139-
}
140-
}
103+
// optionally configure rSocket server
141104
}
142-
//configure routing
143105
routing {
144-
//configure route `/rsocket`
145106
rSocket("rsocket") {
146107
println(config.setupPayload.data.readString()) //print setup payload data
147108

148109
RSocketRequestHandler {
149-
//handler for request/response
110+
// handler for request/response
150111
requestResponse { request: Payload ->
151112
println(request.data.readString()) //print request payload data
152113
delay(500) // work emulation
153114
buildPayload {
154115
data("""{ "data": "Server response" }""")
155116
}
156117
}
157-
//handler for request/stream
118+
// handler for request/stream
158119
requestStream { request: Payload ->
159-
println(request.data.readString()) //print request payload data
120+
println(request.data.readString()) // print request payload data
160121
flow {
161122
repeat(10) { i ->
162123
emit(
@@ -181,45 +142,49 @@ Dependencies:
181142

182143
```kotlin
183144
dependencies {
184-
implementation("io.rsocket.kotlin:rsocket-core:0.16.0")
145+
implementation("io.rsocket.kotlin:rsocket-core:0.20.0")
185146

186147
// TCP ktor client/server transport
187-
implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:0.16.0")
148+
implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:0.20.0")
188149

189150
// WS ktor client transport
190-
implementation("io.rsocket.kotlin:rsocket-transport-ktor-websocket-client:0.16.0")
151+
implementation("io.rsocket.kotlin:rsocket-transport-ktor-websocket-client:0.20.0")
191152

192153
// WS ktor server transport
193-
implementation("io.rsocket.kotlin:rsocket-transport-ktor-websocket-server:0.16.0")
154+
implementation("io.rsocket.kotlin:rsocket-transport-ktor-websocket-server:0.20.0")
194155

195-
// TCP nodeJS client/server transport
196-
implementation("io.rsocket.kotlin:rsocket-transport-nodejs-tcp:0.16.0")
156+
// Netty TCP client/server transport
157+
implementation("io.rsocket.kotlin:rsocket-transport-netty-tcp:0.20.0")
197158
}
198159
```
199160

200-
Example of usage standalone client transport:
161+
Example of usage standalone TCP ktor client transport:
201162

202163
```kotlin
203-
204-
val transport = TcpClientTransport("0.0.0.0", 8080)
164+
val parentContext = Job()
165+
val target = KtorTcpClientTransport(parentContext) {
166+
// optional configuration
167+
}.target("127.0.0.1", 8080)
205168
val connector = RSocketConnector {
206169
//configuration goes here
207170
}
208-
val rsocket: RSocket = connector.connect(transport)
171+
val rsocket: RSocket = connector.connect(target)
209172
//use rsocket to do request
210173
val response = rsocket.requestResponse(buildPayload { data("""{ "data": "hello world" }""") })
211174
println(response.data.readString())
212175
```
213176

214-
Example of usage standalone server transport:
177+
Example of usage standalone TCP ktor server transport:
215178

216179
```kotlin
217-
218-
val transport = TcpServerTransport("0.0.0.0", 8080)
219-
val connector = RSocketServer {
180+
val parentContext = Job()
181+
val target = KtorTcpServerTransport(parentContext) {
182+
// optional configuration
183+
}.target("127.0.0.1", 8080)
184+
val server = RSocketServer {
220185
//configuration goes here
221186
}
222-
val server: TcpServer = server.bind(transport) {
187+
val serverInstance = server.startServer(target) {
223188
RSocketRequestHandler {
224189
//handler for request/response
225190
requestResponse { request: Payload ->
@@ -231,7 +196,7 @@ val server: TcpServer = server.bind(transport) {
231196
}
232197
}
233198
}
234-
server.handlerJob.join() //wait for server to finish
199+
serverInstance.coroutineContext.job.join() // wait for server to finish
235200
```
236201

237202
### More samples:

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2015-2024 the original author or authors.
2+
# Copyright 2015-2025 the original author or authors.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
#
1616
group=io.rsocket.kotlin
17-
version=0.16.0
17+
version=0.20.0
1818
#Kotlin
1919
kotlin.mpp.import.enableKgpDependencyResolution=true
2020
kotlin.native.ignoreDisabledTargets=true

0 commit comments

Comments
 (0)