Skip to content

Commit 7d96f8f

Browse files
committed
Docs for 0.5.0 Release (#256)
1 parent 7abecc3 commit 7d96f8f

File tree

21 files changed

+566
-179
lines changed

21 files changed

+566
-179
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.4.0'
23+
CONFIG_JSON_VERSION: '0.5.0'
2424

2525
jobs:
2626
build:

README.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,36 @@ import kotlinx.rpc.annotations.Rpc
2525
@Rpc
2626
interface AwesomeService : RemoteService {
2727
suspend fun getNews(city: String): Flow<String>
28+
29+
suspend fun daysUntilStableRelese(): Int
2830
}
2931
```
3032
In your server code define how to respond by simply implementing the service:
3133
```kotlin
32-
class AwesomeServiceImpl(override val coroutineContext: CoroutineContext) : AwesomeService {
34+
class AwesomeServiceImpl(
35+
val parameters: AwesomeParameters,
36+
override val coroutineContext: CoroutineContext,
37+
) : AwesomeService {
3338
override suspend fun getNews(city: String): Flow<String> {
3439
return flow {
3540
emit("Today is 23 degrees!")
3641
emit("Harry Potter is in $city!")
3742
emit("New dogs cafe has opened doors to all fluffy customers!")
3843
}
3944
}
45+
46+
override suspend fun daysUntilStableRelese(): Int {
47+
retuen if (parameters.stable) 0 else {
48+
parameters.daysUntilStable ?: error("Who says it will be stable?")
49+
}
50+
}
4051
}
4152
```
4253
Then, choose how do you want your service to communicate. For example, you can use integration with [Ktor](https://ktor.io/):
4354

4455
```kotlin
56+
data class AwesomeParameters(val stable: Boolean, val daysUntilStable: Int?)
57+
4558
fun main() {
4659
embeddedServer(Netty, 8080) {
4760
install(Krpc)
@@ -53,7 +66,9 @@ fun main() {
5366
}
5467
}
5568

56-
registerService<AwesomeService> { ctx -> AwesomeServiceImpl(ctx) }
69+
registerService<AwesomeService> { ctx ->
70+
AwesomeServiceImpl(AwesomeParameters(false, null), ctx)
71+
}
5772
}
5873
}
5974
}.start(wait = true)
@@ -71,8 +86,12 @@ val rpcClient = HttpClient { installKrpc() }.rpc {
7186
}
7287
}
7388

