@BetaApi(value="The surface for streaming is not stable yet and may change in the future.") public abstract class ServerStreamingCallable<RequestT,ResponseT> extends Object
It is considered advanced usage for a user to create a ServerStreamingCallable themselves. This class is intended to be created by a generated client class, and configured by instances of StreamingCallSettings.Builder which are exposed through the client settings class.
| Modifier | Constructor and Description |
|---|---|
protected |
ServerStreamingCallable() |
| Modifier and Type | Method and Description |
|---|---|
UnaryCallable<RequestT,List<ResponseT>> |
all()
Construct a
UnaryCallable that will buffer the entire stream into memory before
completing. |
Iterator<ResponseT> |
blockingServerStreamingCall(RequestT request)
Deprecated.
Please use call() instead.
|
Iterator<ResponseT> |
blockingServerStreamingCall(RequestT request,
ApiCallContext context)
Deprecated.
Please use call() instead.
|
ServerStream<ResponseT> |
call(RequestT request)
Conduct a iteration server streaming call.
|
ServerStream<ResponseT> |
call(RequestT request,
ApiCallContext context)
Conduct a server streaming call with the given
ApiCallContext. |
void |
call(RequestT request,
ResponseObserver<ResponseT> responseObserver)
Conduct a server streaming call
|
abstract void |
call(RequestT request,
ResponseObserver<ResponseT> responseObserver,
ApiCallContext context)
Conduct a server streaming call with the given
ApiCallContext. |
UnaryCallable<RequestT,ResponseT> |
first()
Construct a
UnaryCallable that will yield the first item in the stream and cancel it. |
void |
serverStreamingCall(RequestT request,
ApiStreamObserver<ResponseT> responseObserver)
Deprecated.
Please use the
ResponseObserver variant instead. |
void |
serverStreamingCall(RequestT request,
ApiStreamObserver<ResponseT> responseObserver,
ApiCallContext context)
Deprecated.
Please use the
ResponseObserver variant instead. |
ServerStreamingCallable<RequestT,ResponseT> |
withDefaultCallContext(ApiCallContext defaultCallContext)
Returns a new
ServerStreamingCallable with an ApiCallContext that is used as a
default when none is supplied in individual calls. |
public UnaryCallable<RequestT,ResponseT> first()
UnaryCallable that will yield the first item in the stream and cancel it.
If the stream is empty, the item will be null.
Example usage:
StreamingCallable<String> streamingCallable = // ..
String theResult = streamingCallable.first().call(request);
ApiFuture<String> theResult = streamingCallable.first().futureCall(request);
UnaryCallable.public UnaryCallable<RequestT,List<ResponseT>> all()
UnaryCallable that will buffer the entire stream into memory before
completing. If the stream is empty, then the list will be empty.
Example usage:
StreamingCallable<String> streamingCallable = // ..
List<String> theResult = streamingCallable.all().call(request);
ApiFuture<List<String>> theResult = streamingCallable.all().futureCall(request);
UnaryCallable.public ServerStream<ResponseT> call(RequestT request)
This returns a live stream that must either be fully consumed or cancelled. Example usage:
StreamingCallable<String> streamingCallable = // ..
ServerStream stream = streamingCallable.call(request)
for (String s : stream) {
if ("needle".equals(s)) {
// Cancelling the stream will cause `hasNext()` to return false on the next iteration,
// naturally breaking the loop.
stream.cancel();
}
}
List<String> theResult = streamingCallable.all().call(request);
ApiFuture<List<String>> theResult = streamingCallable.all().futureCall(request);
request - requestServerStream which is used for iterating the responses.public ServerStream<ResponseT> call(RequestT request, ApiCallContext context)
ApiCallContext.
This returns a live stream that must either be fully consumed or cancelled.
request - requestcontext - the contextServerStream which is used for iterating the responses.public abstract void call(RequestT request, ResponseObserver<ResponseT> responseObserver, ApiCallContext context)
ApiCallContext.request - requestresponseObserver - ResponseObserver to observe the streaming responsescontext - ApiCallContext to provide context information for the RPC call.public void call(RequestT request, ResponseObserver<ResponseT> responseObserver)
request - requestresponseObserver - ResponseObserver to observe the streaming responses@Deprecated public void serverStreamingCall(RequestT request, ApiStreamObserver<ResponseT> responseObserver, ApiCallContext context)
ResponseObserver variant instead.ApiCallContext.request - requestresponseObserver - ApiStreamObserver to observe the streaming responsescontext - ApiCallContext to provide context information for the RPC call.@Deprecated public void serverStreamingCall(RequestT request, ApiStreamObserver<ResponseT> responseObserver)
ResponseObserver variant instead.request - requestresponseObserver - ApiStreamObserver to observe the streaming responses@Deprecated public Iterator<ResponseT> blockingServerStreamingCall(RequestT request, ApiCallContext context)
request - requestcontext - contextIterator which is used for iterating the responses.@Deprecated public Iterator<ResponseT> blockingServerStreamingCall(RequestT request)
request - requestIterator which is used for iterating the responses.public ServerStreamingCallable<RequestT,ResponseT> withDefaultCallContext(ApiCallContext defaultCallContext)
ServerStreamingCallable with an ApiCallContext that is used as a
default when none is supplied in individual calls.defaultCallContext - the default ApiCallContext.