Skip to content
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
8 changes: 8 additions & 0 deletions docs/pages/kotlinx-rpc/topics/platforms.topic
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@
<td><list><li>apple<list><li>ios<list><li>iosArm64</li><li>iosSimulatorArm64</li><li>iosX64</li></list></li><li>macos<list><li>macosArm64</li><li>macosX64</li></list></li><li>watchos<list><li>watchosArm32</li><li>watchosArm64</li><li>watchosDeviceArm64</li><li>watchosSimulatorArm64</li><li>watchosX64</li></list></li><li>tvos<list><li>tvosArm64</li><li>tvosSimulatorArm64</li><li>tvosX64</li></list></li></list></li><li>linux<list><li>linuxArm64</li><li>linuxX64</li></list></li><li>windows<list><li>mingwX64</li></list></li></list></td>
</tr>

<tr>
<td>grpc-ktor-server</td>
<td>jvm</td>
<td><list><li>browser</li><li>node</li></list></td>
<td><list><li>wasmJs<list><li>browser</li><li>d8</li><li>node</li></list></li></list></td>
<td><list><li>apple<list><li>ios<list><li>iosArm64</li><li>iosSimulatorArm64</li><li>iosX64</li></list></li><li>macos<list><li>macosArm64</li><li>macosX64</li></list></li><li>watchos<list><li>watchosArm32</li><li>watchosArm64</li><li>watchosDeviceArm64</li><li>watchosSimulatorArm64</li><li>watchosX64</li></list></li><li>tvos<list><li>tvosArm64</li><li>tvosSimulatorArm64</li><li>tvosX64</li></list></li></list></li><li>linux<list><li>linuxArm64</li><li>linuxX64</li></list></li><li>windows<list><li>mingwX64</li></list></li></list></td>
</tr>

