GrpcCall

interface GrpcCall<S : Any, R : Any>

A single call to a remote server. This call sends a single request value and receives a single response value. A gRPC call cannot be executed twice.

gRPC calls can be suspending, blocking, or asynchronous. Use whichever mechanism works at your call site: the bytes transmitted on the network are the same.

Types

Link copied to clipboard
interface Callback<S : Any, R : Any>

Properties

Link copied to clipboard
abstract val method: GrpcMethod<S, R>

The method invoked by this call.

Link copied to clipboard

A map containing request metadata. This is initially empty; it can be assigned to any other map of metadata before the call is executed. It is an error to set this value after the call is executed.

Link copied to clipboard

A map containing response metadata. This is null until the call has executed, at which point it will be non-null if the call completed successfully. It may also be non-null in failure cases if the failure was not a problem of connectivity. For example, if the gRPC call fails with an HTTP 503 error, response metadata will be present.

Link copied to clipboard
abstract val timeout: Timeout

Configures how long the call can take to complete before it is automatically canceled.

Functions

Link copied to clipboard
abstract fun cancel()

Attempts to cancel the call. This function is safe to call concurrently with execution. When canceled, execution fails with an immediate IOException rather than waiting to complete normally.

Link copied to clipboard
abstract fun clone(): GrpcCall<S, R>

Create a new, identical gRPC call to this one which can be enqueued or executed even if this call has already been.

Link copied to clipboard
abstract fun enqueue(request: S, callback: GrpcCall.Callback<S, R>)

Enqueues this call for asynchronous execution. The callback will be invoked on the client's dispatcher thread when the call completes.

Link copied to clipboard
abstract suspend fun execute(request: S): R

Invokes the call immediately and suspends until its response is received.

Link copied to clipboard
abstract fun executeBlocking(request: S): R

Invokes the call immediately and blocks until its response is received.

Link copied to clipboard
abstract fun isCanceled(): Boolean

True if cancel was called.

Link copied to clipboard
abstract fun isExecuted(): Boolean

Returns true if execute, executeBlocking, or enqueue was called. It is an error to execute or enqueue a call more than once.