GrpcServer

Available in a dev version: 0․11․0-grpc-186

How to configure

fun GrpcServer(port: Int, parentContext: CoroutineContext = EmptyCoroutineContext, configure: GrpcServerConfiguration.() -> Unit = {}): GrpcServer(source)

Creates and configures a gRPC server instance.

This function initializes a gRPC server with the provided port and a configuration block (GrpcServerConfiguration).

To start the server, call the GrpcServer.start method. To clean up resources, call the GrpcServer.shutdown or GrpcServer.shutdownNow methods.

GrpcServer(port) {
credentials = tls(myCertChain, myPrivateKey)
services {
registerService<MyService> { MyServiceImpl() }
registerService<MyOtherService> { MyOtherServiceImpl() }
}
}

Return

A fully configured GrpcServer instance, which must be started explicitly to handle requests.

Parameters

port

The port number where the gRPC server will listen for incoming connections. This must be a valid and available port on the host system.

parentContext

The parent coroutine context used for managing server-related operations. Defaults to an empty coroutine context if not specified.

configure

A configuration lambda receiver, allowing customization of server behavior such as credentials, interceptors, marshallers, and service registration logic.