Skip to content

Ktor usage cleanup #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 9, 2025
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
7 changes: 0 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,14 @@ kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutine

kotlinx-benchmark = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }

ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor" }
ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor" }
ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" }
ktor-websockets = { module = "io.ktor:ktor-websockets", version.ref = "ktor" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
ktor-server-websockets = { module = "io.ktor:ktor-server-websockets", version.ref = "ktor" }
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
ktor-server-jetty = { module = "io.ktor:ktor-server-jetty", version.ref = "ktor" }

netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }
Expand Down
8 changes: 1 addition & 7 deletions ktor-plugins/ktor-server-rsocket/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -32,11 +32,5 @@ kotlin {
api(projects.rsocketCore)
api(libs.ktor.server.websockets)
}
commonTest.dependencies {
implementation(projects.ktorClientRsocket)
implementation(projects.rsocketTest)
implementation(libs.ktor.client.cio)
implementation(libs.ktor.server.cio)
}
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,11 +14,23 @@
* limitations under the License.
*/

package io.rsocket.kotlin.transport.ktor.websocket.server
import rsocketbuild.*

import io.ktor.client.engine.cio.CIO as ClientCIO
import io.ktor.server.cio.CIO as ServerCIO
plugins {
id("rsocketbuild.multiplatform-base")
}

class CIOWebSocketTransportTest : WebSocketTransportTest(ClientCIO, ServerCIO)
kotlin {
jvmTarget()
nixTargets()

class CIOKtorWebSocketTransportTest : KtorWebSocketTransportTest(ClientCIO, ServerCIO)
sourceSets {
commonTest.dependencies {
implementation(projects.ktorClientRsocket)
implementation(projects.ktorServerRsocket)
implementation(projects.rsocketTest)
implementation(libs.ktor.client.cio)
implementation(libs.ktor.server.cio)
}
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.rsocket.kotlin.transport.ktor.websocket.server
package io.rsocket.kotlin.ktor.tests

import io.ktor.client.*
import io.ktor.server.application.*
Expand Down
14 changes: 2 additions & 12 deletions rsocket-transports/ktor-websocket-server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -31,18 +31,8 @@ kotlin {
implementation(projects.rsocketTransportKtorWebsocketInternal)
implementation(projects.rsocketInternalIo)
api(projects.rsocketCore)
api(libs.ktor.server.host.common)
api(libs.ktor.server.core)
api(libs.ktor.server.websockets)
}
commonTest.dependencies {
implementation(projects.rsocketTransportTests)
implementation(projects.rsocketTransportKtorWebsocketClient)
implementation(libs.ktor.client.cio)
implementation(libs.ktor.server.cio)
}
jvmTest.dependencies {
implementation(libs.ktor.client.okhttp)
implementation(libs.ktor.server.netty)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,12 +14,23 @@
* limitations under the License.
*/

package io.rsocket.kotlin.transport.ktor.websocket.client
import rsocketbuild.*

//class ClientWebSocketTransportTest : TransportTest() {
// override suspend fun before() {
// client = connectClient(
// WebSocketClientTransport(Js, port = 9000, context = testContext, pool = InUseTrackingPool)
// )
// }
//}
plugins {
id("rsocketbuild.multiplatform-base")
}

kotlin {
jvmTarget()
nixTargets()

sourceSets {
commonTest.dependencies {
implementation(projects.rsocketTransportTests)
implementation(projects.rsocketTransportKtorWebsocketClient)
implementation(projects.rsocketTransportKtorWebsocketServer)
implementation(libs.ktor.client.cio)
implementation(libs.ktor.server.cio)
}
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,43 +14,38 @@
* limitations under the License.
*/

package io.rsocket.kotlin.transport.ktor.websocket.server
package io.rsocket.kotlin.transport.ktor.websocket.tests

import io.ktor.client.engine.*
import io.ktor.server.engine.*
import io.rsocket.kotlin.transport.ktor.websocket.client.*
import io.rsocket.kotlin.transport.ktor.websocket.server.*
import io.rsocket.kotlin.transport.tests.*
import io.ktor.client.engine.cio.CIO as ClientCIO
import io.ktor.server.cio.CIO as ServerCIO

@Suppress("DEPRECATION_ERROR")
abstract class WebSocketTransportTest(
private val clientEngine: HttpClientEngineFactory<*>,
private val serverEngine: ApplicationEngineFactory<*, *>,
) : TransportTest() {
class WebSocketTransportTest : TransportTest() {
override suspend fun before() {
val embeddedServer = startServer(
WebSocketServerTransport(serverEngine, port = 0)
WebSocketServerTransport(ServerCIO, port = 0)
)
val connector = embeddedServer.engine.resolvedConnectors().single()
client = connectClient(
WebSocketClientTransport(clientEngine, port = connector.port, context = testContext)
WebSocketClientTransport(ClientCIO, port = connector.port, context = testContext)
)
}
}

abstract class KtorWebSocketTransportTest(
private val clientEngine: HttpClientEngineFactory<*>,
private val serverEngine: ApplicationEngineFactory<*, *>,
) : TransportTest() {
class KtorWebSocketTransportTest : TransportTest() {
override suspend fun before() {
val server = startServer(
KtorWebSocketServerTransport(testContext) {
httpEngine(serverEngine)
httpEngine(ServerCIO)
}.target(port = 0)
)
val port = server.connectors.single().port
client = connectClient(
KtorWebSocketClientTransport(testContext) {
httpEngine(clientEngine)
httpEngine(ClientCIO)
}.target(port = port)
)
}
Expand Down
4 changes: 3 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -41,6 +41,7 @@ projects("rsocket-kotlin") {
module("ktor-websocket-internal")
module("ktor-websocket-client")
module("ktor-websocket-server")
module("ktor-websocket-tests")

module("netty-internal")
module("netty-tcp")
Expand All @@ -52,6 +53,7 @@ projects("rsocket-kotlin") {
folder("ktor-plugins", null) {
module("ktor-client-rsocket")
module("ktor-server-rsocket")
module("ktor-tests")
// for migration from old names
module("rsocket-ktor-client")
module("rsocket-ktor-server")
Expand Down