Skip to content

Commit 3561d6a

Browse files
committed
Updated docs for 0.4.0; bumped version
1 parent f7c135b commit 3561d6a

File tree

15 files changed

+138
-160
lines changed

15 files changed

+138
-160
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.3.0'
23+
CONFIG_JSON_VERSION: '0.4.0'
2424

2525
jobs:
2626
build:

README.md

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[![Kotlin Experimental](https://kotl.in/badges/experimental.svg)](https://kotlinlang.org/docs/components-stability.html)
99
[![Official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
10-
[![Kotlin](https://img.shields.io/badge/kotlin-1.7.0--2.0.10-blue.svg?logo=kotlin)](http://kotlinlang.org)
10+
[![Kotlin](https://img.shields.io/badge/kotlin-2.0.0--2.0.21-blue.svg?logo=kotlin)](http://kotlinlang.org)
1111
[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
1212

1313
[//]: # ([![TeamCity build](https://img.shields.io/teamcity/build/s/Build_kRPC_All.svg?server=http%3A%2F%2Fkrpc.teamcity.com)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=Build_kRPC_All&guest=1))
@@ -84,33 +84,18 @@ Check out our [getting started guide](https://kotlin.github.io/kotlinx-rpc) for
8484

8585
### Plugin dependencies
8686

87-
`kotlinx.rpc` has the following plugin dependencies:
88-
- The `org.jetbrains.kotlinx.rpc.plugin` will set up BOM and code generation for targets in the project.
89-
- The `org.jetbrains.kotlinx.rpc.platform` will only set up BOM. It is useful when you want to split your app into modules,
90-
and some of them will contain service declarations, thus using code generation, while others will only consume them.
87+
`kotlinx.rpc` provides Gradle plugin `org.jetbrains.kotlinx.rpc.plugin`
88+
that will set up code generation in a project.
9189

92-
Example of plugins setup in a project's `build.gradle.kts`:
90+
Example of a setup in a project's `build.gradle.kts`:
9391
```kotlin
9492
plugins {
95-
kotlin("jvm") version "2.0.10"
96-
kotlin("plugin.serialization") version "2.0.10"
97-
id("org.jetbrains.kotlinx.rpc.plugin") version "0.3.0"
93+
kotlin("multiplatform") version "2.0.21"
94+
kotlin("plugin.serialization") version "2.0.21"
95+
id("org.jetbrains.kotlinx.rpc.plugin") version "0.4.0"
9896
}
9997
```
10098

101-
For Kotlin versions prior to 2.0,
102-
KSP plugin is required
103-
(Corresponding configurations will be set up automatically by `org.jetbrains.kotlinx.rpc.plugin` plugin):
104-
105-
```kotlin
106-
// build.gradle.kts
107-
plugins {
108-
kotlin("jvm") version "1.9.25"
109-
kotlin("plugin.serialization") version "1.9.25"
110-
id("com.google.devtools.ksp") version "1.9.25-1.0.20"
111-
id("org.jetbrains.kotlinx.rpc.plugin") version "0.3.0"
112-
}
113-
```
11499
### Runtime dependencies
115100
To use `kotlinx.rpc` runtime dependencies, add Maven Central to the list of your repositories:
116101
```kotlin
@@ -121,16 +106,16 @@ repositories {
121106
And now you can add dependencies to your project:
122107
```kotlin
123108
dependencies {
124-
// client API
125-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client")
126-
// server API
127-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server")
128-
// serialization module. also, protobuf and cbor are available
129-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json")
109+
// Client API
110+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.4.0")
111+
// Server API
112+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.4.0")
113+
// Serialization module. Also, protobuf and cbor are provided
114+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.4.0")
130115

131-
// transport implementation for Ktor
132-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client")
133-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server")
116+
// Transport implementation for Ktor
117+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client:0.4.0")
118+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.4.0")
134119

135120
// Ktor API
136121
implementation("io.ktor:ktor-client-cio-jvm:$ktor_version")
@@ -143,7 +128,7 @@ You can see example projects in the [samples](samples) folder.
143128
`kotlinx.rpc` is designed to be transport agnostic.
144129
That means that the library aims to provide the best RPC experience regardless of how the resulting messages are transferred.
145130
That allows for easy integration into existing solutions, such as Ktor, without the need to rewrite code.
146-
Just plug-in `kotlinx.rpc`, provide it with means to transfer encoded data (or use out-of-the-box integrations) and it will run.
131+
Add `kotlinx.rpc`, provide it with means to transfer encoded data (or use out-of-the-box integrations) and it will run.
147132
With enough time it might even work with [avian carriers](https://en.wikipedia.org/wiki/IP_over_Avian_Carriers).
148133

149134
`kotlinx.rpc` provides its own transfer protocol called kRPC, which takes responsibility for tracking serializing and handling other complex request operations.
@@ -154,26 +139,12 @@ Besides that, one can even provide their own protocol or integration with one to
154139
Though possible, it is much more complicated way to use the library and generally not needed.
155140
`kotlinx.rpc` aims to provide most common protocols integrations as well as the in-house one called kRPC.
156141
Integrations in progress:
157-
- Integration with [gRPC](https://grpc.io/) (in prototype)
142+
- Integration with [gRPC](https://grpc.io/) (in prototype)
158143

159144
## Kotlin compatibility
160145
We support all stable Kotlin versions starting from 2.0.0:
161146
- 2.0.0, 2.0.10, 2.0.20, 2.0.21
162147

163-
To simplify project configuration, our Gradle plugin sets a proper library version automatically using BOM,
164-
based on the project's Kotlin version:
165-
```kotlin
166-
plugins {
167-
kotlin("jvm") version "2.0.10"
168-
id("org.jetbrains.kotlinx.rpc.plugin") version "0.3.0"
169-
}
170-
171-
dependencies {
172-
// version 0.3.0 is set by the Gradle plugin
173-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-core")
174-
}
175-
```
176-
177148
For a full compatibility checklist,
178149
see [Versions](https://kotlin.github.io/kotlinx-rpc/versions.html).
179150

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[
2-
{"version":"0.3.0","url":"/kotlinx-rpc/0.3.0/","isCurrent":true}
2+
{"version":"0.4.0","url":"/kotlinx-rpc/0.4.0/","isCurrent":true}
33
]

docs/pages/kotlinx-rpc/rpc.tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</toc-element>
2727
<toc-element topic="versions.topic"/>
2828
<toc-element toc-title="Migration guides">
29+
<toc-element topic="0-4-0.topic"/>
2930
<toc-element topic="0-3-0.topic"/>
3031
<toc-element topic="0-2-4.topic"/>
3132
<toc-element topic="0-2-1.topic"/>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE topic
3+
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
4+
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
6+
title="Migration to 0.4.0" id="0-4-0">
7+
<p>
8+
Version <code>0.4.0</code> introduces breaking changes.
9+
</p>
10+
<chapter title="@Rpc Annotation and RemoteService Interface" id="rpc_annotation_and_remote_service_interface">
11+
<p>
12+
This version brings changes to service definitions.
13+
Prior to <code>0.4.0</code> a service was defined as following:
14+
</p>
15+
<code-block lang="kotlin">
16+
interface MyService : RPC
17+
</code-block>
18+
<p>
19+
Starting from <code>0.4.0</code> new service definition is required:
20+
</p>
21+
<code-block lang="kotlin">
22+
@Rpc
23+
interface MyService
24+
</code-block>
25+
<p>
26+
This definition will be enough for the project to build, but it is not sufficient for use in IDE.
27+
All interfaces annotated with <code>@Rpc</code> are inherently <code>RemoteService</code>.
28+
This supertype is added by our compiler plugin.
29+
However, IDE can't resolve it yet, so for the code to be highlighted properly,
30+
explicit typing is required:
31+
</p>
32+
<code-block lang="kotlin">
33+
@Rpc
34+
interface MyService : RemoteService
35+
</code-block>
36+
<note>
37+
The reasoning behind this change is that Kotlin Compiler Plugin API has changed.
38+
Versions <code>2.0.0</code> and <code>2.0.10</code> allowed our plugin to resolve marker interfaces (which <code>RPC</code> was)
39+
before the code generation phase. Starting from <code>2.0.20</code> this doesn't work,
40+
and we are forced to use annotations to reliably detect RPC services.
41+
To track changes in this regard, we created an <a href="https://youtrack.jetbrains.com/issue/KT-72654">issue</a> for the compiler team.
42+
This change is not the final API design decision, and it may be changed before the stable release.
43+
</note>
44+
</chapter>
45+
<chapter title="Removal of Kotlin versions prior to 2.0" id="removal_of_kotlin_versions_prior_to_2_0">
46+
<p>
47+
We stopped publishing compiler plugin artifacts for Kotlin versions prior to 2.0.
48+
The reason for this is high maintenance cost with little to no usage.
49+
We encourage the migration to Kotlin 2.0, where all stable versions are now supported.
50+
<br/>
51+
List of Kotlin versions that are currently supported: <code>2.0.0</code>, <code>2.0.10</code>, <code>2.0.20</code>, <code>2.0.21</code>
52+
</p>
53+
</chapter>
54+
<chapter title="Removal of org.jetbrains.kotlinx.rpc.platform Gradle plugin"
55+
id="removal_of_org_jetbrains_kotlinx_rpc_platform_gradle_plugin">
56+
<p>
57+
Gradle plugin with id <code>org.jetbrains.kotlinx.rpc.platform</code> is not being published anymore.
58+
The reason is that it's sole role was to set BOM in the project, which is now considered unnecessary.
59+
<a href="https://docs.gradle.org/current/userguide/platforms.html#sub:conventional-dependencies-toml">Gradle version catalogs</a>
60+
can be used instead.
61+
</p>
62+
</chapter>
63+
<chapter title="Removal of BOM from the Gradle plugin" id="removal_of_bom_from_the_gradle_plugin">
64+
<p>
65+
The Gradle plugin that is left (<code>org.jetbrains.kotlinx.rpc.plugin</code>)
66+
does not set BOM for the project anymore. Instead, manual dependency can be set:
67+
</p>
68+
<code-block lang="kotlin">
69+
dependencies {
70+
implementation(platform("org.jetbrains.kotlinx:kotlinx-rpc-bom:%kotlinx-rpc-version%"))
71+
}
72+
</code-block>
73+
</chapter>
74+
</topic>

docs/pages/kotlinx-rpc/topics/features.topic

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
that will provide your flows with their lifetime:</p>
3737

3838
<code-block lang="kotlin">
39-
interface MyService {
39+
@Rpc
40+
interface MyService : RemoteService {
4041
suspend fun sendFlow(flow: Flow&lt;Int&gt;)
4142
}
4243

@@ -81,6 +82,16 @@
8182
}
8283
</code-block>
8384
<p>Note that this API is experimental and may be removed in future releases.</p>
85+
<p>
86+
Another way of managing streams - is to do it manually.
87+
For this, <code>StreamScope</code> constructor function can be used on pair with <code>withStreamScope</code>:
88+
</p>
89+
<code-block lang="kotlin">
90+
val streamScope = StreamScope(myJob)
91+
withStreamScope(streamScope) {
92+
// use streams here
93+
}
94+
</code-block>
8495
</chapter>
8596
<chapter title="Service fields" id="service-fields">
8697
<p>Our protocol provides you with an ability to declare service fields:</p>

docs/pages/kotlinx-rpc/topics/get-started.topic

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,33 +110,23 @@
110110
</chapter>
111111

112112
<chapter title="Add plugin dependencies" id="add-gradle-plugin">
113-
<p><code>kotlinx.rpc</code> provides <a href="plugins.topic">two Gradle plugins</a>:</p>
114-
<list>
115-
<li>
116-
<a href="plugins.topic" anchor="rpc-platform">
117-
<code>org.jetbrains.kotlinx.rpc.platform</code>
118-
</a>
119-
</li>
120-
<li>
121-
<a href="plugins.topic" anchor="rpc-plugin">
122-
<code>org.jetbrains.kotlinx.rpc.plugin</code>
123-
</a>
124-
</li>
125-
</list>
126113
<p>
127-
To add a plugin to your project, you need to define the following in your <path>build.gradle.kts</path>:
114+
To add a <a href="plugins.topic">Gradle plugin</a> to your project, you need to define the following in your <path>build.gradle.kts</path>:
128115
</p>
129116

130117
<code-block lang="kotlin">
131118
plugins {
132119
id(&quot;org.jetbrains.kotlinx.rpc.plugin&quot;) version &quot;%kotlinx-rpc-version%&quot;
133120
}
134121
</code-block>
135-
<p>To learn more about versioning, see <a href="versions.topic"/>.</p>
122+
123+
<p>
124+
This will configure code generation for your project.
125+
</p>
136126
</chapter>
137127

138128
<chapter title="Add serialization dependency" id="add-serialization-dependency">
139-
<p><code>kotlinx.rpc</code> requires you to add
129+
<p><code>kotlinx.rpc</code> requires you to add the
140130
<a href="https://github.com/Kotlin/kotlinx.serialization">kotlinx.serialization</a>
141131
Gradle plugin to your project.</p>
142132

docs/pages/kotlinx-rpc/topics/plugins.topic

Lines changed: 9 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -9,98 +9,24 @@
99
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
1010
title="Plugins" id="plugins">
1111
<p>
12-
The <code>kotlinx.rpc</code> library offers plugins that simplify project configuration by automating repetitive
13-
tasks.
14-
Specifically, <code>kotlinx.rpc</code> provides two Gradle <a
15-
href="https://docs.gradle.org/current/userguide/plugins.html">plugins</a>:
12+
The <code>kotlinx.rpc</code> library offers a <a href="https://docs.gradle.org/current/userguide/plugins.html">Gradle plugin</a>
13+
that simplifies project configuration by automating repetitive tasks: `org.jetbrains.kotlinx.rpc.plugin`
1614
</p>
17-
<list>
18-
<li>
19-
<a anchor="rpc-platform">
20-
<code>org.jetbrains.kotlinx.rpc.platform</code>
21-
</a>
22-
</li>
23-
<li>
24-
<a anchor="rpc-plugin">
25-
<code>org.jetbrains.kotlinx.rpc.plugin</code>
26-
</a>
27-
</li>
28-
</list>
2915

30-
<chapter title="org.jetbrains.kotlinx.rpc.platform" id="rpc-platform">
31-
<p>The <code>org.jetbrains.kotlinx.rpc.platform</code> plugin
32-
is particularly useful for versioning project dependencies.
33-
It adds <a href="https://docs.gradle.org/current/userguide/platforms.html#sub:bom_import">BOM</a>
34-
dependency to your project, that specifies proper versions for <code>kotlinx.rpc</code> dependencies.
35-
With this, you can skip specifying versions for each runtime dependency:</p>
36-
37-
<code-block lang="kotlin">
38-
plugins {
39-
kotlin("jvm") version "%kotlin-version%"
40-
id("org.jetbrains.kotlinx.rpc.platform") version "%kotlinx-rpc-version%"
41-
}
42-
43-
dependencies {
44-
// versions are set automatically to %kotlinx-rpc-version%
45-
implementation(&quot;org.jetbrains.kotlinx:kotlinx-rpc-krpc-client&quot;)
46-
implementation(&quot;org.jetbrains.kotlinx:kotlinx-rpc-krpc-server&quot;)
47-
}
48-
</code-block>
49-
<p>Using this plugin with version catalogs, your code can be rewritten like this:</p>
50-
51-
<code-block lang="yaml">
52-
# gradle / libs.versions.toml
53-
[versions]
54-
kotlinx-rpc-core = "%kotlinx-rpc-version%";
55-
56-
[libraries]
57-
kotlinx-rpc-client = { module = "org.jetbrains.kotlinx:kotlinx-rpc-krpc-client" }
58-
59-
[plugins]
60-
kotlinx-rpc-platform = { id = "org.jetbrains.kotlinx.rpc.platform"; version.ref = "kotlinx-rpc-core"; }
61-
</code-block>
62-
63-
<code-block lang="kotlin">
64-
// build.gradle.kts
65-
plugins {
66-
alias(libs.plugins.kotlinx.rpc.platform)
67-
}
68-
69-
dependencies {
70-
implementation(libs.kotlinx.rpc.client)
71-
}
72-
</code-block>
73-
</chapter>
7416
<chapter title="org.jetbrains.kotlinx.rpc.plugin" id="rpc-plugin">
7517
<p>
76-
The <code>org.jetbrains.kotlinx.rpc.plugin</code> plugin
77-
has the same BOM functionality as <a anchor="rpc-platform"><code>org.jetbrains.kotlinx.rpc.platform</code></a> and it also sets
78-
up code generation configurations.
18+
The <code>org.jetbrains.kotlinx.rpc.plugin</code> plugin sets up code generation configurations.
7919
</p>
80-
<p>It is useful for multi-project setups
81-
where you define your <a href="services.topic">RPC services</a> in one set of subprojects and use in the
82-
other. In such a setup, you can add the plugin only to modules with service definitions
83-
to save time on building your project.</p>
84-
8520
<code-block lang="kotlin">
8621
plugins {
8722
kotlin("jvm") version "%kotlin-version%"
8823
id("org.jetbrains.kotlinx.rpc.plugin") version "%kotlinx-rpc-version%"
8924
}
9025
</code-block>
91-
92-
<chapter title="Kotlin versions earlier than 2.0" id="pre-kotlin-2-0">
93-
<p>
94-
If you are using a version of Kotlin prior to 2.0,
95-
you must also add the KSP (Kotlin Symbol Processing) Gradle plugin:
96-
</p>
97-
<code-block lang="kotlin">
98-
plugins {
99-
kotlin("jvm") version "1.9.25"
100-
id("org.jetbrains.kotlinx.rpc.plugin") version "%kotlinx-rpc-version%"
101-
id("com.google.devtools.ksp") version "1.9.25-1.0.20"
102-
}
103-
</code-block>
104-
</chapter>
26+
<p>
27+
For multi-project setups
28+
where you define your <a href="services.topic">RPC services</a> in one set of subprojects and use them in
29+
another, you can add the plugin only to modules with service definitions.
30+
</p>
10531
</chapter>
106-
</topic>
32+
</topic>

docs/pages/kotlinx-rpc/topics/services.topic

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
1010
title="Services" id="services">
1111
<p>Services are the centerpieces of the library.
12-
A service is an interface annotated with the <code>RPC</code> annotation,
12+
A service is an interface annotated with the <code>@Rpc</code> annotation,
1313
and contains a set of methods and fields
1414
that can be executed or accessed remotely.
15+
Additionally, a service always has a type of <code>RemoteService</code>,
16+
which can be specified explicitly, or assumed implicitly and added by a compiler
17+
(the latter option does not work in IDE right now, but WIP).
1518
A simple service can be declared as follows:</p>
1619

1720
<code-block lang="kotlin">

0 commit comments

Comments
 (0)