diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 0030a4bb..82d66e09 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -33,7 +33,7 @@ jobs: fail-fast: false matrix: os: [ 'ubuntu-latest' ] - target: [ 'jvm', 'jvm11', 'jvm17', 'jvm21', 'js', 'native' ] + target: [ 'jvm', 'jvm11', 'jvm17', 'jvm21', 'web', 'native' ] include: - os: 'macos-latest' target: 'macos' @@ -50,7 +50,6 @@ jobs: - uses: ./.github/actions/setup-gradle - run: ./gradlew ${{ matrix.target }}Test --continue - timeout-minutes: 30 - if: always() && !cancelled() uses: actions/upload-artifact@v4 diff --git a/build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts index b5eb9b7e..339545ae 100644 --- a/build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts +++ b/build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.* import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.plugin.mpp.* import org.jetbrains.kotlin.gradle.targets.js.ir.* +import org.jetbrains.kotlin.gradle.targets.js.testing.* import org.jetbrains.kotlin.gradle.targets.jvm.* import org.jetbrains.kotlin.gradle.targets.jvm.tasks.* import org.jetbrains.kotlin.gradle.targets.native.tasks.* @@ -32,15 +33,30 @@ plugins { @OptIn(ExperimentalKotlinGradlePluginApi::class) kotlin { compilerOptions { - // because of INVISIBLE_REFERENCE suppression - will be removed after migration to kotlinx.io - if (project.name != "rsocket-test") { - allWarningsAsErrors.set(true) - } + allWarningsAsErrors.set(true) progressiveMode.set(true) freeCompilerArgs.add("-Xrender-internal-diagnostic-names") optIn.addAll(OptIns.ExperimentalSubclassOptIn) } + applyDefaultHierarchyTemplate { + common { + group("nonJvm") { + group("nonConcurrent") + group("native") + } + group("concurrent") { + withJvm() + group("native") + } + group("nonConcurrent") { + withJs() + withWasmJs() + withWasmWasi() + } + } + } + sourceSets.configureEach { languageSettings { if (name.contains("test", ignoreCase = true)) { @@ -103,6 +119,12 @@ registerTestAggregationTask( targetFilter = { it.platformType == KotlinPlatformType.jvm } ) +registerTestAggregationTask( + name = "webTest", + taskDependencies = { tasks.withType() }, + targetFilter = { it.platformType == KotlinPlatformType.js || it.platformType == KotlinPlatformType.wasm } +) + registerTestAggregationTask( name = "nativeTest", taskDependencies = { tasks.withType().matching { it.enabled } }, diff --git a/build-logic/src/main/kotlin/rsocketbuild/targets.kt b/build-logic/src/main/kotlin/rsocketbuild/targets.kt index 3ef9d40e..83c1bee8 100644 --- a/build-logic/src/main/kotlin/rsocketbuild/targets.kt +++ b/build-logic/src/main/kotlin/rsocketbuild/targets.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,21 @@ package rsocketbuild import org.gradle.jvm.toolchain.* import org.gradle.kotlin.dsl.* +import org.jetbrains.kotlin.gradle.* import org.jetbrains.kotlin.gradle.dsl.* -fun KotlinMultiplatformExtension.appleTargets() { +fun KotlinMultiplatformExtension.allTargets( + supportsWasi: Boolean = true, + supportsBrowser: Boolean = true, +) { + jvmTarget() + jsTarget(supportsBrowser = supportsBrowser) + wasmJsTarget(supportsBrowser = supportsBrowser) + if (supportsWasi) wasmWasiTarget() + nativeTargets() +} + +fun KotlinMultiplatformExtension.nativeTargets() { macosX64() macosArm64() @@ -32,29 +44,20 @@ fun KotlinMultiplatformExtension.appleTargets() { watchosArm32() watchosArm64() watchosSimulatorArm64() - // https://youtrack.jetbrains.com/issue/KTOR-6368, supported by kotlinx-io - // watchosDeviceArm64() + watchosDeviceArm64() tvosX64() tvosArm64() tvosSimulatorArm64() -} -fun KotlinMultiplatformExtension.nixTargets() { - appleTargets() linuxX64() linuxArm64() -} - -fun KotlinMultiplatformExtension.nativeTargets() { - nixTargets() mingwX64() - // not supported by ktor, supported by kotlinx-io - // androidNativeX64() - // androidNativeX86() - // androidNativeArm64() - // androidNativeArm32() + androidNativeX64() + androidNativeX86() + androidNativeArm64() + androidNativeArm32() } fun KotlinMultiplatformExtension.jsTarget( @@ -67,6 +70,24 @@ fun KotlinMultiplatformExtension.jsTarget( } } +@OptIn(ExperimentalWasmDsl::class) +fun KotlinMultiplatformExtension.wasmJsTarget( + supportsNode: Boolean = true, + supportsBrowser: Boolean = true, +) { + wasmJs { + if (supportsNode) nodejs() + if (supportsBrowser) browser() + } +} + +@OptIn(ExperimentalWasmDsl::class) +fun KotlinMultiplatformExtension.wasmWasiTarget() { + wasmWasi { + nodejs() + } +} + fun KotlinMultiplatformExtension.jvmTarget( jdkVersion: Int = 8, jdkAdditionalTestVersions: Set = setOf(11, 17, 21), diff --git a/build-settings/src/main/kotlin/rsocketsettings.repositories.settings.gradle.kts b/build-settings/src/main/kotlin/rsocketsettings.repositories.settings.gradle.kts index 60646f00..a5d70da0 100644 --- a/build-settings/src/main/kotlin/rsocketsettings.repositories.settings.gradle.kts +++ b/build-settings/src/main/kotlin/rsocketsettings.repositories.settings.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3cf17bb2..9deceabc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ kotlinx-coroutines = "1.10.1" kotlinx-benchmark = "0.4.8" kotlinx-bcv = "0.17.0" -ktor = "3.0.3" +ktor = "3.1.0" netty = "4.1.117.Final" netty-quic = "0.0.70.Final" diff --git a/ktor-plugins/ktor-client-rsocket/build.gradle.kts b/ktor-plugins/ktor-client-rsocket/build.gradle.kts index 9d9b43f8..ff829cdd 100644 --- a/ktor-plugins/ktor-client-rsocket/build.gradle.kts +++ b/ktor-plugins/ktor-client-rsocket/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ plugins { description = "rsocket-kotlin ktor client plugin" kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets( + supportsWasi = false, + ) sourceSets { commonMain.dependencies { diff --git a/ktor-plugins/ktor-server-rsocket/build.gradle.kts b/ktor-plugins/ktor-server-rsocket/build.gradle.kts index 0348e3db..3346b8d2 100644 --- a/ktor-plugins/ktor-server-rsocket/build.gradle.kts +++ b/ktor-plugins/ktor-server-rsocket/build.gradle.kts @@ -23,8 +23,10 @@ plugins { description = "rsocket-kotlin ktor server plugin" kotlin { - jvmTarget() - nixTargets() + allTargets( + supportsWasi = false, + supportsBrowser = false + ) sourceSets { commonMain.dependencies { diff --git a/ktor-plugins/ktor-tests/build.gradle.kts b/ktor-plugins/ktor-tests/build.gradle.kts index 64ca7d45..01736695 100644 --- a/ktor-plugins/ktor-tests/build.gradle.kts +++ b/ktor-plugins/ktor-tests/build.gradle.kts @@ -21,8 +21,10 @@ plugins { } kotlin { - jvmTarget() - nixTargets() + allTargets( + supportsWasi = false, + supportsBrowser = false + ) sourceSets { commonTest.dependencies { diff --git a/ktor-plugins/ktor-tests/src/commonTest/kotlin/io/rsocket/kotlin/ktor/tests/WebSocketConnectionTest.kt b/ktor-plugins/ktor-tests/src/commonTest/kotlin/io/rsocket/kotlin/ktor/tests/WebSocketConnectionTest.kt index dac3ae3a..6f7d92c6 100644 --- a/ktor-plugins/ktor-tests/src/commonTest/kotlin/io/rsocket/kotlin/ktor/tests/WebSocketConnectionTest.kt +++ b/ktor-plugins/ktor-tests/src/commonTest/kotlin/io/rsocket/kotlin/ktor/tests/WebSocketConnectionTest.kt @@ -76,12 +76,12 @@ class WebSocketConnectionTest : SuspendTest { } override suspend fun before() { - server.start() + server.startSuspend() delay(1000) } override suspend fun after() { - server.stop() + server.stopSuspend() client.coroutineContext.job.cancelAndJoin() } diff --git a/ktor-plugins/rsocket-ktor-client/build.gradle.kts b/ktor-plugins/rsocket-ktor-client/build.gradle.kts index 3312f542..ae42e802 100644 --- a/ktor-plugins/rsocket-ktor-client/build.gradle.kts +++ b/ktor-plugins/rsocket-ktor-client/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ plugins { description = "OLD ARTIFACT - migrate to ktor-client-rsocket" kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets( + supportsWasi = false, + ) sourceSets { commonMain.dependencies { diff --git a/ktor-plugins/rsocket-ktor-server/build.gradle.kts b/ktor-plugins/rsocket-ktor-server/build.gradle.kts index a7aeeba4..d9cafe4c 100644 --- a/ktor-plugins/rsocket-ktor-server/build.gradle.kts +++ b/ktor-plugins/rsocket-ktor-server/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,10 @@ plugins { description = "OLD ARTIFACT - migrate to ktor-server-rsocket" kotlin { - jvmTarget() - nixTargets() + allTargets( + supportsWasi = false, + supportsBrowser = false + ) sourceSets { commonMain.dependencies { diff --git a/rsocket-core/build.gradle.kts b/rsocket-core/build.gradle.kts index 87aa8634..1f79a103 100644 --- a/rsocket-core/build.gradle.kts +++ b/rsocket-core/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,7 @@ plugins { description = "rsocket-kotlin core functionality" kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets() sourceSets { commonMain.dependencies { diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt index 25813de0..56f59b82 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package io.rsocket.kotlin.internal import io.rsocket.kotlin.* import io.rsocket.kotlin.frame.* +import io.rsocket.kotlin.internal.io.* import io.rsocket.kotlin.keepalive.* import io.rsocket.kotlin.payload.* import io.rsocket.kotlin.test.* @@ -102,7 +103,7 @@ class RSocketRequesterTest : TestWithConnection() { val flow = requester.requestStream(Payload.Empty).take(2).flowOn(PrefetchStrategy(1, 0)) expectNoEventsIn(200) - flow.launchIn(connection + anotherDispatcher) + flow.launchIn(connection + Dispatchers.IoCompatible) awaitFrame { frame -> assertTrue(frame is RequestFrame) diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/transport/internal/PrioritizationFrameQueueTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/transport/internal/PrioritizationFrameQueueTest.kt index beace8d1..624d625b 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/transport/internal/PrioritizationFrameQueueTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/transport/internal/PrioritizationFrameQueueTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package io.rsocket.kotlin.transport.internal +import io.rsocket.kotlin.internal.io.* import io.rsocket.kotlin.test.* import kotlinx.coroutines.* import kotlinx.coroutines.channels.* @@ -62,7 +63,7 @@ class PrioritizationFrameQueueTest : SuspendTest { @Test fun testAsyncReceive() = test { val deferred = CompletableDeferred() - launch(anotherDispatcher) { + launch(Dispatchers.IoCompatible) { deferred.complete(queue.dequeueFrame()) } delay(100) diff --git a/rsocket-core/src/jsMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt b/rsocket-core/src/jsMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt deleted file mode 100644 index dcde87bc..00000000 --- a/rsocket-core/src/jsMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2015-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.rsocket.kotlin.logging - -import io.rsocket.kotlin.* - -@RSocketLoggingApi -internal actual val DefaultLoggerFactory: LoggerFactory - get() = ConsoleLogger - -@RSocketLoggingApi -public class ConsoleLogger( - override val tag: String, - private val minLevel: LoggingLevel = LoggingLevel.INFO, -) : Logger { - override fun isLoggable(level: LoggingLevel): Boolean = level >= minLevel - override fun rawLog(level: LoggingLevel, throwable: Throwable?, message: Any?) { - val meta = "[$level] ($tag)" - when (level) { - LoggingLevel.ERROR -> throwable - ?.let { console.error(meta, message, "Error:", it) } - ?: console.error(meta, message) - LoggingLevel.WARN -> throwable - ?.let { console.warn(meta, message, "Error:", it) } - ?: console.warn(meta, message) - LoggingLevel.INFO -> throwable - ?.let { console.info(meta, message, "Error:", it) } - ?: console.info(meta, message) - LoggingLevel.DEBUG -> throwable - ?.let { console.log(meta, message, "Error:", it) } - ?: console.log(meta, message) - LoggingLevel.TRACE -> throwable - ?.let { console.log(meta, message, "Error:", it) } - ?: console.log(meta, message) - } - } - - public companion object : LoggerFactory { - override fun logger(tag: String): Logger = ConsoleLogger(tag) - - public fun withLevel(minLevel: LoggingLevel): LoggerFactory = LoggerFactory { ConsoleLogger(it, minLevel) } - } -} diff --git a/rsocket-core/src/nativeMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt b/rsocket-core/src/nonJvmMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt similarity index 85% rename from rsocket-core/src/nativeMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt rename to rsocket-core/src/nonJvmMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt index d234e402..bc809077 100644 --- a/rsocket-core/src/nativeMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt +++ b/rsocket-core/src/nonJvmMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,5 +19,5 @@ package io.rsocket.kotlin.logging import io.rsocket.kotlin.* @RSocketLoggingApi -public actual val DefaultLoggerFactory: LoggerFactory +internal actual val DefaultLoggerFactory: LoggerFactory get() = PrintLogger diff --git a/rsocket-internal-io/api/rsocket-internal-io.api b/rsocket-internal-io/api/rsocket-internal-io.api index 8f783f53..4a0099ad 100644 --- a/rsocket-internal-io/api/rsocket-internal-io.api +++ b/rsocket-internal-io/api/rsocket-internal-io.api @@ -13,6 +13,10 @@ public final class io/rsocket/kotlin/internal/io/ContextKt { public static final fun supervisorContext (Lkotlin/coroutines/CoroutineContext;)Lkotlin/coroutines/CoroutineContext; } +public final class io/rsocket/kotlin/internal/io/Context_concurrentKt { + public static final fun getIoCompatible (Lkotlinx/coroutines/Dispatchers;)Lkotlinx/coroutines/CoroutineDispatcher; +} + public final class io/rsocket/kotlin/internal/io/Int24Kt { public static final fun readInt24 (Lkotlinx/io/Source;)I public static final fun writeInt24 (Lkotlinx/io/Sink;I)V diff --git a/rsocket-internal-io/build.gradle.kts b/rsocket-internal-io/build.gradle.kts index 7211178b..48f55269 100644 --- a/rsocket-internal-io/build.gradle.kts +++ b/rsocket-internal-io/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,7 @@ plugins { description = "rsocket-kotlin internal IO support" kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets() sourceSets { commonMain.dependencies { diff --git a/rsocket-internal-io/src/commonMain/kotlin/io/rsocket/kotlin/internal/io/Context.kt b/rsocket-internal-io/src/commonMain/kotlin/io/rsocket/kotlin/internal/io/Context.kt index 1ed305c7..a6d05d4c 100644 --- a/rsocket-internal-io/src/commonMain/kotlin/io/rsocket/kotlin/internal/io/Context.kt +++ b/rsocket-internal-io/src/commonMain/kotlin/io/rsocket/kotlin/internal/io/Context.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ package io.rsocket.kotlin.internal.io import kotlinx.coroutines.* import kotlin.coroutines.* +public expect val Dispatchers.IoCompatible: CoroutineDispatcher + public fun CoroutineContext.supervisorContext(): CoroutineContext = plus(SupervisorJob(get(Job))) public fun CoroutineContext.childContext(): CoroutineContext = plus(Job(get(Job))) diff --git a/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/Test.common.kt b/rsocket-internal-io/src/concurrentMain/kotlin/io/rsocket/kotlin/internal/io/Context.concurrent.kt similarity index 66% rename from rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/Test.common.kt rename to rsocket-internal-io/src/concurrentMain/kotlin/io/rsocket/kotlin/internal/io/Context.concurrent.kt index 337ccd36..66c796f9 100644 --- a/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/Test.common.kt +++ b/rsocket-internal-io/src/concurrentMain/kotlin/io/rsocket/kotlin/internal/io/Context.concurrent.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,8 @@ * limitations under the License. */ -package io.rsocket.kotlin.test +package io.rsocket.kotlin.internal.io import kotlinx.coroutines.* -expect annotation class IgnoreJs() -expect annotation class IgnoreJvm() -expect annotation class IgnoreNative() - -expect val anotherDispatcher: CoroutineDispatcher - -expect fun identityHashCode(instance: Any): Int +public actual val Dispatchers.IoCompatible: CoroutineDispatcher get() = IO diff --git a/rsocket-test/src/jvmMain/kotlin/io/rsocket/kotlin/test/Test.kt b/rsocket-internal-io/src/nonConcurrentMain/kotlin/io/rsocket/kotlin/internal/io/Context.nonConcurrent.kt similarity index 62% rename from rsocket-test/src/jvmMain/kotlin/io/rsocket/kotlin/test/Test.kt rename to rsocket-internal-io/src/nonConcurrentMain/kotlin/io/rsocket/kotlin/internal/io/Context.nonConcurrent.kt index e86c5bec..476dbfeb 100644 --- a/rsocket-test/src/jvmMain/kotlin/io/rsocket/kotlin/test/Test.kt +++ b/rsocket-internal-io/src/nonConcurrentMain/kotlin/io/rsocket/kotlin/internal/io/Context.nonConcurrent.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,8 @@ * limitations under the License. */ -package io.rsocket.kotlin.test +package io.rsocket.kotlin.internal.io import kotlinx.coroutines.* -actual annotation class IgnoreJs -actual typealias IgnoreJvm = org.junit.Ignore - -actual annotation class IgnoreNative - -actual val anotherDispatcher: CoroutineDispatcher get() = Dispatchers.IO - -actual fun identityHashCode(instance: Any): Int = System.identityHashCode(instance) +public actual val Dispatchers.IoCompatible: CoroutineDispatcher get() = Default diff --git a/rsocket-test/build.gradle.kts b/rsocket-test/build.gradle.kts index f15aebc9..caf72fc8 100644 --- a/rsocket-test/build.gradle.kts +++ b/rsocket-test/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,7 @@ plugins { @OptIn(ExperimentalKotlinGradlePluginApi::class) kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets() compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/rsocket-test/src/jsMain/kotlin/io/rsocket/kotlin/test/Test.kt b/rsocket-test/src/jsMain/kotlin/io/rsocket/kotlin/test/Test.kt deleted file mode 100644 index 06142344..00000000 --- a/rsocket-test/src/jsMain/kotlin/io/rsocket/kotlin/test/Test.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.rsocket.kotlin.test - -import kotlinx.coroutines.* - -actual typealias IgnoreJs = kotlin.test.Ignore - -actual annotation class IgnoreJvm -actual annotation class IgnoreNative - -//JS is single threaded, so it have only one dispatcher backed by one threed -actual val anotherDispatcher: CoroutineDispatcher get() = Dispatchers.Default - -actual fun identityHashCode(instance: Any): Int = instance.hashCode() diff --git a/rsocket-test/src/nativeMain/kotlin/io/rsocket/kotlin/test/Test.kt b/rsocket-test/src/nativeMain/kotlin/io/rsocket/kotlin/test/Test.kt deleted file mode 100644 index 3b97c4c1..00000000 --- a/rsocket-test/src/nativeMain/kotlin/io/rsocket/kotlin/test/Test.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2015-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.rsocket.kotlin.test - -import kotlinx.coroutines.* -import kotlin.experimental.* -import kotlin.native.* - -actual annotation class IgnoreJs -actual annotation class IgnoreJvm -actual typealias IgnoreNative = kotlin.test.Ignore - -actual val anotherDispatcher: CoroutineDispatcher get() = newSingleThreadContext("another") - -@OptIn(ExperimentalNativeApi::class) -actual fun identityHashCode(instance: Any): Int = instance.identityHashCode() diff --git a/rsocket-transport-tests/build.gradle.kts b/rsocket-transport-tests/build.gradle.kts index a2353b56..8bae8c67 100644 --- a/rsocket-transport-tests/build.gradle.kts +++ b/rsocket-transport-tests/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,7 @@ plugins { @OptIn(ExperimentalKotlinGradlePluginApi::class) kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets() compilerOptions { optIn.addAll( diff --git a/rsocket-transport-tests/src/commonMain/kotlin/io/rsocket/kotlin/transport/tests/TransportTest.kt b/rsocket-transport-tests/src/commonMain/kotlin/io/rsocket/kotlin/transport/tests/TransportTest.kt index 59b9fa05..9840a32d 100644 --- a/rsocket-transport-tests/src/commonMain/kotlin/io/rsocket/kotlin/transport/tests/TransportTest.kt +++ b/rsocket-transport-tests/src/commonMain/kotlin/io/rsocket/kotlin/transport/tests/TransportTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import kotlin.time.Duration.Companion.seconds //TODO: need to somehow rework those tests, as now they are super flaky abstract class TransportTest : SuspendTest { - override val testTimeout: Duration = 3.minutes + override val testTimeout: Duration = 10.minutes private val testJob = SupervisorJob() protected val testContext = testJob + TestExceptionHandler @@ -121,7 +121,6 @@ abstract class TransportTest : SuspendTest { } @Test - @Ignore //flaky, ignore for now fun requestChannel20000() = test { val request = flow { repeat(20_000) { emit(payload(7)) } @@ -148,7 +147,6 @@ abstract class TransportTest : SuspendTest { } @Test - @Ignore //flaky, ignore for now fun requestChannel16x256() = test { val request = flow { repeat(256) { @@ -180,7 +178,6 @@ abstract class TransportTest : SuspendTest { } @Test - @IgnoreNative // slow test fun requestStreamX16() = test { (0..16).map { async { @@ -202,7 +199,6 @@ abstract class TransportTest : SuspendTest { } @Test - @IgnoreNative //flaky, ignore for now fun requestChannel500NoLeak() = test { val request = flow { repeat(10_000) { emitOrClose(payload(3)) } @@ -241,13 +237,13 @@ abstract class TransportTest : SuspendTest { } @Test - @IgnoreNative //flaky, ignore for now + @Ignore // windows fun requestResponse10000() = test { (1..10000).map { async { client.requestResponse(payload(3)).let(Companion::checkPayload) } }.awaitAll() } @Test - @Ignore //flaky, ignore for now + @Ignore // QUIC fun requestResponse100000() = test { repeat(100000) { client.requestResponse(payload(3)).let(Companion::checkPayload) } } @@ -260,14 +256,12 @@ abstract class TransportTest : SuspendTest { } @Test - @IgnoreNative fun requestStream8K() = test { val count = client.requestStream(payload(3)).onEach { checkPayload(it) }.count() assertEquals(8192, count) // TODO } @Test - @IgnoreNative fun requestStream500NoLeak() = test { val count = client diff --git a/rsocket-transports/ktor-tcp/build.gradle.kts b/rsocket-transports/ktor-tcp/build.gradle.kts index 7c4cf76d..9bbcab73 100644 --- a/rsocket-transports/ktor-tcp/build.gradle.kts +++ b/rsocket-transports/ktor-tcp/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,10 @@ plugins { description = "rsocket-kotlin ktor TCP client/server transport implementation" kotlin { - jvmTarget() - nixTargets() + allTargets( + supportsWasi = false, + supportsBrowser = false + ) sourceSets { commonMain.dependencies { diff --git a/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpClientTransport.kt b/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpClientTransport.kt index ae5c815f..388b05eb 100644 --- a/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpClientTransport.kt +++ b/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpClientTransport.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public sealed interface KtorTcpClientTransportBuilder : RSocketTransportBuilder< private class KtorTcpClientTransportBuilderImpl : KtorTcpClientTransportBuilder { private var dispatcher: CoroutineContext = Dispatchers.Default - private var selector: KtorTcpSelector = KtorTcpSelector.FromContext(Dispatchers.IO) + private var selector: KtorTcpSelector = KtorTcpSelector.FromContext(Dispatchers.IoCompatible) private var socketOptions: SocketOptions.TCPClientSocketOptions.() -> Unit = {} override fun dispatcher(context: CoroutineContext) { diff --git a/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpServerTransport.kt b/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpServerTransport.kt index c414b709..b15fa855 100644 --- a/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpServerTransport.kt +++ b/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpServerTransport.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public sealed interface KtorTcpServerTransportBuilder : RSocketTransportBuilder< private class KtorTcpServerTransportBuilderImpl : KtorTcpServerTransportBuilder { private var dispatcher: CoroutineContext = Dispatchers.Default - private var selector: KtorTcpSelector = KtorTcpSelector.FromContext(Dispatchers.IO) + private var selector: KtorTcpSelector = KtorTcpSelector.FromContext(Dispatchers.IoCompatible) private var socketOptions: SocketOptions.AcceptorOptions.() -> Unit = {} override fun dispatcher(context: CoroutineContext) { diff --git a/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpClientTransport.kt b/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpClientTransport.kt index 40eb4a3c..7352748b 100644 --- a/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpClientTransport.kt +++ b/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpClientTransport.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package io.rsocket.kotlin.transport.ktor.tcp import io.ktor.network.selector.* import io.ktor.network.sockets.* +import io.rsocket.kotlin.internal.io.* import io.rsocket.kotlin.transport.* import kotlinx.coroutines.* import kotlin.coroutines.* @@ -42,7 +43,7 @@ public fun TcpClientTransport( configure: SocketOptions.TCPClientSocketOptions.() -> Unit = {}, ): ClientTransport { val transportJob = SupervisorJob(context[Job]) - val transportContext = Dispatchers.IO + context + transportJob + CoroutineName("rSocket-tcp-client") + val transportContext = Dispatchers.IoCompatible + context + transportJob + CoroutineName("rSocket-tcp-client") val selector = SelectorManager(transportContext) Job(transportJob).invokeOnCompletion { selector.close() } return ClientTransport(transportContext) { diff --git a/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpServerTransport.kt b/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpServerTransport.kt index 994b5a69..4ac723fd 100644 --- a/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpServerTransport.kt +++ b/rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpServerTransport.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +20,14 @@ package io.rsocket.kotlin.transport.ktor.tcp import io.ktor.network.selector.* import io.ktor.network.sockets.* -import io.ktor.utils.io.core.* +import io.rsocket.kotlin.internal.io.* import io.rsocket.kotlin.transport.* import kotlinx.coroutines.* @Deprecated(level = DeprecationLevel.ERROR, message = "Deprecated in favor of new Transport API, use KtorTcpServerInstance") public class TcpServer internal constructor( public val handlerJob: Job, - public val serverSocket: Deferred + public val serverSocket: Deferred, ) @Suppress("DEPRECATION_ERROR") @@ -44,7 +44,7 @@ public fun TcpServerTransport( configure: SocketOptions.AcceptorOptions.() -> Unit = {}, ): ServerTransport = ServerTransport { accept -> val serverSocketDeferred = CompletableDeferred() - val handlerJob = launch(Dispatchers.IO + coroutineContext) { + val handlerJob = launch(Dispatchers.IoCompatible + coroutineContext) { SelectorManager(coroutineContext).use { selector -> aSocket(selector).tcp().bind(localAddress, configure).use { serverSocket -> serverSocketDeferred.complete(serverSocket) diff --git a/rsocket-transports/ktor-tcp/src/commonTest/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpServerTest.kt b/rsocket-transports/ktor-tcp/src/commonTest/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpServerTest.kt index 732768b7..005f7811 100644 --- a/rsocket-transports/ktor-tcp/src/commonTest/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpServerTest.kt +++ b/rsocket-transports/ktor-tcp/src/commonTest/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpServerTest.kt @@ -25,7 +25,7 @@ import kotlin.test.* class TcpServerTest : SuspendTest { private val testJob = Job() private val testContext = testJob + TestExceptionHandler - private val serverTransport = KtorTcpServerTransport(testContext).target() + private val serverTransport = KtorTcpServerTransport(testContext).target("127.0.0.1") private fun KtorTcpServerInstance.clientTransport() = KtorTcpClientTransport(testContext).target(localAddress) diff --git a/rsocket-transports/ktor-tcp/src/commonTest/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpTransportTest.kt b/rsocket-transports/ktor-tcp/src/commonTest/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpTransportTest.kt index 72682ce3..c51bf418 100644 --- a/rsocket-transports/ktor-tcp/src/commonTest/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpTransportTest.kt +++ b/rsocket-transports/ktor-tcp/src/commonTest/kotlin/io/rsocket/kotlin/transport/ktor/tcp/TcpTransportTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,13 +18,14 @@ package io.rsocket.kotlin.transport.ktor.tcp import io.ktor.network.selector.* import io.ktor.network.sockets.* +import io.rsocket.kotlin.internal.io.* import io.rsocket.kotlin.transport.tests.* import kotlinx.coroutines.* @Suppress("DEPRECATION_ERROR") class TcpTransportTest : TransportTest() { override suspend fun before() { - val serverSocket = startServer(TcpServerTransport()).serverSocket.await() + val serverSocket = startServer(TcpServerTransport("127.0.0.1")).serverSocket.await() client = connectClient(TcpClientTransport(serverSocket.localAddress as InetSocketAddress, testContext)) } } @@ -32,11 +33,11 @@ class TcpTransportTest : TransportTest() { class KtorTcpTransportTest : TransportTest() { // a single SelectorManager for both client and server works much better in K/N // in user code in most of the cases, only one SelectorManager will be created - private val selector = SelectorManager(Dispatchers.IO) + private val selector = SelectorManager(Dispatchers.IoCompatible) override suspend fun before() { val server = startServer(KtorTcpServerTransport(testContext) { selectorManager(selector, false) - }.target()) + }.target("127.0.0.1")) client = connectClient(KtorTcpClientTransport(testContext) { selectorManager(selector, false) }.target(server.localAddress)) diff --git a/rsocket-transports/ktor-websocket-client/build.gradle.kts b/rsocket-transports/ktor-websocket-client/build.gradle.kts index f9bcbf6a..e38fe827 100644 --- a/rsocket-transports/ktor-websocket-client/build.gradle.kts +++ b/rsocket-transports/ktor-websocket-client/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ plugins { description = "rsocket-kotlin ktor WebSocket client transport implementation" kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets( + supportsWasi = false + ) sourceSets { commonMain.dependencies { diff --git a/rsocket-transports/ktor-websocket-internal/build.gradle.kts b/rsocket-transports/ktor-websocket-internal/build.gradle.kts index c3583f62..de5caf5a 100644 --- a/rsocket-transports/ktor-websocket-internal/build.gradle.kts +++ b/rsocket-transports/ktor-websocket-internal/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ plugins { description = "rsocket-kotlin ktor WebSocket transport utilities" kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets( + supportsWasi = false + ) sourceSets { commonMain.dependencies { diff --git a/rsocket-transports/ktor-websocket-server/build.gradle.kts b/rsocket-transports/ktor-websocket-server/build.gradle.kts index 078fd3d3..737d35bd 100644 --- a/rsocket-transports/ktor-websocket-server/build.gradle.kts +++ b/rsocket-transports/ktor-websocket-server/build.gradle.kts @@ -23,8 +23,10 @@ plugins { description = "rsocket-kotlin ktor WebSocket server transport implementation" kotlin { - jvmTarget() - nixTargets() + allTargets( + supportsWasi = false, + supportsBrowser = false + ) sourceSets { commonMain.dependencies { diff --git a/rsocket-transports/ktor-websocket-server/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/KtorWebSocketServerTransport.kt b/rsocket-transports/ktor-websocket-server/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/KtorWebSocketServerTransport.kt index 7d690157..b55e5b7a 100644 --- a/rsocket-transports/ktor-websocket-server/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/KtorWebSocketServerTransport.kt +++ b/rsocket-transports/ktor-websocket-server/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/KtorWebSocketServerTransport.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,7 +93,7 @@ private class KtorWebSocketServerTransportBuilderImpl : KtorWebSocketServerTrans @RSocketTransportApi override fun buildTransport(context: CoroutineContext): KtorWebSocketServerTransport = KtorWebSocketServerTransportImpl( // we always add IO - as it's the best choice here, server will use it's own dispatcher anyway - coroutineContext = context.supervisorContext() + Dispatchers.IO, + coroutineContext = context.supervisorContext() + Dispatchers.IoCompatible, factory = requireNotNull(httpServerFactory) { "httpEngine is required" }, webSocketsConfig = webSocketsConfig, ) @@ -191,14 +191,14 @@ private class KtorWebSocketServerTargetImpl( private suspend fun startServer( embeddedServer: EmbeddedServer<*, *>, serverContext: CoroutineContext, - ): List = launchCoroutine(serverContext + Dispatchers.IO) { cont -> - embeddedServer.start() - launch(serverContext + Dispatchers.IO) { + ): List = launchCoroutine(serverContext + Dispatchers.IoCompatible) { cont -> + embeddedServer.startSuspend() + launch(serverContext + Dispatchers.IoCompatible) { try { awaitCancellation() } finally { withContext(NonCancellable) { - embeddedServer.stop() + embeddedServer.stopSuspend() } } } diff --git a/rsocket-transports/ktor-websocket-server/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/WebSocketServerTransport.kt b/rsocket-transports/ktor-websocket-server/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/WebSocketServerTransport.kt index 47bbaa1d..873fc54f 100644 --- a/rsocket-transports/ktor-websocket-server/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/WebSocketServerTransport.kt +++ b/rsocket-transports/ktor-websocket-server/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/WebSocketServerTransport.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import io.ktor.server.routing.* import io.ktor.server.websocket.* import io.rsocket.kotlin.transport.* import io.rsocket.kotlin.transport.ktor.websocket.internal.* +import kotlinx.coroutines.* @Deprecated(level = DeprecationLevel.ERROR, message = "Deprecated in favor of new Transport API, use KtorWebSocketServerTransport") @Suppress("DEPRECATION_ERROR", "FunctionName") @@ -71,7 +72,13 @@ public fun WebSocke this.connectors.addAll(connectors) engine() }.also { - it.start(wait = false) - it.engine.stopServerOnCancellation(it.application) + it.application.launch(start = CoroutineStart.UNDISPATCHED) { + try { + it.startSuspend() + awaitCancellation() + } finally { + it.stopSuspend() + } + } } } diff --git a/rsocket-transports/ktor-websocket-tests/build.gradle.kts b/rsocket-transports/ktor-websocket-tests/build.gradle.kts index 41ae0109..013ed44f 100644 --- a/rsocket-transports/ktor-websocket-tests/build.gradle.kts +++ b/rsocket-transports/ktor-websocket-tests/build.gradle.kts @@ -21,8 +21,10 @@ plugins { } kotlin { - jvmTarget() - nixTargets() + allTargets( + supportsWasi = false, + supportsBrowser = false + ) sourceSets { commonTest.dependencies { diff --git a/rsocket-transports/local/build.gradle.kts b/rsocket-transports/local/build.gradle.kts index f1755711..84464c6d 100644 --- a/rsocket-transports/local/build.gradle.kts +++ b/rsocket-transports/local/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,7 @@ plugins { description = "rsocket-kotlin Local transport implementation" kotlin { - jvmTarget() - jsTarget() - nativeTargets() + allTargets() sourceSets { commonMain.dependencies { diff --git a/rsocket-transports/local/src/commonTest/kotlin/io/rsocket/kotlin/transport/local/LocalTransportTest.kt b/rsocket-transports/local/src/commonTest/kotlin/io/rsocket/kotlin/transport/local/LocalTransportTest.kt index 2b7a242a..b5122f6b 100644 --- a/rsocket-transports/local/src/commonTest/kotlin/io/rsocket/kotlin/transport/local/LocalTransportTest.kt +++ b/rsocket-transports/local/src/commonTest/kotlin/io/rsocket/kotlin/transport/local/LocalTransportTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,20 +40,9 @@ class SequentialBufferedLocalTransportTest : LocalTransportTest({ sequential(prioritizationQueueBuffersCapacity = Channel.BUFFERED) }) -class SequentialUnlimitedLocalTransportTest : LocalTransportTest({ - sequential(prioritizationQueueBuffersCapacity = Channel.UNLIMITED) -}) - class MultiplexedBufferedLocalTransportTest : LocalTransportTest({ multiplexed( streamsQueueCapacity = Channel.BUFFERED, streamBufferCapacity = Channel.BUFFERED ) }) - -class MultiplexedUnlimitedLocalTransportTest : LocalTransportTest({ - multiplexed( - streamsQueueCapacity = Channel.UNLIMITED, - streamBufferCapacity = Channel.UNLIMITED - ) -})