kotlinx.rpc 0.9.1 Help

Configuration

KrpcConfig is a class used to configure KrpcClient and KrpcServer (not to be confused with RpcClient and RpcServer).

It has two children: KrpcConfig.Client and KrpcConfig.Server. Client and Server may have shared properties as well as distinct ones. To create instances of these configurations, DSL builders are provided:

  • rpcClientConfig

  • rpcServerConfig

val config: KrpcConfig.Client = rpcClientConfig { // same for KrpcConfig.Server with rpcServerConfig waitForServices = true // default parameter }

The following configuration options are available:

serialization DSL

This parameter defines how serialization should work in RPC services and is present in both client and server configurations.

The serialization process is used to encode and decode data in RPC requests, so that the data can be transferred through the network.

Currently only StringFormat and BinaryFormat from kotlinx.serialization are supported, and by default you can choose from Json, Protobuf or Cbor formats:

rpcClientConfig { serialization { json { /* this: JsonBuilder from kotlinx.serialization */ } cbor { /* this: CborBuilder from kotlinx.serialization */ } protobuf { /* this: ProtobufBuilder from kotlinx.serialization */ } } }

Only last defined format will be used to serialize requests. If no format is specified, a runtime error will be thrown. You can also define a custom format.

waitForServices DSL

waitForServices parameter is available for both client and server. It specifies the behavior for an endpoint in situations when the message for a service is received, but the service is not present in KrpcClient or KrpcServer. If set to true, the message will be stored in memory, otherwise, the error will be sent to a peer endpoint, saying that the message was not handled. Default value is true.

Last modified: 13 June 2025