Skip to content

Commit bd4e0ee

Browse files
authored
Docs for gRPC with Ktor #393 (#394)
1 parent e90fc89 commit bd4e0ee

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

docs/pages/kotlinx-rpc/rpc.tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<toc-element topic="grpc-services.topic"/>
3636
<toc-element topic="grpc-client.topic"/>
3737
<toc-element topic="grpc-server.topic"/>
38+
<toc-element topic="grpc-ktor-server.topic"/>
3839
</toc-element>
3940
</toc-element>
4041
<toc-element topic="strict-mode.topic"/>

docs/pages/kotlinx-rpc/topics/grpc-client.topic

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?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+
26
<!DOCTYPE topic
37
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
48
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -21,11 +25,11 @@
2125
val result = recognizer.recognize(image)
2226
println("Recognized category: ${result.category}")
2327

24-
grpcClient.cancel()
28+
grpcClient.close()
2529
</code-block>
2630
<list>
2731
<li>
2832
<code>usePlaintext()</code> - is a JVM binding to Java gRPC runtime. Other bindings are also present.
2933
</li>
3034
</list>
31-
</topic>
35+
</topic>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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="Ktor Server" id="grpc-ktor-server">
11+
12+
<p>
13+
Similarly to <a href="grpc-server.topic"/>,
14+
you can use gRPC with Ktor:
15+
</p>
16+
<code-block lang="kotlin">
17+
fun Application.module() {
18+
grpc(port = PORT, configure = { /* ... */ }) {
19+
registerService&lt;MyService&gt; { MyServiceImpl() }
20+
}
21+
}
22+
</code-block>
23+
<p>
24+
<code>GrpcServer</code> instance is created and bound to the Ktor Application lifetime.
25+
It can be accessed via <code>application.attributes[GrpcServerKey]</code>.
26+
</p>
27+
Add the Ktor dependency to your project:
28+
<code-block lang="kotlin">
29+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-ktor-server:%kotlinx-rpc-version%")
30+
</code-block>
31+
</topic>

0 commit comments

Comments
 (0)