Skip to content

Commit d7e95c7

Browse files
committed
Docs/release 0.6.0 (#314)
* Docs for 0.6.0 * Deprecations * Review comments
1 parent e71b097 commit d7e95c7

File tree

11 files changed

+205
-134
lines changed

11 files changed

+205
-134
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
ALGOLIA_INDEX_NAME: 'prod_kotlin_rpc'
2121
ALGOLIA_KEY: '${{ secrets.ALGOLIA_KEY }}'
2222
CONFIG_JSON_PRODUCT: 'kotlinx-rpc'
23-
CONFIG_JSON_VERSION: '0.5.1'
23+
CONFIG_JSON_VERSION: '0.6.0'
2424

2525
jobs:
2626
build:

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Example of a setup in a project's `build.gradle.kts`:
116116
plugins {
117117
kotlin("multiplatform") version "2.1.20"
118118
kotlin("plugin.serialization") version "2.1.20"
119-
id("org.jetbrains.kotlinx.rpc.plugin") version "0.5.1"
119+
id("org.jetbrains.kotlinx.rpc.plugin") version "0.6.0"
120120
}
121121
```
122122

@@ -131,15 +131,15 @@ And now you can add dependencies to your project:
131131
```kotlin
132132
dependencies {
133133
// Client API
134-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.5.1")
134+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.6.0")
135135
// Server API
136-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.5.1")
136+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.6.0")
137137
// Serialization module. Also, protobuf and cbor are provided
138-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.5.1")
138+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.6.0")
139139

140140
// Transport implementation for Ktor
141-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client:0.5.1")
142-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.5.1")
141+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client:0.6.0")
142+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.6.0")
143143

144144
// Ktor API
145145
implementation("io.ktor:ktor-client-cio-jvm:$ktor_version")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[
2-
{"version":"0.5.1","url":"/kotlinx-rpc/0.5.1/","isCurrent":true}
2+
{"version":"0.6.0","url":"/kotlinx-rpc/0.6.0/","isCurrent":true}
33
]

docs/pages/kotlinx-rpc/rpc.tree

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
- Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
- Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
44
-->
55

66
<!DOCTYPE instance-profile
@@ -36,10 +36,11 @@
3636
<toc-element topic="strict-mode.topic"/>
3737
<toc-element topic="versions.topic"/>
3838
<toc-element toc-title="Migration guides">
39+
<toc-element topic="0-6-0.topic"/>
3940
<toc-element topic="0-5-0.topic"/>
4041
<toc-element topic="0-4-0.topic"/>
4142
<toc-element topic="0-3-0.topic"/>
4243
<toc-element topic="0-2-4.topic"/>
4344
<toc-element topic="0-2-1.topic"/>
4445
</toc-element>
45-
</instance-profile>
46+
</instance-profile>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
- Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
4+
-->
5+
6+
<!DOCTYPE topic
7+
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
8+
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
10+
title="Migration to 0.6.0" id="0-6-0">
11+
12+
<p>
13+
Version <code>0.6.0</code> introduces non-breaking changes that require migration.
14+
</p>
15+
16+
<chapter title="Non-suspending flows" id="non-suspending-flows">
17+
<p>
18+
Non-suspending server flows are now supported.
19+
That begins the deprecation cycle for the suspending server flows and stream scopes.
20+
For more details, refer to the Non-suspending server flows and Stream scopes management
21+
sections in the <a href="strict-mode.topic"/> topic.
22+
</p>
23+
</chapter>
24+
</topic>
Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
- Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
- Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
44
-->
55

66
<!DOCTYPE topic
@@ -25,15 +25,15 @@
2525

2626
@Rpc
2727
interface MyService : RemoteService {
28-
suspend fun sendStream(stream: Flow&lt;Int&gt;): Flow&lt;String&gt;
28+
fun sendStream(stream: Flow&lt;Int&gt;): Flow&lt;String&gt;
2929

3030
suspend fun streamRequest(request: StreamRequest)
3131
}
3232
</code-block>
3333

3434
<p>
3535
Another requirement is that server-side steaming (flows that are returned from a function),
36-
must be the top-level type:
36+
must be the top-level type and the function must be non-suspending:
3737
</p>
3838

3939
<code-block lang="kotlin">
@@ -45,7 +45,8 @@
4545

4646
@Rpc
4747
interface MyService : RemoteService {
48-
suspend fun serverStream(): Flow&lt;String&gt; // ok
48+
fun serverStream(): Flow&lt;String&gt; // ok
49+
suspend fun serverStream(): Flow&lt;String&gt; // not ok
4950
suspend fun serverStream(): StreamResult // not ok
5051
}
5152
</code-block>
@@ -55,57 +56,5 @@
5556
<a href="https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serializers.md#contextual-serialization">Contextual</a>
5657
annotation.
5758
</note>
58-
59-
<p>
60-
To use flows in your code, use the <code>streamScoped</code> function
61-
that will provide your flows with their lifetime:
62-
</p>
63-
64-
<code-block lang="kotlin">
65-
@Rpc
66-
interface MyService : RemoteService {
67-
suspend fun sendFlow(flow: Flow&lt;Int&gt;)
68-
}
69-
70-
val myService = rpcClient.withService&lt;MyService&gt;()
71-
72-
streamScoped {
73-
val flow = flow {
74-
repeat(10) { i -&gt;
75-
emit(i)
76-
}
77-
}
78-
79-
myService.sendFlow(flow)
80-
}
81-
</code-block>
82-
<p>
83-
In that case all your flows, including incoming and outgoing,
84-
will work until the <code>streamScoped</code> function completes.
85-
After that, all streams that are still live will be closed.
86-
</p>
87-
<p>
88-
You can have multiple RPC calls and flows inside the <code>streamScoped</code> function, including those from
89-
different services.
90-
</p>
91-
<p>
92-
On the server side, you can use the <code>invokeOnStreamScopeCompletion</code> handler inside your methods
93-
to execute code after <code>streamScoped</code> on the client side has closed.
94-
It might be useful to clean resources, for example.
95-
</p>
96-
<warning>
97-
Note that this API is experimental and may be removed in future releases.
98-
</warning>
99-
<p>
100-
Another way of managing streams is to do it manually.
101-
For this, you can use the <code>StreamScope</code> constructor function together with
102-
<code>withStreamScope</code>:
103-
</p>
104-
<code-block lang="kotlin">
105-
val streamScope = StreamScope(myJob)
106-
withStreamScope(streamScope) {
107-
// use streams here
108-
}
109-
</code-block>
11059
</chapter>
11160
</topic>

0 commit comments

Comments
 (0)