Class UnaryCallable<RequestT,ResponseT>

java.lang.Object
com.google.api.gax.rpc.UnaryCallable<RequestT,ResponseT>
Direct Known Subclasses:
BatchingCallable, PagedCallable, TracedBatchingCallable, TracedUnaryCallable, TranslatingUnaryCallable

public abstract class UnaryCallable<RequestT,ResponseT> extends Object
A UnaryCallable is an immutable object which is capable of making RPC calls to non-streaming API methods.

In typical usage, the request to send to the remote service will not be bound to the UnaryCallable, but instead is provided at call time, which allows for a UnaryCallable to be saved and used indefinitely.

There are two styles of calls that can be made through a UnaryCallable: synchronous and asynchronous.

Synchronous example:


 RequestType request = RequestType.newBuilder().build();
 UnaryCallable<RequestType, ResponseType> unaryCallable = api.doSomethingCallable();
 ResponseType response = unaryCallable.call();
 

Asynchronous example:


 RequestType request = RequestType.newBuilder().build();
 UnaryCallable<RequestType, ResponseType> unaryCallable = api.doSomethingCallable();
 ApiFuture<ResponseType> resultFuture = unaryCallable.futureCall();
 // do other work
 // ...
 ResponseType response = resultFuture.get();
 

It is considered advanced usage for a user to create a UnaryCallable themselves. This class is intended to be created by a generated client class, and configured by instances of UnaryCallSettings.Builder which are exposed through the client settings class.