unaryServerMethodDefinition

fun <RequestT, ResponseT> unaryServerMethodDefinition(context: CoroutineContext, descriptor: MethodDescriptor<RequestT, ResponseT>, implementation: suspend (RequestT) -> ResponseT): ServerMethodDefinition<RequestT, ResponseT>

Creates a ServerMethodDefinition that implements the specified unary RPC method by running the specified implementation and associated implementation details within a per-RPC CoroutineScope generated with the specified CoroutineContext.

When the RPC is received, this method definition will pass the request from the client to implementation, and send the response back to the client when it is returned.

If implementation fails with a StatusException, the RPC will fail with the corresponding Status. If implementation fails with a CancellationException, the RPC will fail with Status.CANCELLED. If implementation fails for any other reason, the RPC will fail with Status.UNKNOWN with the exception as a cause. If a cancellation is received from the client before implementation is complete, the coroutine will be cancelled and the RPC will fail with Status.CANCELLED.

Parameters

context

The context of the scopes the RPC implementation will run in

descriptor

The descriptor of the method being implemented

implementation

The implementation of the RPC method

Sources

jvm source
Link copied to clipboard