ClientCalls

object ClientCalls

Helpers for gRPC clients implemented in Kotlin. Can be used directly, but intended to be used from generated Kotlin APIs.

Functions

Link copied to clipboard
fun <RequestT, ResponseT> bidiStreamingRpc(    channel: Channel,     method: MethodDescriptor<RequestT, ResponseT>,     requests: Flow<RequestT>,     callOptions: CallOptions = CallOptions.DEFAULT,     headers: Metadata = GrpcMetadata()): Flow<ResponseT>

Returns a Flow which launches the specified bidirectional-streaming RPC, collecting the requests flow, sending them to the server, and emitting the responses.

Link copied to clipboard
fun <RequestT, ResponseT> bidiStreamingRpcFunction(    channel: Channel,     method: MethodDescriptor<RequestT, ResponseT>,     callOptions: CallOptions = CallOptions.DEFAULT,     headers: suspend () -> Metadata = { GrpcMetadata() }): (Flow<RequestT>) -> Flow<ResponseT>

Returns a function object representing a bidirectional streaming RPC.

Link copied to clipboard
suspend fun <RequestT, ResponseT> clientStreamingRpc(    channel: Channel,     method: MethodDescriptor<RequestT, ResponseT>,     requests: Flow<RequestT>,     callOptions: CallOptions = CallOptions.DEFAULT,     headers: Metadata = GrpcMetadata()): ResponseT

Launches a client-streaming RPC on the specified channel, suspending until the server returns the result. The caller is expected to provide a Flow of requests.

Link copied to clipboard
fun <RequestT, ResponseT> clientStreamingRpcFunction(    channel: Channel,     method: MethodDescriptor<RequestT, ResponseT>,     callOptions: CallOptions = CallOptions.DEFAULT,     headers: suspend () -> Metadata = { GrpcMetadata() }): suspend (Flow<RequestT>) -> ResponseT

Returns a function object representing a client streaming RPC.

Link copied to clipboard
fun <RequestT, ResponseT> serverStreamingRpc(    channel: Channel,     method: MethodDescriptor<RequestT, ResponseT>,     request: RequestT,     callOptions: CallOptions = CallOptions.DEFAULT,     headers: Metadata = GrpcMetadata()): Flow<ResponseT>

Returns a Flow which launches the specified server-streaming RPC and emits the responses.

Link copied to clipboard
fun <RequestT, ResponseT> serverStreamingRpcFunction(    channel: Channel,     method: MethodDescriptor<RequestT, ResponseT>,     callOptions: CallOptions = CallOptions.DEFAULT,     headers: suspend () -> Metadata = { GrpcMetadata() }): (RequestT) -> Flow<ResponseT>

Returns a function object representing a server streaming RPC.

Link copied to clipboard
suspend fun <RequestT, ResponseT> unaryRpc(    channel: Channel,     method: MethodDescriptor<RequestT, ResponseT>,     request: RequestT,     callOptions: CallOptions = CallOptions.DEFAULT,     headers: Metadata = GrpcMetadata()): ResponseT

Launches a unary RPC on the specified channel, suspending until the result is received.

Link copied to clipboard
fun <RequestT, ResponseT> unaryRpcFunction(    channel: Channel,     method: MethodDescriptor<RequestT, ResponseT>,     callOptions: CallOptions = CallOptions.DEFAULT,     headers: suspend () -> Metadata = { GrpcMetadata() }): suspend (RequestT) -> ResponseT

Returns a function object representing a unary RPC.

Sources

Link copied to clipboard