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
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ object StrictModeConfigurationKeys {

fun CompilerConfiguration.strictModeAggregator(): StrictModeAggregator {
return StrictModeAggregator(
stateFlow = get(StrictModeConfigurationKeys.STATE_FLOW, StrictMode.WARNING),
sharedFlow = get(StrictModeConfigurationKeys.SHARED_FLOW, StrictMode.WARNING),
nestedFlow = get(StrictModeConfigurationKeys.NESTED_FLOW, StrictMode.WARNING),
streamScopedFunctions = get(StrictModeConfigurationKeys.STREAM_SCOPED_FUNCTIONS, StrictMode.WARNING),
suspendingServerStreaming = get(StrictModeConfigurationKeys.SUSPENDING_SERVER_STREAMING, StrictMode.WARNING),
notTopLevelServerFlow = get(StrictModeConfigurationKeys.NOT_TOP_LEVEL_SERVER_FLOW, StrictMode.WARNING),
fields = get(StrictModeConfigurationKeys.FIELDS, StrictMode.WARNING),
stateFlow = get(StrictModeConfigurationKeys.STATE_FLOW, StrictMode.ERROR),
sharedFlow = get(StrictModeConfigurationKeys.SHARED_FLOW, StrictMode.ERROR),
nestedFlow = get(StrictModeConfigurationKeys.NESTED_FLOW, StrictMode.ERROR),
streamScopedFunctions = get(StrictModeConfigurationKeys.STREAM_SCOPED_FUNCTIONS, StrictMode.ERROR),
suspendingServerStreaming = get(StrictModeConfigurationKeys.SUSPENDING_SERVER_STREAMING, StrictMode.ERROR),
notTopLevelServerFlow = get(StrictModeConfigurationKeys.NOT_TOP_LEVEL_SERVER_FLOW, StrictMode.ERROR),
fields = get(StrictModeConfigurationKeys.FIELDS, StrictMode.ERROR),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class RpcStrictModeDiagnosticRendererFactory(
StrictMode.ERROR -> "prohibited"
}

return "$entityName is $actionWord in @Rpc services in strict mode."
return "$entityName is $actionWord in @Rpc services in strict mode. " +
"Support will be removed completely in the 0.8.0 release."
}
}
31 changes: 17 additions & 14 deletions docs/pages/kotlinx-rpc/topics/strict-mode.topic
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
Starting with version <code>0.5.0</code>, the library introduces major changes to the service APIs.
The following declarations will be gradually restricted:
</p>
<warning>
String mode will be enforced in the <code>0.8.0</code> release.
</warning>
<chapter title="StateFlow and SharedFlow" id="stateflow-and-sharedflow">
<p>Deprecation level: <code>WARNING</code></p>
<p>Deprecation level: <code>ERROR</code></p>
<code-block lang="kotlin">
@Rpc
interface Service : RemoteService {
Expand All @@ -26,7 +29,7 @@
</chapter>

<chapter title="Fields" id="fields">
<p>Deprecation level: <code>WARNING</code></p>
<p>Deprecation level: <code>ERROR</code></p>
<code-block lang="kotlin">
@Rpc
interface Service : RemoteService {
Expand All @@ -37,7 +40,7 @@
</code-block>
</chapter>
<chapter title="Nested Flows" id="nested-flows">
<p>Deprecation level: <code>WARNING</code></p>
<p>Deprecation level: <code>ERROR</code></p>
<code-block lang="kotlin">
@Rpc
interface Service : RemoteService {
Expand All @@ -48,7 +51,7 @@
</code-block>
</chapter>
<chapter title="Not top-level server flows" id="not-top-level-server-flows">
<p>Deprecation level: <code>WARNING</code></p>
<p>Deprecation level: <code>ERROR</code></p>

<code-block lang="kotlin">
data class SpotifyWrapped(val myMusicFlow: Flow&lt;Rap&gt;, val extra: Data)
Expand All @@ -64,7 +67,7 @@
</code-block>
</chapter>
<chapter title="Non-suspending server flows" id="non-suspending-server-flows">
<p>Deprecation level: <code>WARNING</code></p>
<p>Deprecation level: <code>ERROR</code></p>

<code-block lang="kotlin">
data class SpotifyWrapped(val extra: Data)
Expand All @@ -78,7 +81,7 @@
</code-block>
</chapter>
<chapter title="Stream scopes management" id="stream-scopes-management">
<p>Deprecation level: <code>WARNING</code></p>
<p>Deprecation level: <code>ERROR</code></p>

<p>
The next stream scope management structures are deprecated due to the introduction of
Expand Down Expand Up @@ -158,18 +161,18 @@

rpc {
strict {
stateFlow = RpcStrictMode.WARNING
sharedFlow = RpcStrictMode.WARNING
nestedFlow = RpcStrictMode.WARNING
notTopLevelServerFlow = RpcStrictMode.WARNING
fields = RpcStrictMode.WARNING
suspendingServerStreaming = RpcStrictMode.WARNING
streamScopedFunctions = RpcStrictMode.WARNING
stateFlow = RpcStrictMode.ERROR
sharedFlow = RpcStrictMode.ERROR
nestedFlow = RpcStrictMode.ERROR
notTopLevelServerFlow = RpcStrictMode.ERROR
fields = RpcStrictMode.ERROR
suspendingServerStreaming = RpcStrictMode.ERROR
streamScopedFunctions = RpcStrictMode.ERROR
}
}
</code-block>
<p>
Modes <code>RpcStrictMode.NONE</code> and <code>RpcStrictMode.ERROR</code> are available.
Modes <code>RpcStrictMode.NONE</code> and <code>RpcStrictMode.WARNING</code> are available.
</p>

<warning>
Expand Down
2 changes: 1 addition & 1 deletion gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) {
val fields: Property<RpcStrictMode> = objects.strictModeProperty()

private fun ObjectFactory.strictModeProperty(
default: RpcStrictMode = RpcStrictMode.WARNING,
default: RpcStrictMode = RpcStrictMode.ERROR,
): Property<RpcStrictMode> {
return property(RpcStrictMode::class.java).convention(default)
}
Expand Down
13 changes: 13 additions & 0 deletions krpc/krpc-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import kotlinx.rpc.RpcStrictMode
import util.applyAtomicfuPlugin

plugins {
Expand All @@ -26,3 +27,15 @@ kotlin {
}
}
}

rpc {
strict {
stateFlow = RpcStrictMode.NONE
sharedFlow = RpcStrictMode.NONE
nestedFlow = RpcStrictMode.NONE
streamScopedFunctions = RpcStrictMode.NONE
suspendingServerStreaming = RpcStrictMode.NONE
notTopLevelServerFlow = RpcStrictMode.NONE
fields = RpcStrictMode.NONE
}
}
13 changes: 13 additions & 0 deletions krpc/krpc-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import kotlinx.rpc.RpcStrictMode
import util.applyAtomicfuPlugin

plugins {
Expand All @@ -27,3 +28,15 @@ kotlin {
}
}
}

rpc {
strict {
stateFlow = RpcStrictMode.NONE
sharedFlow = RpcStrictMode.NONE
nestedFlow = RpcStrictMode.NONE
streamScopedFunctions = RpcStrictMode.NONE
suspendingServerStreaming = RpcStrictMode.NONE
notTopLevelServerFlow = RpcStrictMode.NONE
fields = RpcStrictMode.NONE
}
}
13 changes: 13 additions & 0 deletions krpc/krpc-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import kotlinx.rpc.RpcStrictMode
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
Expand Down Expand Up @@ -100,3 +101,15 @@ tasks.register("moveToGold") {
}
}
}

rpc {
strict {
stateFlow = RpcStrictMode.NONE
sharedFlow = RpcStrictMode.NONE
nestedFlow = RpcStrictMode.NONE
streamScopedFunctions = RpcStrictMode.NONE
suspendingServerStreaming = RpcStrictMode.NONE
notTopLevelServerFlow = RpcStrictMode.NONE
fields = RpcStrictMode.NONE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ExtensionRegistrarConfigurator(testServices: TestServices) : EnvironmentCo
) {
val strictMode = module.directives[RpcDirectives.RPC_STRICT_MODE]
if (strictMode.isNotEmpty()) {
val mode = StrictMode.fromCli(strictMode.single()) ?: StrictMode.WARNING
val mode = StrictMode.fromCli(strictMode.single()) ?: StrictMode.ERROR
configuration.put(StrictModeConfigurationKeys.STATE_FLOW, mode)
configuration.put(StrictModeConfigurationKeys.SHARED_FLOW, mode)
configuration.put(StrictModeConfigurationKeys.NESTED_FLOW, mode)
Expand Down