kotlinx.rpc 0.10.2 Help

Server

GrpcServer listens for incoming gRPC calls and dispatches them to registered service implementations.

val server = GrpcServer(8080) { services { registerService<ImageRecognizer> { ImageRecognizerImpl() } } } server.start() server.awaitTermination()

Multiple services can be registered in the same services block:

val server = GrpcServer(8080) { services { registerService<ImageRecognizer> { ImageRecognizerImpl() } registerService<EchoService> { EchoServiceImpl() } } }

Configuration

credentials

Sets server credentials. By default the server uses plaintext. Use tls(certificateChain, privateKey) { ... } for secure communication.

messageMarshallerResolver

A GrpcMarshallerResolver for custom serialization. Not needed when using generated Protobuf types. See No proto.

intercept(...)

Adds server-side interceptors for cross-cutting concerns like authentication, logging, or metrics.

fallbackHandlerRegistry

A custom GrpcHandlerRegistry for resolving services that were not registered via services { ... }. Unresolved services return UNIMPLEMENTED status by default.

Lifecycle

Call start() to begin listening for connections. Use shutdown() for an orderly shutdown (existing calls finish, new calls are rejected) or shutdownNow() to cancel everything immediately. awaitTermination() blocks until all calls have completed.

Last modified: 10 March 2026