GrpcServer

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

How to configure

Server for listening for and dispatching incoming calls. It is not expected to be implemented by application code or interceptors.

Properties

Link copied to clipboard
abstract val isShutdown: Boolean

Returns whether the server is shutdown. Shutdown servers reject any new calls but may still have some calls being processed.

Link copied to clipboard
abstract val isTerminated: Boolean

Returns whether the server is terminated. Terminated servers have no running calls and relevant resources released (like TCP connections).

Link copied to clipboard
abstract val port: Int

Returns the port number the server is listening on. This can return -1 if there is no actual port or the result otherwise doesn't make sense. The result is undefined after the server is terminated. If there are multiple possible ports, this will return one arbitrarily. Implementations are encouraged to return the same port on each call.

Functions

Link copied to clipboard
abstract suspend fun awaitTermination(duration: Duration = Duration.INFINITE): GrpcServer

Waits for the server to become terminated, giving up if the timeout is reached.

Link copied to clipboard
abstract fun <Service : Any> deregisterService(serviceKClass: KClass<Service>)
Link copied to clipboard
abstract fun <Service : Any> registerService(serviceKClass: KClass<Service>, serviceFactory: () -> Service)
Link copied to clipboard
abstract fun shutdown(): GrpcServer

Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected. After this call returns, this server has released the listening socket(s) and may be reused by another server.

Link copied to clipboard
abstract fun shutdownNow(): GrpcServer

Initiates a forceful shutdown in which preexisting and new calls are rejected. Although forceful, the shutdown process is still not instantaneous; isTerminated will likely return false immediately after this method returns. After this call returns, this server has released the listening socket(s) and may be reused by another server.

Link copied to clipboard
abstract fun start(): GrpcServer

Bind and start the server. After this call returns, clients may begin connecting to the listening socket(s).