Skip to content

Commit 7c3f7e8

Browse files
committed
Cleanup shared code:
* create IoCompatible dispatcher * drop unneeded test utils * use `startSuspend`/`stopSuspend` to support web targets
1 parent cb119d4 commit 7c3f7e8

File tree

18 files changed

+53
-165
lines changed

18 files changed

+53
-165
lines changed

ktor-plugins/ktor-tests/src/commonTest/kotlin/io/rsocket/kotlin/ktor/tests/WebSocketConnectionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ class WebSocketConnectionTest : SuspendTest {
7676
}
7777

7878
override suspend fun before() {
79-
server.start()
79+
server.startSuspend()
8080
delay(1000)
8181
}
8282

8383
override suspend fun after() {
84-
server.stop()
84+
server.stopSuspend()
8585
client.coroutineContext.job.cancelAndJoin()
8686
}
8787

rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package io.rsocket.kotlin.internal
1818

1919
import io.rsocket.kotlin.*
2020
import io.rsocket.kotlin.frame.*
21+
import io.rsocket.kotlin.internal.io.*
2122
import io.rsocket.kotlin.keepalive.*
2223
import io.rsocket.kotlin.payload.*
2324
import io.rsocket.kotlin.test.*
@@ -102,7 +103,7 @@ class RSocketRequesterTest : TestWithConnection() {
102103
val flow = requester.requestStream(Payload.Empty).take(2).flowOn(PrefetchStrategy(1, 0))
103104

104105
expectNoEventsIn(200)
105-
flow.launchIn(connection + anotherDispatcher)
106+
flow.launchIn(connection + Dispatchers.IoCompatible)
106107

107108
awaitFrame { frame ->
108109
assertTrue(frame is RequestFrame)

rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/transport/internal/PrioritizationFrameQueueTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package io.rsocket.kotlin.transport.internal
1818

19+
import io.rsocket.kotlin.internal.io.*
1920
import io.rsocket.kotlin.test.*
2021
import kotlinx.coroutines.*
2122
import kotlinx.coroutines.channels.*
@@ -62,7 +63,7 @@ class PrioritizationFrameQueueTest : SuspendTest {
6263
@Test
6364
fun testAsyncReceive() = test {
6465
val deferred = CompletableDeferred<Source?>()
65-
launch(anotherDispatcher) {
66+
launch(Dispatchers.IoCompatible) {
6667
deferred.complete(queue.dequeueFrame())
6768
}
6869
delay(100)

rsocket-core/src/jsMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt

Lines changed: 0 additions & 57 deletions
This file was deleted.

rsocket-core/src/nativeMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt renamed to rsocket-core/src/nonJvmMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2022 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,5 +19,5 @@ package io.rsocket.kotlin.logging
1919
import io.rsocket.kotlin.*
2020

2121
@RSocketLoggingApi
22-
public actual val DefaultLoggerFactory: LoggerFactory
22+
internal actual val DefaultLoggerFactory: LoggerFactory
2323
get() = PrintLogger

rsocket-internal-io/api/rsocket-internal-io.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public final class io/rsocket/kotlin/internal/io/ContextKt {
1313
public static final fun supervisorContext (Lkotlin/coroutines/CoroutineContext;)Lkotlin/coroutines/CoroutineContext;
1414
}
1515

16+
public final class io/rsocket/kotlin/internal/io/Context_concurrentKt {
17+
public static final fun getIoCompatible (Lkotlinx/coroutines/Dispatchers;)Lkotlinx/coroutines/CoroutineDispatcher;
18+
}
19+
1620
public final class io/rsocket/kotlin/internal/io/Int24Kt {
1721
public static final fun readInt24 (Lkotlinx/io/Source;)I
1822
public static final fun writeInt24 (Lkotlinx/io/Sink;I)V

rsocket-internal-io/src/commonMain/kotlin/io/rsocket/kotlin/internal/io/Context.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@ package io.rsocket.kotlin.internal.io
1919
import kotlinx.coroutines.*
2020
import kotlin.coroutines.*
2121

22+
public expect val Dispatchers.IoCompatible: CoroutineDispatcher
23+
2224
public fun CoroutineContext.supervisorContext(): CoroutineContext = plus(SupervisorJob(get(Job)))
2325
public fun CoroutineContext.childContext(): CoroutineContext = plus(Job(get(Job)))
2426

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,14 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.test
17+
package io.rsocket.kotlin.internal.io
1818

1919
import kotlinx.coroutines.*
2020

21-
expect annotation class IgnoreJs()
22-
expect annotation class IgnoreJvm()
23-
expect annotation class IgnoreNative()
24-
25-
expect val anotherDispatcher: CoroutineDispatcher
26-
27-
expect fun identityHashCode(instance: Any): Int
21+
public actual val Dispatchers.IoCompatible: CoroutineDispatcher get() = IO
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,15 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.test
17+
package io.rsocket.kotlin.internal.io
1818

1919
import kotlinx.coroutines.*
2020

21-
actual annotation class IgnoreJs
22-
actual typealias IgnoreJvm = org.junit.Ignore
23-
24-
actual annotation class IgnoreNative
25-
26-
actual val anotherDispatcher: CoroutineDispatcher get() = Dispatchers.IO
27-
28-
actual fun identityHashCode(instance: Any): Int = System.identityHashCode(instance)
21+
public actual val Dispatchers.IoCompatible: CoroutineDispatcher get() = Default

rsocket-test/src/jsMain/kotlin/io/rsocket/kotlin/test/Test.kt

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)