Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/pages/kotlinx-rpc/rpc.tree
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<toc-element topic="versions.topic"/>
<toc-element topic="platforms.topic"/>
<toc-element toc-title="Migration guides">
<toc-element topic="0-10-0.topic"/>
<toc-element topic="0-8-0.topic"/>
<toc-element topic="0-6-0.topic"/>
<toc-element topic="0-5-0.topic"/>
Expand Down
32 changes: 32 additions & 0 deletions docs/pages/kotlinx-rpc/topics/0-10-0.topic
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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.10.0" id="0-10-0">

<p>
Version <code>0.10.0</code> brings some changes that require a migration:
</p>
<list>
<li>
<code>waitForServices</code> parameter in kRPC config is deprecated
and should be replaced with <a href="configuration.topic#connector-dsl"/>
</li>
<li>
As a continuation of the previous point, the backpressure mechanism is now introduced.
You may encounter slowdowns by default when using streams.
Use <a href="configuration.topic#connector-dsl"/>
to configure better suited buffer sizes.
</li>
<li>
For Ktor kRPC integration -
<code>public fun Route.rpc</code> functions now accept a suspending function parameter
instead of a regular one.
</li>
</list>
</topic>
59 changes: 47 additions & 12 deletions docs/pages/kotlinx-rpc/topics/configuration.topic
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
-->

<!DOCTYPE topic
Expand Down Expand Up @@ -28,7 +28,7 @@

<code-block lang="kotlin">
val config: KrpcConfig.Client = rpcClientConfig { // same for KrpcConfig.Server with rpcServerConfig
waitForServices = true // default parameter
// configuration here
}
</code-block>
<p>
Expand Down Expand Up @@ -67,19 +67,54 @@
You can also define a custom format.
</p>
</chapter>
<chapter id="waitforservices-dsl">
<chapter id="connector-dsl">
<title>
<code>waitForServices</code> DSL
<code>connector</code> DSL
</title>
<p>
<code>waitForServices</code> parameter is available for both client and server.
It specifies the behavior for an endpoint in situations
when the message for a service is received,
but the service is not present in <code>KrpcClient</code> or <code>KrpcServer</code>.
If set to <code>true</code>, the message will be stored in memory,
otherwise, the error will be sent to a peer endpoint,
saying that the message was not handled.
Default value is <code>true</code>.
Connector is a part of kRPC that is responsible for sending and receiving data over the network.
You can configure the following parameters:
</p>
<list>
<li>
<code>waitTimeout</code> - timeout for waiting for a service to be registered.
Sometimes services can be registered after the server starts,
and after the first requests starts to arrive from a peer.
This parameter defines how long the server will wait for a service to be registered.
<br/>
The default value is <code>Duration.INFINITE</code>.
<br/>
Also, available a value of <code>dontWait()</code>.
</li>
<li>
<code>callTimeout</code> - timeout for processing one message.
<br/>
The default value is <code>Duration.INFINITE</code>.
</li>
<li>
<code>perCallBufferSize</code> - size of the buffer for one call.
Call can be a stream or a single message.
This effectively provides a backpressure mechanism.
If a peer is slow to process the message during a call,
the buffer will be filled up and
the sender will wait before sending more messages.
<br/>
Note that this is <b>per call</b>, not per connection.
<br/>
The default value is <code>1</code>.
</li>
</list>
<p>
Example:
</p>
<code-block lang="kotlin">
rpcClientConfig {
connector {
waitTimeout = 10.seconds
callTimeout = 60.seconds
perCallBufferSize = 1000
}
}
</code-block>
</chapter>
</topic>
16 changes: 12 additions & 4 deletions docs/pages/kotlinx-rpc/topics/krpc-ktor.topic
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
<code-block lang="kotlin">
val ktorClient = HttpClient {
installKrpc {
waitForServices = true
serialization {
json()
}
}
}

val rpcClient: KtorKrpcClient =
ktorClient.rpc(&quot;ws://localhost:4242/services&quot;) {
rpcConfig {
waitForServices = false
serialization {
protobuf()
}
}
}

Expand All @@ -53,13 +57,17 @@
<code-block lang="kotlin">
fun Application.module() {
install(Krpc) {
waitForServices = true
serialization {
json()
}
}

routing {
rpc(&quot;/services&quot;) {
rpcConfig {
waitForServices = false
serialization {
protobuf()
}
}

registerService&lt;MyService&gt; { MyServiceImpl() }
Expand Down