<tr>
<td>krpc-client</td>
<td>jvm</td>
Expand Down
14 changes: 8 additions & 6 deletions grpc/grpc-core/api/grpc-core.api
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
public final class kotlinx/rpc/grpc/GrpcClient : kotlinx/rpc/RpcClient {
public final fun awaitTermination-VtjQ1oo (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun call (Lkotlinx/rpc/RpcCall;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun callAsync (Lkotlinx/coroutines/CoroutineScope;Lkotlinx/rpc/RpcCall;)Lkotlinx/coroutines/Deferred;
public fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
public fun provideStubContext (J)Lkotlin/coroutines/CoroutineContext;
public fun callServerStreaming (Lkotlinx/rpc/RpcCall;)Lkotlinx/coroutines/flow/Flow;
public final fun shutdown ()V
public final fun shutdownNow ()V
}

public final class kotlinx/rpc/grpc/GrpcClientKt {
Expand All @@ -14,11 +15,11 @@ public final class kotlinx/rpc/grpc/GrpcClientKt {

public final class kotlinx/rpc/grpc/GrpcServer : kotlinx/rpc/RpcServer, kotlinx/rpc/grpc/Server {
public fun awaitTermination-VtjQ1oo (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
public fun deregisterService (Lkotlin/reflect/KClass;)V
public fun getPort ()I
public fun isShutdown ()Z
public fun isTerminated ()Z
public fun registerService (Lkotlin/reflect/KClass;Lkotlin/jvm/functions/Function1;)V
public fun registerService (Lkotlin/reflect/KClass;Lkotlin/jvm/functions/Function0;)V
public fun shutdown ()Lkotlinx/rpc/grpc/GrpcServer;
public synthetic fun shutdown ()Lkotlinx/rpc/grpc/Server;
public fun shutdownNow ()Lkotlinx/rpc/grpc/GrpcServer;
Expand Down Expand Up @@ -47,6 +48,7 @@ public final class kotlinx/rpc/grpc/ManagedChannel_jvmKt {

public abstract interface class kotlinx/rpc/grpc/Server {
public abstract fun awaitTermination-VtjQ1oo (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun awaitTermination-VtjQ1oo$default (Lkotlinx/rpc/grpc/Server;JLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public abstract fun getPort ()I
public abstract fun isShutdown ()Z
public abstract fun isTerminated ()Z
Expand Down Expand Up @@ -102,7 +104,7 @@ public final class kotlinx/rpc/grpc/StatusRuntimeException_jvmKt {

public abstract interface class kotlinx/rpc/grpc/descriptor/GrpcClientDelegate {
public abstract fun call (Lkotlinx/rpc/RpcCall;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun callAsync (Lkotlinx/rpc/RpcCall;)Lkotlinx/coroutines/Deferred;
public abstract fun callServerStreaming (Lkotlinx/rpc/RpcCall;)Lkotlinx/coroutines/flow/Flow;
}

public abstract interface class kotlinx/rpc/grpc/descriptor/GrpcDelegate {
Expand Down
145 changes: 145 additions & 0 deletions grpc/grpc-core/api/grpc-core.klib.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Klib ABI Dump
// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
// Rendering settings:
// - Signature version: 2
// - Show manifest properties: true
// - Show declarations: true

// Library unique name: <org.jetbrains.kotlinx:grpc-core>
abstract interface <#A: kotlin/Any> kotlinx.rpc.grpc.descriptor/GrpcDelegate { // kotlinx.rpc.grpc.descriptor/GrpcDelegate|null[0]
abstract fun clientProvider(kotlinx.rpc.grpc/ManagedChannel): kotlinx.rpc.grpc.descriptor/GrpcClientDelegate // kotlinx.rpc.grpc.descriptor/GrpcDelegate.clientProvider|clientProvider(kotlinx.rpc.grpc.ManagedChannel){}[0]
abstract fun definitionFor(#A): kotlinx.rpc.grpc/ServerServiceDefinition // kotlinx.rpc.grpc.descriptor/GrpcDelegate.definitionFor|definitionFor(1:0){}[0]
}

abstract interface <#A: kotlin/Any> kotlinx.rpc.grpc.descriptor/GrpcServiceDescriptor : kotlinx.rpc.descriptor/RpcServiceDescriptor<#A> { // kotlinx.rpc.grpc.descriptor/GrpcServiceDescriptor|null[0]
abstract val delegate // kotlinx.rpc.grpc.descriptor/GrpcServiceDescriptor.delegate|{}delegate[0]
abstract fun <get-delegate>(): kotlinx.rpc.grpc.descriptor/GrpcDelegate<#A> // kotlinx.rpc.grpc.descriptor/GrpcServiceDescriptor.delegate.<get-delegate>|<get-delegate>(){}[0]
}

abstract interface kotlinx.rpc.grpc.descriptor/GrpcClientDelegate { // kotlinx.rpc.grpc.descriptor/GrpcClientDelegate|null[0]
abstract fun <#A1: kotlin/Any?> callServerStreaming(kotlinx.rpc/RpcCall): kotlinx.coroutines.flow/Flow<#A1> // kotlinx.rpc.grpc.descriptor/GrpcClientDelegate.callServerStreaming|callServerStreaming(kotlinx.rpc.RpcCall){0§<kotlin.Any?>}[0]
abstract suspend fun <#A1: kotlin/Any?> call(kotlinx.rpc/RpcCall): #A1 // kotlinx.rpc.grpc.descriptor/GrpcClientDelegate.call|call(kotlinx.rpc.RpcCall){0§<kotlin.Any?>}[0]
}

abstract interface kotlinx.rpc.grpc/ManagedChannel { // kotlinx.rpc.grpc/ManagedChannel|null[0]
abstract val isShutdown // kotlinx.rpc.grpc/ManagedChannel.isShutdown|{}isShutdown[0]
abstract fun <get-isShutdown>(): kotlin/Boolean // kotlinx.rpc.grpc/ManagedChannel.isShutdown.<get-isShutdown>|<get-isShutdown>(){}[0]
abstract val isTerminated // kotlinx.rpc.grpc/ManagedChannel.isTerminated|{}isTerminated[0]
abstract fun <get-isTerminated>(): kotlin/Boolean // kotlinx.rpc.grpc/ManagedChannel.isTerminated.<get-isTerminated>|<get-isTerminated>(){}[0]
abstract val platformApi // kotlinx.rpc.grpc/ManagedChannel.platformApi|{}platformApi[0]
abstract fun <get-platformApi>(): kotlinx.rpc.grpc/ManagedChannelPlatform // kotlinx.rpc.grpc/ManagedChannel.platformApi.<get-platformApi>|<get-platformApi>(){}[0]

abstract fun shutdown(): kotlinx.rpc.grpc/ManagedChannel // kotlinx.rpc.grpc/ManagedChannel.shutdown|shutdown(){}[0]
abstract fun shutdownNow(): kotlinx.rpc.grpc/ManagedChannel // kotlinx.rpc.grpc/ManagedChannel.shutdownNow|shutdownNow(){}[0]
abstract suspend fun awaitTermination(kotlin.time/Duration): kotlin/Boolean // kotlinx.rpc.grpc/ManagedChannel.awaitTermination|awaitTermination(kotlin.time.Duration){}[0]
}

abstract interface kotlinx.rpc.grpc/Server { // kotlinx.rpc.grpc/Server|null[0]
abstract val isShutdown // kotlinx.rpc.grpc/Server.isShutdown|{}isShutdown[0]
abstract fun <get-isShutdown>(): kotlin/Boolean // kotlinx.rpc.grpc/Server.isShutdown.<get-isShutdown>|<get-isShutdown>(){}[0]
abstract val isTerminated // kotlinx.rpc.grpc/Server.isTerminated|{}isTerminated[0]
abstract fun <get-isTerminated>(): kotlin/Boolean // kotlinx.rpc.grpc/Server.isTerminated.<get-isTerminated>|<get-isTerminated>(){}[0]
abstract val port // kotlinx.rpc.grpc/Server.port|{}port[0]
abstract fun <get-port>(): kotlin/Int // kotlinx.rpc.grpc/Server.port.<get-port>|<get-port>(){}[0]

abstract fun shutdown(): kotlinx.rpc.grpc/Server // kotlinx.rpc.grpc/Server.shutdown|shutdown(){}[0]
abstract fun shutdownNow(): kotlinx.rpc.grpc/Server // kotlinx.rpc.grpc/Server.shutdownNow|shutdownNow(){}[0]
abstract fun start(): kotlinx.rpc.grpc/Server // kotlinx.rpc.grpc/Server.start|start(){}[0]
abstract suspend fun awaitTermination(kotlin.time/Duration = ...): kotlinx.rpc.grpc/Server // kotlinx.rpc.grpc/Server.awaitTermination|awaitTermination(kotlin.time.Duration){}[0]
}

abstract interface kotlinx.rpc.grpc/Status { // kotlinx.rpc.grpc/Status|null[0]
abstract val cause // kotlinx.rpc.grpc/Status.cause|{}cause[0]
abstract fun <get-cause>(): kotlin/Throwable? // kotlinx.rpc.grpc/Status.cause.<get-cause>|<get-cause>(){}[0]
abstract val code // kotlinx.rpc.grpc/Status.code|{}code[0]
abstract fun <get-code>(): kotlinx.rpc.grpc/Status.Code // kotlinx.rpc.grpc/Status.code.<get-code>|<get-code>(){}[0]
abstract val description // kotlinx.rpc.grpc/Status.description|{}description[0]
abstract fun <get-description>(): kotlin/String? // kotlinx.rpc.grpc/Status.description.<get-description>|<get-description>(){}[0]

final enum class Code : kotlin/Enum<kotlinx.rpc.grpc/Status.Code> { // kotlinx.rpc.grpc/Status.Code|null[0]
enum entry ABORTED // kotlinx.rpc.grpc/Status.Code.ABORTED|null[0]
enum entry ALREADY_EXISTS // kotlinx.rpc.grpc/Status.Code.ALREADY_EXISTS|null[0]
enum entry CANCELLED // kotlinx.rpc.grpc/Status.Code.CANCELLED|null[0]
enum entry DATA_LOSS // kotlinx.rpc.grpc/Status.Code.DATA_LOSS|null[0]
enum entry DEADLINE_EXCEEDED // kotlinx.rpc.grpc/Status.Code.DEADLINE_EXCEEDED|null[0]
enum entry FAILED_PRECONDITION // kotlinx.rpc.grpc/Status.Code.FAILED_PRECONDITION|null[0]
enum entry INTERNAL // kotlinx.rpc.grpc/Status.Code.INTERNAL|null[0]
enum entry INVALID_ARGUMENT // kotlinx.rpc.grpc/Status.Code.INVALID_ARGUMENT|null[0]
enum entry NOT_FOUND // kotlinx.rpc.grpc/Status.Code.NOT_FOUND|null[0]
enum entry OK // kotlinx.rpc.grpc/Status.Code.OK|null[0]
enum entry OUT_OF_RANGE // kotlinx.rpc.grpc/Status.Code.OUT_OF_RANGE|null[0]
enum entry PERMISSION_DENIED // kotlinx.rpc.grpc/Status.Code.PERMISSION_DENIED|null[0]
enum entry RESOURCE_EXHAUSTED // kotlinx.rpc.grpc/Status.Code.RESOURCE_EXHAUSTED|null[0]
enum entry UNAUTHENTICATED // kotlinx.rpc.grpc/Status.Code.UNAUTHENTICATED|null[0]
enum entry UNAVAILABLE // kotlinx.rpc.grpc/Status.Code.UNAVAILABLE|null[0]
enum entry UNIMPLEMENTED // kotlinx.rpc.grpc/Status.Code.UNIMPLEMENTED|null[0]
enum entry UNKNOWN // kotlinx.rpc.grpc/Status.Code.UNKNOWN|null[0]

final val entries // kotlinx.rpc.grpc/Status.Code.entries|#static{}entries[0]
final fun <get-entries>(): kotlin.enums/EnumEntries<kotlinx.rpc.grpc/Status.Code> // kotlinx.rpc.grpc/Status.Code.entries.<get-entries>|<get-entries>#static(){}[0]
final val value // kotlinx.rpc.grpc/Status.Code.value|{}value[0]
final fun <get-value>(): kotlin/Int // kotlinx.rpc.grpc/Status.Code.value.<get-value>|<get-value>(){}[0]
final val valueAscii // kotlinx.rpc.grpc/Status.Code.valueAscii|{}valueAscii[0]
final fun <get-valueAscii>(): kotlin/ByteArray // kotlinx.rpc.grpc/Status.Code.valueAscii.<get-valueAscii>|<get-valueAscii>(){}[0]

final fun valueOf(kotlin/String): kotlinx.rpc.grpc/Status.Code // kotlinx.rpc.grpc/Status.Code.valueOf|valueOf#static(kotlin.String){}[0]
final fun values(): kotlin/Array<kotlinx.rpc.grpc/Status.Code> // kotlinx.rpc.grpc/Status.Code.values|values#static(){}[0]
}
}

abstract interface kotlinx.rpc.grpc/StatusRuntimeException { // kotlinx.rpc.grpc/StatusRuntimeException|null[0]
abstract val status // kotlinx.rpc.grpc/StatusRuntimeException.status|{}status[0]
abstract fun <get-status>(): kotlinx.rpc.grpc/Status // kotlinx.rpc.grpc/StatusRuntimeException.status.<get-status>|<get-status>(){}[0]
}

abstract class <#A: kotlinx.rpc.grpc/ManagedChannelBuilder<#A>> kotlinx.rpc.grpc/ManagedChannelBuilder { // kotlinx.rpc.grpc/ManagedChannelBuilder|null[0]
constructor <init>() // kotlinx.rpc.grpc/ManagedChannelBuilder.<init>|<init>(){}[0]
}

abstract class <#A: kotlinx.rpc.grpc/ServerBuilder<#A>> kotlinx.rpc.grpc/ServerBuilder { // kotlinx.rpc.grpc/ServerBuilder|null[0]
constructor <init>() // kotlinx.rpc.grpc/ServerBuilder.<init>|<init>(){}[0]

abstract fun addService(kotlinx.rpc.grpc/ServerServiceDefinition): #A // kotlinx.rpc.grpc/ServerBuilder.addService|addService(kotlinx.rpc.grpc.ServerServiceDefinition){}[0]
abstract fun fallbackHandlerRegistry(kotlinx.rpc.grpc/HandlerRegistry?): #A // kotlinx.rpc.grpc/ServerBuilder.fallbackHandlerRegistry|fallbackHandlerRegistry(kotlinx.rpc.grpc.HandlerRegistry?){}[0]
}

abstract class kotlinx.rpc.grpc/HandlerRegistry { // kotlinx.rpc.grpc/HandlerRegistry|null[0]
constructor <init>() // kotlinx.rpc.grpc/HandlerRegistry.<init>|<init>(){}[0]
}

abstract class kotlinx.rpc.grpc/ManagedChannelPlatform { // kotlinx.rpc.grpc/ManagedChannelPlatform|null[0]
constructor <init>() // kotlinx.rpc.grpc/ManagedChannelPlatform.<init>|<init>(){}[0]
}

final class kotlinx.rpc.grpc/GrpcClient : kotlinx.rpc/RpcClient { // kotlinx.rpc.grpc/GrpcClient|null[0]
final fun <#A1: kotlin/Any?> callServerStreaming(kotlinx.rpc/RpcCall): kotlinx.coroutines.flow/Flow<#A1> // kotlinx.rpc.grpc/GrpcClient.callServerStreaming|callServerStreaming(kotlinx.rpc.RpcCall){0§<kotlin.Any?>}[0]
final fun shutdown() // kotlinx.rpc.grpc/GrpcClient.shutdown|shutdown(){}[0]
final fun shutdownNow() // kotlinx.rpc.grpc/GrpcClient.shutdownNow|shutdownNow(){}[0]
final suspend fun <#A1: kotlin/Any?> call(kotlinx.rpc/RpcCall): #A1 // kotlinx.rpc.grpc/GrpcClient.call|call(kotlinx.rpc.RpcCall){0§<kotlin.Any?>}[0]
final suspend fun awaitTermination(kotlin.time/Duration) // kotlinx.rpc.grpc/GrpcClient.awaitTermination|awaitTermination(kotlin.time.Duration){}[0]
}

final class kotlinx.rpc.grpc/GrpcServer : kotlinx.rpc.grpc/Server, kotlinx.rpc/RpcServer { // kotlinx.rpc.grpc/GrpcServer|null[0]
final val isShutdown // kotlinx.rpc.grpc/GrpcServer.isShutdown|{}isShutdown[0]
final fun <get-isShutdown>(): kotlin/Boolean // kotlinx.rpc.grpc/GrpcServer.isShutdown.<get-isShutdown>|<get-isShutdown>(){}[0]
final val isTerminated // kotlinx.rpc.grpc/GrpcServer.isTerminated|{}isTerminated[0]
final fun <get-isTerminated>(): kotlin/Boolean // kotlinx.rpc.grpc/GrpcServer.isTerminated.<get-isTerminated>|<get-isTerminated>(){}[0]
final val port // kotlinx.rpc.grpc/GrpcServer.port|{}port[0]
final fun <get-port>(): kotlin/Int // kotlinx.rpc.grpc/GrpcServer.port.<get-port>|<get-port>(){}[0]

final fun <#A1: kotlin/Any> deregisterService(kotlin.reflect/KClass<#A1>) // kotlinx.rpc.grpc/GrpcServer.deregisterService|deregisterService(kotlin.reflect.KClass<0:0>){0§<kotlin.Any>}[0]
final fun <#A1: kotlin/Any> registerService(kotlin.reflect/KClass<#A1>, kotlin/Function0<#A1>) // kotlinx.rpc.grpc/GrpcServer.registerService|registerService(kotlin.reflect.KClass<0:0>;kotlin.Function0<0:0>){0§<kotlin.Any>}[0]
final fun shutdown(): kotlinx.rpc.grpc/GrpcServer // kotlinx.rpc.grpc/GrpcServer.shutdown|shutdown(){}[0]
final fun shutdownNow(): kotlinx.rpc.grpc/GrpcServer // kotlinx.rpc.grpc/GrpcServer.shutdownNow|shutdownNow(){}[0]
final fun start(): kotlinx.rpc.grpc/GrpcServer // kotlinx.rpc.grpc/GrpcServer.start|start(){}[0]
final suspend fun awaitTermination(kotlin.time/Duration): kotlinx.rpc.grpc/GrpcServer // kotlinx.rpc.grpc/GrpcServer.awaitTermination|awaitTermination(kotlin.time.Duration){}[0]
}

final class kotlinx.rpc.grpc/ServerServiceDefinition { // kotlinx.rpc.grpc/ServerServiceDefinition|null[0]
constructor <init>() // kotlinx.rpc.grpc/ServerServiceDefinition.<init>|<init>(){}[0]
}

final fun kotlinx.rpc.grpc/GrpcClient(kotlin/String, kotlin/Function1<kotlinx.rpc.grpc/ManagedChannelBuilder<*>, kotlin/Unit> = ...): kotlinx.rpc.grpc/GrpcClient // kotlinx.rpc.grpc/GrpcClient|GrpcClient(kotlin.String;kotlin.Function1<kotlinx.rpc.grpc.ManagedChannelBuilder<*>,kotlin.Unit>){}[0]
final fun kotlinx.rpc.grpc/GrpcClient(kotlin/String, kotlin/Int, kotlin/Function1<kotlinx.rpc.grpc/ManagedChannelBuilder<*>, kotlin/Unit> = ...): kotlinx.rpc.grpc/GrpcClient // kotlinx.rpc.grpc/GrpcClient|GrpcClient(kotlin.String;kotlin.Int;kotlin.Function1<kotlinx.rpc.grpc.ManagedChannelBuilder<*>,kotlin.Unit>){}[0]
final fun kotlinx.rpc.grpc/GrpcServer(kotlin/Int, kotlin/Function1<kotlinx.rpc.grpc/ServerBuilder<*>, kotlin/Unit> = ..., kotlin/Function1<kotlinx.rpc/RpcServer, kotlin/Unit> = ...): kotlinx.rpc.grpc/GrpcServer // kotlinx.rpc.grpc/GrpcServer|GrpcServer(kotlin.Int;kotlin.Function1<kotlinx.rpc.grpc.ServerBuilder<*>,kotlin.Unit>;kotlin.Function1<kotlinx.rpc.RpcServer,kotlin.Unit>){}[0]
final fun kotlinx.rpc.grpc/StatusRuntimeException(kotlinx.rpc.grpc/Status): kotlinx.rpc.grpc/StatusRuntimeException // kotlinx.rpc.grpc/StatusRuntimeException|StatusRuntimeException(kotlinx.rpc.grpc.Status){}[0]
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.rpc.RpcClient
import kotlinx.rpc.grpc.descriptor.GrpcClientDelegate
import kotlinx.rpc.grpc.descriptor.GrpcServiceDescriptor
import kotlinx.rpc.internal.utils.map.RpcInternalConcurrentHashMap
import kotlin.time.Duration

/**
* GrpcClient manages gRPC communication by providing implementation for making asynchronous RPC calls.
Expand All @@ -19,6 +20,20 @@ import kotlinx.rpc.internal.utils.map.RpcInternalConcurrentHashMap
public class GrpcClient internal constructor(private val channel: ManagedChannel) : RpcClient {
private val stubs = RpcInternalConcurrentHashMap<Long, GrpcClientDelegate>()

public fun shutdown() {
stubs.clear()
channel.shutdown()
}

public fun shutdownNow() {
stubs.clear()
channel.shutdownNow()
}

public suspend fun awaitTermination(duration: Duration) {
channel.awaitTermination(duration)
}

override suspend fun <T> call(call: RpcCall): T {
return call.delegate().call(call)
}
Expand All @@ -39,11 +54,11 @@ public class GrpcClient internal constructor(private val channel: ManagedChannel
* Constructor function for the [GrpcClient] class.
*/
public fun GrpcClient(
name: String,
hostname: String,
port: Int,
configure: ManagedChannelBuilder<*>.() -> Unit = {},
): GrpcClient {
val channel = ManagedChannelBuilder(name, port).apply(configure).buildChannel()
val channel = ManagedChannelBuilder(hostname, port).apply(configure).buildChannel()
return GrpcClient(channel)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package kotlinx.rpc.grpc

import kotlinx.atomicfu.atomic
import kotlinx.rpc.RpcServer
import kotlinx.rpc.descriptor.serviceDescriptorOf
import kotlinx.rpc.grpc.annotations.Grpc
Expand Down Expand Up @@ -65,9 +66,13 @@ public class GrpcServer internal constructor(
return grpc.delegate.definitionFor(service)
}

private val buildLock = atomic(false)

internal fun build() {
internalServer = Server(serverBuilder)
isBuilt = true
if (buildLock.compareAndSet(expect = false, update = true)) {
internalServer = Server(serverBuilder)
isBuilt = true
}
}

override val isShutdown: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface ManagedChannel {
*/
public expect abstract class ManagedChannelBuilder<T : ManagedChannelBuilder<T>>

internal expect fun ManagedChannelBuilder(name: String, port: Int): ManagedChannelBuilder<*>
internal expect fun ManagedChannelBuilder(hostname: String, port: Int): ManagedChannelBuilder<*>
internal expect fun ManagedChannelBuilder(target: String): ManagedChannelBuilder<*>

internal expect fun ManagedChannelBuilder<*>.buildChannel(): ManagedChannel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal actual fun ManagedChannelBuilder<*>.buildChannel(): ManagedChannel {
error("JS target is not supported in gRPC")
}

internal actual fun ManagedChannelBuilder(name: String, port: Int): ManagedChannelBuilder<*> {
internal actual fun ManagedChannelBuilder(hostname: String, port: Int): ManagedChannelBuilder<*> {
error("JS target is not supported in gRPC")
}

Expand Down
Loading