89+
val service = rpcClient.withService<AwesomeService>()
90+
91+
service.daysUntilStableRelese()
92+
7493
streamScoped {
75-
rpcClient.withService<AwesomeService>().getNews("KotlinBurg").collect { article ->
94+
service.getNews("KotlinBurg").collect { article ->
7695
println(article)
7796
}
7897
}
@@ -92,7 +111,7 @@ Example of a setup in a project's `build.gradle.kts`:
92111
plugins {
93112
kotlin("multiplatform") version "2.1.0"
94113
kotlin("plugin.serialization") version "2.1.0"
95-
id("org.jetbrains.kotlinx.rpc.plugin") version "0.4.0"
114+
id("org.jetbrains.kotlinx.rpc.plugin") version "0.5.0"
96115
}
97116
```
98117

@@ -107,15 +126,15 @@ And now you can add dependencies to your project:
107126
```kotlin
108127
dependencies {
109128
// Client API
110-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.4.0")
129+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.5.0")
111130
// Server API
112-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.4.0")
131+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.5.0")
113132
// Serialization module. Also, protobuf and cbor are provided
114-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.4.0")
133+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.5.0")
115134

116135
// 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")
136+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client:0.5.0")
137+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.5.0")
119138

120139
// Ktor API
121140
implementation("io.ktor:ktor-client-cio-jvm:$ktor_version")

core/src/commonMain/kotlin/kotlinx/rpc/RpcEagerField.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc
@@ -8,6 +8,10 @@ package kotlinx.rpc
88
* The field marked with this annotation will be initialized with the service creation.
99
*/
1010
@Target(AnnotationTarget.PROPERTY)
11+
@Deprecated(
12+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
13+
level = DeprecationLevel.WARNING,
14+
)
1115
public annotation class RpcEagerField
1216

1317
@Deprecated("Use RpcEagerField instead", ReplaceWith("RpcEagerField"), level = DeprecationLevel.ERROR)

core/src/commonMain/kotlin/kotlinx/rpc/UninitializedRpcFieldException.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc
@@ -18,6 +18,10 @@ public typealias UninitializedRPCFieldException = UninitializedRpcFieldException
1818
*
1919
* Use [awaitFieldInitialization] to await for the field initialization
2020
*/
21+
@Deprecated(
22+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
23+
level = DeprecationLevel.WARNING,
24+
)
2125
public class UninitializedRpcFieldException(serviceName: String, property: KProperty<*>) : Exception() {
2226
override val message: String = "${property.name} field of RPC service \"$serviceName\" in not initialized"
2327
}

core/src/commonMain/kotlin/kotlinx/rpc/awaitFieldInitialization.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc
@@ -27,6 +27,10 @@ import kotlin.reflect.KClass
2727
* @param getter function that returns the field of the context service to wait for.
2828
* @return service filed after it was initialized.
2929
*/
30+
@Deprecated(
31+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
32+
level = DeprecationLevel.WARNING,
33+
)
3034
public suspend fun <@Rpc T : Any, R> T.awaitFieldInitialization(getter: T.() -> R): R {
3135
val field = getter()
3236

@@ -56,6 +60,10 @@ public suspend fun <@Rpc T : Any, R> T.awaitFieldInitialization(getter: T.() ->
5660
* @param T service type
5761
* @return specified service, after all of it's field were initialized.
5862
*/
63+
@Deprecated(
64+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
65+
level = DeprecationLevel.WARNING,
66+
)
5967
public suspend inline fun <@Rpc reified T : Any> T.awaitFieldInitialization(): T {
6068
return awaitFieldInitialization(T::class)
6169
}
@@ -79,6 +87,10 @@ public suspend inline fun <@Rpc reified T : Any> T.awaitFieldInitialization(): T
7987
* @param kClass [KClass] of the [T] type.
8088
* @return specified service, after all of it's field were initialized.
8189
*/
90+
@Deprecated(
91+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
92+
level = DeprecationLevel.WARNING,
93+
)
8294
public suspend fun <@Rpc T : Any> T.awaitFieldInitialization(kClass: KClass<T>): T {
8395
serviceDescriptorOf(kClass)
8496
.getFields(this)

core/src/commonMain/kotlin/kotlinx/rpc/descriptor/RpcServiceDescriptor.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc.descriptor
@@ -44,6 +44,10 @@ public interface RpcServiceDescriptor<@Rpc T : Any> {
4444
public val fqName: String
4545

4646
@InternalRpcApi
47+
@Deprecated(
48+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
49+
level = DeprecationLevel.WARNING,
50+
)
4751
public fun getFields(service: T): List<RpcDeferredField<*>>
4852

4953
public fun getCallable(name: String): RpcCallable<T>?
@@ -68,6 +72,10 @@ public sealed interface RpcInvokator<@Rpc T : Any> {
6872
}
6973

7074
@ExperimentalRpcApi
75+
@Deprecated(
76+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
77+
level = DeprecationLevel.WARNING,
78+
)
7179
public fun interface Field<@Rpc T : Any> : RpcInvokator<T> {
7280
public fun call(service: T): Any?
7381
}

core/src/commonMain/kotlin/kotlinx/rpc/registerField.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc
@@ -25,6 +25,10 @@ import kotlinx.rpc.internal.RpcFlow
2525
* @param serviceId id of the service, that made the call
2626
* @return Flow instance to be consumed.
2727
*/
28+
@Deprecated(
29+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
30+
level = DeprecationLevel.WARNING,
31+
)
2832
public fun <T> RpcClient.registerPlainFlowField(
2933
serviceScope: CoroutineScope,
3034
descriptor: RpcServiceDescriptor<*>,
@@ -46,6 +50,10 @@ public fun <T> RpcClient.registerPlainFlowField(
4650
* @param serviceId id of the service, that made the call
4751
* @return SharedFlow instance to be consumed.
4852
*/
53+
@Deprecated(
54+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
55+
level = DeprecationLevel.WARNING,
56+
)
4957
public fun <T> RpcClient.registerSharedFlowField(
5058
serviceScope: CoroutineScope,
5159
descriptor: RpcServiceDescriptor<*>,
@@ -67,6 +75,10 @@ public fun <T> RpcClient.registerSharedFlowField(
6775
* @param serviceId id of the service, that made the call
6876
* @return StateFlow instance to be consumed.
6977
*/
78+
@Deprecated(
79+
"Fields are deprecated, see https://kotlin.github.io/kotlinx-rpc/0-5-0.html",
80+
level = DeprecationLevel.WARNING,
81+
)
7082
public fun <T> RpcClient.registerStateFlowField(
7183
serviceScope: CoroutineScope,
7284
descriptor: RpcServiceDescriptor<*>,

docs/pages/kotlinx-rpc/.idea/kotlinx-rpc.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pages/kotlinx-rpc/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[
2-
{"version":"0.4.0","url":"/kotlinx-rpc/0.4.0/","isCurrent":true}
2+
{"version":"0.5.0","url":"/kotlinx-rpc/0.5.0/","isCurrent":true}
33
]

0 commit comments

Comments
 (0)