-
Notifications
You must be signed in to change notification settings - Fork 40
Docs/release 0.6.0 #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs/release 0.6.0 #314
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[ | ||
{"version":"0.5.1","url":"/kotlinx-rpc/0.5.1/","isCurrent":true} | ||
{"version":"0.6.0","url":"/kotlinx-rpc/0.6.0/","isCurrent":true} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
- Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
--> | ||
|
||
<!DOCTYPE topic | ||
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd"> | ||
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd" | ||
title="Migration to 0.6.0" id="0-6-0"> | ||
|
||
<p> | ||
Version <code>0.6.0</code> introduces non-breaking changes, that require migration. | ||
</p> | ||
|
||
<chapter title="Non-suspending flows" id="non-suspending-flows"> | ||
<p> | ||
Non-suspending server flows are now supported. | ||
That begins the deprecation cycle for the suspending server flows and stream scopes. | ||
Please refer to the <a href="strict-mode.topic"/> section for more details on the migration | ||
Mr3zee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
(sections <code>Non-suspending server flows</code> and <code>Stream scopes management</code>). | ||
</p> | ||
</chapter> | ||
</topic> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
- Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
--> | ||
|
||
<!DOCTYPE topic | ||
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd"> | ||
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
|
@@ -63,6 +67,89 @@ | |
} | ||
</code-block> | ||
</li> | ||
<li> | ||
Mr3zee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
<b>Non-suspending server flows</b> | ||
<p>Deprecation level: <code>WARNING</code></p> | ||
|
||
<code-block lang="kotlin"> | ||
data class SpotifyWrapped(val extra: Data) | ||
|
||
@Rpc | ||
interface Service : RemoteService { | ||
suspend fun old(): Flow<SpotifyWrapped> // deprecated | ||
|
||
fun new(): Flow<SpotifyWrapped> | ||
} | ||
</code-block> | ||
</li> | ||
<li> | ||
<b>Stream scopes management</b> | ||
<p>Deprecation level: <code>WARNING</code></p> | ||
|
||
<p> | ||
The next stream scope management structures are deprecated due to the introduction of | ||
non-suspending server flows: | ||
</p> | ||
<list> | ||
<li><code>StreamScoped</code> class and function</li> | ||
<li><code>streamScoped</code> function</li> | ||
<li><code>invokeOnStreamScopeCompletion</code> function</li> | ||
<li><code>withStreamScope</code> function</li> | ||
</list> | ||
<p> | ||
Stream collection and completion is now bound to the <code>CoroutineScope</code> in which the flow was | ||
collected (server-side flows) or produced (client-side flows). | ||
</p> | ||
<p> | ||
Old code: | ||
|
||
</p> | ||
<code-block lang="kotlin"> | ||
@Rpc | ||
interface Service : RemoteService { | ||
suspend fun oldClient(flow: Flow<Int>) | ||
suspend fun oldServer(): Flow<Int> | ||
} | ||
|
||
suspend fun consumer(service: Service) { | ||
streamScoped { | ||
service.oldClient(flow { /* ... */ } ) | ||
|
||
service.oldServer().collect { | ||
// ... | ||
} | ||
} | ||
} | ||
</code-block> | ||
<p> | ||
New code: | ||
</p> | ||
<code-block lang="kotlin"> | ||
@Rpc | ||
interface Service : RemoteService { | ||
suspend fun newClient(flow: Flow<Int>) | ||
fun newServer(): Flow<Int> | ||
} | ||
|
||
fun consumer(service: Service, scope: CoroutineScope) { | ||
val flow = service.new() | ||
scope.launch { | ||
service.newClient(flow { /* ... */ } ) | ||
|
||
flow.collect { | ||
// ... | ||
} | ||
} | ||
} | ||
// or | ||
suspend fun consumer(service: Service) { | ||
service.newClient(flow { /* ... */ } ) | ||
|
||
service.new().collect { | ||
// ... | ||
} | ||
} | ||
</code-block> | ||
</li> | ||
</list> | ||
|
||
<p> | ||
|
@@ -81,6 +168,8 @@ | |
nestedFlow = RpcStrictMode.WARNING | ||
notTopLevelServerFlow = RpcStrictMode.WARNING | ||
fields = RpcStrictMode.WARNING | ||
suspendingServerStreaming = RpcStrictMode.WARNING | ||
streamScopedFunctions = RpcStrictMode.WARNING | ||
} | ||
} | ||
</code-block> | ||
|
@@ -90,7 +179,7 @@ | |
|
||
<warning> | ||
Note that setting <code>RpcStrictMode.NONE</code> should not be done permanently. | ||
All deprecated APIs will become errors in future without an option to suppress it. | ||
All deprecated APIs will become errors in the future without an option to suppress them. | ||
Consider your migration path in advance. | ||
</warning> | ||
</topic> |
Uh oh!
There was an error while loading. Please reload this page.