Skip to content
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

Kotlin 2.0 #264

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ syntax: glob
!/.idea/codeStyles
*.iml

.kotlin
.gradle
classes
build/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ plugins {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
compilerOptions {
// because of https://youtrack.jetbrains.com/issue/KT-64115/KGP-JVM-JS-WASM-The-same-library-can-be-passed-twice-to-the-compiler
// allWarningsAsErrors.set(true)
// because of INVISIBLE_REFERENCE suppression - will be removed after migration to kotlinx.io
if (project.name != "rsocket-test") {
allWarningsAsErrors.set(true)
}
progressiveMode.set(true)
freeCompilerArgs.add("-Xrender-internal-diagnostic-names")
optIn.addAll(OptIns.ExperimentalSubclassOptIn)
}

sourceSets.configureEach {
languageSettings {
if (name.contains("test", ignoreCase = true)) {
// for hex API
optIn(OptIns.ExperimentalStdlibApi)
// for channel.isClosedForSend - need to be replaced by testing via turbine or optIn in place
// and GlobalScope - need to be dropped
optIn(OptIns.DelicateCoroutinesApi)

// rsocket related
Expand All @@ -54,10 +60,8 @@ kotlin {
}

targets.withType<KotlinJvmTarget>().configureEach {
compilations.configureEach {
compilerOptions.configure {
freeCompilerArgs.add("-Xjvm-default=all")
}
compilerOptions {
freeCompilerArgs.add("-Xjvm-default=all")
}
}

Expand Down
1 change: 1 addition & 0 deletions build-logic/src/main/kotlin/rsocketbuild/OptIns.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package rsocketbuild

@Suppress("ConstPropertyName")
object OptIns {
const val ExperimentalSubclassOptIn = "kotlin.ExperimentalSubclassOptIn"
const val ExperimentalStdlibApi = "kotlin.ExperimentalStdlibApi"
const val ExperimentalCoroutinesApi = "kotlinx.coroutines.ExperimentalCoroutinesApi"
const val DelicateCoroutinesApi = "kotlinx.coroutines.DelicateCoroutinesApi"
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "1.9.24"
kotlin = "2.0.0"

kotlinx-atomicfu = "0.24.0"
kotlinx-coroutines = "1.8.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal suspend fun HttpClient.connectRSocket(request: HttpRequestBuilder.() ->
return config.connector.connect(RSocketSupportTarget(this, request))
}

@OptIn(RSocketTransportApi::class)
private class RSocketSupportTarget(
private val client: HttpClient,
private val request: HttpRequestBuilder.() -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import io.rsocket.kotlin.transport.*
import kotlinx.coroutines.*
import kotlin.coroutines.*

@OptIn(RSocketTransportApi::class)
public sealed interface KtorTcpClientTransport : RSocketTransport {
public fun target(remoteAddress: SocketAddress): RSocketClientTarget
public fun target(host: String, port: Int): RSocketClientTarget
Expand All @@ -31,6 +32,7 @@ public sealed interface KtorTcpClientTransport : RSocketTransport {
RSocketTransportFactory<KtorTcpClientTransport, KtorTcpClientTransportBuilder>(::KtorTcpClientTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface KtorTcpClientTransportBuilder : RSocketTransportBuilder<KtorTcpClientTransport> {
public fun dispatcher(context: CoroutineContext)
public fun inheritDispatcher(): Unit = dispatcher(EmptyCoroutineContext)
Expand Down Expand Up @@ -92,6 +94,7 @@ private class KtorTcpClientTransportImpl(
override fun target(host: String, port: Int): RSocketClientTarget = target(InetSocketAddress(host, port))
}

@OptIn(RSocketTransportApi::class)
private class KtorTcpClientTargetImpl(
override val coroutineContext: CoroutineContext,
private val socketOptions: SocketOptions.TCPClientSocketOptions.() -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import io.rsocket.kotlin.transport.*
import kotlinx.coroutines.*
import kotlin.coroutines.*

@OptIn(RSocketTransportApi::class)
public sealed interface KtorTcpServerInstance : RSocketServerInstance {
public val localAddress: SocketAddress
}

@OptIn(RSocketTransportApi::class)
public sealed interface KtorTcpServerTransport : RSocketTransport {
public fun target(localAddress: SocketAddress? = null): RSocketServerTarget<KtorTcpServerInstance>
public fun target(host: String = "0.0.0.0", port: Int = 0): RSocketServerTarget<KtorTcpServerInstance>
Expand All @@ -35,6 +37,7 @@ public sealed interface KtorTcpServerTransport : RSocketTransport {
RSocketTransportFactory<KtorTcpServerTransport, KtorTcpServerTransportBuilder>(::KtorTcpServerTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface KtorTcpServerTransportBuilder : RSocketTransportBuilder<KtorTcpServerTransport> {
public fun dispatcher(context: CoroutineContext)
public fun inheritDispatcher(): Unit = dispatcher(EmptyCoroutineContext)
Expand Down Expand Up @@ -94,6 +97,7 @@ private class KtorTcpServerTransportImpl(
override fun target(host: String, port: Int): RSocketServerTarget<KtorTcpServerInstance> = target(InetSocketAddress(host, port))
}

@OptIn(RSocketTransportApi::class)
private class KtorTcpServerTargetImpl(
override val coroutineContext: CoroutineContext,
private val socketOptions: SocketOptions.AcceptorOptions.() -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.rsocket.kotlin.transport.ktor.websocket.internal.*
import kotlinx.coroutines.*
import kotlin.coroutines.*

@OptIn(RSocketTransportApi::class)
public sealed interface KtorWebSocketClientTransport : RSocketTransport {
public fun target(request: HttpRequestBuilder.() -> Unit): RSocketClientTarget
public fun target(urlString: String, request: HttpRequestBuilder.() -> Unit = {}): RSocketClientTarget
Expand All @@ -43,6 +44,7 @@ public sealed interface KtorWebSocketClientTransport : RSocketTransport {
RSocketTransportFactory<KtorWebSocketClientTransport, KtorWebSocketClientTransportBuilder>(::KtorWebSocketClientTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface KtorWebSocketClientTransportBuilder : RSocketTransportBuilder<KtorWebSocketClientTransport> {
public fun httpEngine(configure: HttpClientEngineConfig.() -> Unit)
public fun httpEngine(engine: HttpClientEngine, configure: HttpClientEngineConfig.() -> Unit = {})
Expand Down Expand Up @@ -128,6 +130,7 @@ private class KtorWebSocketClientTransportImpl(
}
}

@OptIn(RSocketTransportApi::class)
private class KtorWebSocketClientTargetImpl(
override val coroutineContext: CoroutineContext,
private val httpClient: HttpClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ import io.rsocket.kotlin.transport.ktor.websocket.internal.*
import kotlinx.coroutines.*
import kotlin.coroutines.*

@OptIn(RSocketTransportApi::class)
public sealed interface KtorWebSocketServerInstance : RSocketServerInstance {
public val connectors: List<EngineConnectorConfig>
public val path: String
public val protocol: String?
}

@OptIn(RSocketTransportApi::class)
public sealed interface KtorWebSocketServerTransport : RSocketTransport {

public fun target(
Expand Down Expand Up @@ -63,6 +65,7 @@ public sealed interface KtorWebSocketServerTransport : RSocketTransport {
RSocketTransportFactory<KtorWebSocketServerTransport, KtorWebSocketServerTransportBuilder>(::KtorWebSocketServerTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface KtorWebSocketServerTransportBuilder : RSocketTransportBuilder<KtorWebSocketServerTransport> {
public fun <A : ApplicationEngine, T : ApplicationEngine.Configuration> httpEngine(
factory: ApplicationEngineFactory<A, T>,
Expand Down Expand Up @@ -137,6 +140,7 @@ private class KtorWebSocketServerTransportImpl(
): RSocketServerTarget<KtorWebSocketServerInstance> = target(listOf(connector), path, protocol)
}

@OptIn(RSocketTransportApi::class)
private class KtorWebSocketServerTargetImpl(
override val coroutineContext: CoroutineContext,
private val factory: HttpServerFactory<*, *>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ import io.rsocket.kotlin.transport.*
import kotlinx.coroutines.*
import kotlin.coroutines.*

@OptIn(RSocketTransportApi::class)
public sealed interface LocalClientTransport : RSocketTransport {
public fun target(serverName: String): RSocketClientTarget

public companion object Factory :
RSocketTransportFactory<LocalClientTransport, LocalClientTransportBuilder>(::LocalClientTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface LocalClientTransportBuilder : RSocketTransportBuilder<LocalClientTransport> {
public fun dispatcher(context: CoroutineContext)
public fun inheritDispatcher(): Unit = dispatcher(EmptyCoroutineContext)
Expand Down Expand Up @@ -56,6 +58,7 @@ private class LocalClientTransportImpl(
)
}

@OptIn(RSocketTransportApi::class)
private class LocalClientTargetImpl(
override val coroutineContext: CoroutineContext,
private val server: LocalServerInstanceImpl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import kotlin.coroutines.*
import kotlin.random.*

// TODO: rename to inprocess and more to another module/package later
@OptIn(RSocketTransportApi::class)
public sealed interface LocalServerInstance : RSocketServerInstance {
public val serverName: String
}

@OptIn(RSocketTransportApi::class)
public sealed interface LocalServerTransport : RSocketTransport {
public fun target(): RSocketServerTarget<LocalServerInstance>
public fun target(serverName: String): RSocketServerTarget<LocalServerInstance>
Expand All @@ -36,6 +38,7 @@ public sealed interface LocalServerTransport : RSocketTransport {
RSocketTransportFactory<LocalServerTransport, LocalServerTransportBuilder>(::LocalServerTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface LocalServerTransportBuilder : RSocketTransportBuilder<LocalServerTransport> {
public fun dispatcher(context: CoroutineContext)
public fun inheritDispatcher(): Unit = dispatcher(EmptyCoroutineContext)
Expand Down Expand Up @@ -90,6 +93,7 @@ private class LocalServerTransportImpl(
)
}

@OptIn(RSocketTransportApi::class)
private class LocalServerTargetImpl(
override val coroutineContext: CoroutineContext,
private val serverName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import java.net.*
import kotlin.coroutines.*
import kotlin.reflect.*

@OptIn(RSocketTransportApi::class)
public sealed interface NettyQuicClientTransport : RSocketTransport {
public fun target(remoteAddress: InetSocketAddress): RSocketClientTarget
public fun target(host: String, port: Int): RSocketClientTarget
Expand All @@ -39,6 +40,7 @@ public sealed interface NettyQuicClientTransport : RSocketTransport {
RSocketTransportFactory<NettyQuicClientTransport, NettyQuicClientTransportBuilder>(::NettyQuicClientTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyQuicClientTransportBuilder : RSocketTransportBuilder<NettyQuicClientTransport> {
public fun channel(cls: KClass<out DatagramChannel>)
public fun channelFactory(factory: ChannelFactory<out DatagramChannel>)
Expand Down Expand Up @@ -137,6 +139,7 @@ private class NettyQuicClientTransportImpl(
override fun target(host: String, port: Int): RSocketClientTarget = target(InetSocketAddress(host, port))
}

@OptIn(RSocketTransportApi::class)
private class NettyQuicClientTargetImpl(
override val coroutineContext: CoroutineContext,
private val bootstrap: Bootstrap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ import javax.net.ssl.*
import kotlin.coroutines.*
import kotlin.reflect.*

@OptIn(RSocketTransportApi::class)
public sealed interface NettyQuicServerInstance : RSocketServerInstance {
public val localAddress: InetSocketAddress
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyQuicServerTransport : RSocketTransport {
public fun target(localAddress: InetSocketAddress? = null): RSocketServerTarget<NettyQuicServerInstance>
public fun target(host: String = "127.0.0.1", port: Int = 0): RSocketServerTarget<NettyQuicServerInstance>
Expand All @@ -44,6 +46,7 @@ public sealed interface NettyQuicServerTransport : RSocketTransport {
RSocketTransportFactory<NettyQuicServerTransport, NettyQuicServerTransportBuilder>(::NettyQuicServerTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyQuicServerTransportBuilder : RSocketTransportBuilder<NettyQuicServerTransport> {
public fun channel(cls: KClass<out DatagramChannel>)
public fun channelFactory(factory: ChannelFactory<out DatagramChannel>)
Expand Down Expand Up @@ -137,6 +140,7 @@ private class NettyQuicServerTransportImpl(
target(InetSocketAddress(host, port))
}

@OptIn(RSocketTransportApi::class)
private class NettyQuicServerTargetImpl(
override val coroutineContext: CoroutineContext,
private val bootstrap: Bootstrap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import java.net.*
import kotlin.coroutines.*
import kotlin.reflect.*

@OptIn(RSocketTransportApi::class)
public sealed interface NettyTcpClientTransport : RSocketTransport {
public fun target(remoteAddress: SocketAddress): RSocketClientTarget
public fun target(host: String, port: Int): RSocketClientTarget
Expand All @@ -39,6 +40,7 @@ public sealed interface NettyTcpClientTransport : RSocketTransport {
RSocketTransportFactory<NettyTcpClientTransport, NettyTcpClientTransportBuilder>(::NettyTcpClientTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyTcpClientTransportBuilder : RSocketTransportBuilder<NettyTcpClientTransport> {
public fun channel(cls: KClass<out DuplexChannel>)
public fun channelFactory(factory: ChannelFactory<out DuplexChannel>)
Expand Down Expand Up @@ -119,6 +121,7 @@ private class NettyTcpClientTransportImpl(
override fun target(host: String, port: Int): RSocketClientTarget = target(InetSocketAddress(host, port))
}

@OptIn(RSocketTransportApi::class)
private class NettyTcpClientTargetImpl(
override val coroutineContext: CoroutineContext,
private val bootstrap: Bootstrap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ import javax.net.ssl.*
import kotlin.coroutines.*
import kotlin.reflect.*

@OptIn(RSocketTransportApi::class)
public sealed interface NettyTcpServerInstance : RSocketServerInstance {
public val localAddress: SocketAddress
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyTcpServerTransport : RSocketTransport {
public fun target(localAddress: SocketAddress? = null): RSocketServerTarget<NettyTcpServerInstance>
public fun target(host: String = "0.0.0.0", port: Int = 0): RSocketServerTarget<NettyTcpServerInstance>
Expand All @@ -43,6 +45,7 @@ public sealed interface NettyTcpServerTransport : RSocketTransport {
RSocketTransportFactory<NettyTcpServerTransport, NettyTcpServerTransportBuilder>(::NettyTcpServerTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyTcpServerTransportBuilder : RSocketTransportBuilder<NettyTcpServerTransport> {
public fun channel(cls: KClass<out ServerChannel>)
public fun channelFactory(factory: ChannelFactory<out ServerChannel>)
Expand Down Expand Up @@ -134,6 +137,7 @@ private class NettyTcpServerTransportImpl(
target(InetSocketAddress(host, port))
}

@OptIn(RSocketTransportApi::class)
private class NettyTcpServerTargetImpl(
override val coroutineContext: CoroutineContext,
private val bootstrap: ServerBootstrap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import java.net.*
import kotlin.coroutines.*
import kotlin.reflect.*

@OptIn(RSocketTransportApi::class)
public sealed interface NettyWebSocketClientTransport : RSocketTransport {
public fun target(configure: WebSocketClientProtocolConfig.Builder.() -> Unit): RSocketClientTarget
public fun target(uri: URI, configure: WebSocketClientProtocolConfig.Builder.() -> Unit = {}): RSocketClientTarget
Expand All @@ -49,6 +50,7 @@ public sealed interface NettyWebSocketClientTransport : RSocketTransport {
RSocketTransportFactory<NettyWebSocketClientTransport, NettyWebSocketClientTransportBuilder>(::NettyWebSocketClientTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyWebSocketClientTransportBuilder : RSocketTransportBuilder<NettyWebSocketClientTransport> {
public fun channel(cls: KClass<out DuplexChannel>)
public fun channelFactory(factory: ChannelFactory<out DuplexChannel>)
Expand Down Expand Up @@ -174,6 +176,7 @@ private class NettyWebSocketClientTransportImpl(
}
}

@OptIn(RSocketTransportApi::class)
private class NettyWebSocketClientTransportTargetImpl(
override val coroutineContext: CoroutineContext,
private val bootstrap: Bootstrap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ import javax.net.ssl.*
import kotlin.coroutines.*
import kotlin.reflect.*

@OptIn(RSocketTransportApi::class)
public sealed interface NettyWebSocketServerInstance : RSocketServerInstance {
public val localAddress: InetSocketAddress
public val webSocketProtocolConfig: WebSocketServerProtocolConfig
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyWebSocketServerTransport : RSocketTransport {

public fun target(
Expand All @@ -57,6 +59,7 @@ public sealed interface NettyWebSocketServerTransport : RSocketTransport {
RSocketTransportFactory<NettyWebSocketServerTransport, NettyWebSocketServerTransportBuilder>(::NettyWebSocketServerTransportBuilderImpl)
}

@OptIn(RSocketTransportApi::class)
public sealed interface NettyWebSocketServerTransportBuilder : RSocketTransportBuilder<NettyWebSocketServerTransport> {
public fun channel(cls: KClass<out ServerChannel>)
public fun channelFactory(factory: ChannelFactory<out ServerChannel>)
Expand Down Expand Up @@ -168,6 +171,7 @@ private class NettyWebSocketServerTransportImpl(
target(InetSocketAddress(host, port), path, protocol)
}

@OptIn(RSocketTransportApi::class)
private class NettyWebSocketServerTargetImpl(
override val coroutineContext: CoroutineContext,
private val bootstrap: ServerBootstrap,
Expand Down
Loading
Loading