Skip to content

Make KtorRpcClient inherit KrpcClient #396

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 1 commit into from
Jul 17, 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
3 changes: 2 additions & 1 deletion krpc/krpc-ktor/krpc-ktor-client/api/krpc-ktor-client.api
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public final class kotlinx/rpc/krpc/ktor/client/KtorClientDslKt {
public static synthetic fun rpcConfig$default (Lio/ktor/client/request/HttpRequestBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
}

public abstract interface class kotlinx/rpc/krpc/ktor/client/KtorRpcClient : kotlinx/rpc/RpcClient {
public abstract class kotlinx/rpc/krpc/ktor/client/KtorRpcClient : kotlinx/rpc/krpc/client/KrpcClient {
public fun <init> ()V
public abstract fun getWebSocketSession ()Lkotlinx/coroutines/Deferred;
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
// - Show declarations: true

// Library unique name: <org.jetbrains.kotlinx:krpc-ktor-client>
abstract interface kotlinx.rpc.krpc.ktor.client/KtorRpcClient : kotlinx.rpc/RpcClient { // kotlinx.rpc.krpc.ktor.client/KtorRpcClient|null[0]
abstract class kotlinx.rpc.krpc.ktor.client/KtorRpcClient : kotlinx.rpc.krpc.client/KrpcClient { // kotlinx.rpc.krpc.ktor.client/KtorRpcClient|null[0]
constructor <init>() // kotlinx.rpc.krpc.ktor.client/KtorRpcClient.<init>|<init>(){}[0]

abstract val webSocketSession // kotlinx.rpc.krpc.ktor.client/KtorRpcClient.webSocketSession|{}webSocketSession[0]
abstract fun <get-webSocketSession>(): kotlinx.coroutines/Deferred<io.ktor.websocket/WebSocketSession> // kotlinx.rpc.krpc.ktor.client/KtorRpcClient.webSocketSession.<get-webSocketSession>|<get-webSocketSession>(){}[0]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package kotlinx.rpc.krpc.ktor.client
Expand All @@ -22,19 +22,19 @@ import kotlinx.rpc.krpc.rpcClientConfig
* Client is cold, meaning the connection will be established on the first request.
* [webSocketSession] will be completed when the connection is established.
*/
public interface KtorRpcClient : RpcClient {
public abstract class KtorRpcClient : KrpcClient() {
/**
* Cold [WebSocketSession] object. Instantiated when the connection is established on the first request.
*/
public val webSocketSession: Deferred<WebSocketSession>
public abstract val webSocketSession: Deferred<WebSocketSession>
}

internal class KtorKrpcClientImpl(
private val pluginConfigBuilder: KrpcConfigBuilder.Client?,
private val webSocketSessionFactory: suspend (
configSetter: (KrpcConfigBuilder.Client.() -> Unit) -> Unit,
) -> WebSocketSession,
): KrpcClient(), KtorRpcClient {
): KtorRpcClient() {
private var requestConfigBuilder: KrpcConfigBuilder.Client.() -> Unit = {}

private val _webSocketSession = CompletableDeferred<WebSocketSession>()
Expand Down