Class ClientCalls.StreamObserverToCallListenerAdapter<ReqT,RespT>
- java.lang.Object
-
- io.grpc.ClientCall.Listener<T>
-
- io.grpc.stub.ClientCalls.StartableListener<RespT>
-
- io.grpc.stub.ClientCalls.StreamObserverToCallListenerAdapter<ReqT,RespT>
-
- Enclosing class:
- ClientCalls
private static final class ClientCalls.StreamObserverToCallListenerAdapter<ReqT,RespT> extends ClientCalls.StartableListener<RespT>
-
-
Field Summary
Fields Modifier and Type Field Description private ClientCalls.CallToStreamObserverAdapter<ReqT>
adapter
private boolean
firstResponseReceived
private StreamObserver<RespT>
observer
-
Constructor Summary
Constructors Constructor Description StreamObserverToCallListenerAdapter(StreamObserver<RespT> observer, ClientCalls.CallToStreamObserverAdapter<ReqT> adapter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onClose(Status status, Metadata trailers)
The ClientCall has been closed.void
onHeaders(Metadata headers)
The response headers have been received.void
onMessage(RespT message)
A response message has been received.void
onReady()
This indicates that the ClientCall may now be capable of sending additional messages (viaClientCall.sendMessage(ReqT)
) without requiring excessive buffering internally.(package private) void
onStart()
-
-
-
Field Detail
-
observer
private final StreamObserver<RespT> observer
-
adapter
private final ClientCalls.CallToStreamObserverAdapter<ReqT> adapter
-
firstResponseReceived
private boolean firstResponseReceived
-
-
Constructor Detail
-
StreamObserverToCallListenerAdapter
StreamObserverToCallListenerAdapter(StreamObserver<RespT> observer, ClientCalls.CallToStreamObserverAdapter<ReqT> adapter)
-
-
Method Detail
-
onHeaders
public void onHeaders(Metadata headers)
Description copied from class:ClientCall.Listener
The response headers have been received. Headers always precede messages.Since
Metadata
is not thread-safe, the caller must not access (read or write)headers
after this point.- Overrides:
onHeaders
in classClientCall.Listener<RespT>
- Parameters:
headers
- containing metadata sent by the server at the start of the response.
-
onMessage
public void onMessage(RespT message)
Description copied from class:ClientCall.Listener
A response message has been received. May be called zero or more times depending on whether the call response is empty, a single message or a stream of messages.- Overrides:
onMessage
in classClientCall.Listener<RespT>
- Parameters:
message
- returned by the server
-
onClose
public void onClose(Status status, Metadata trailers)
Description copied from class:ClientCall.Listener
The ClientCall has been closed. Any additional calls to theClientCall
will not be processed by the server. No further receiving will occur and no further notifications will be made.Since
Metadata
is not thread-safe, the caller must not access (read or write)trailers
after this point.If
status
returns false forStatus.isOk()
, then the call failed. An additional block of trailer metadata may be received at the end of the call from the server. An emptyMetadata
object is passed if no trailers are received.This method should not throw. If this method throws, there is no way to be notified of the exception. Implementations should therefore be careful of exceptions which can accidentally leak resources.
- Overrides:
onClose
in classClientCall.Listener<RespT>
- Parameters:
status
- the result of the remote call.trailers
- metadata provided at call completion.
-
onReady
public void onReady()
Description copied from class:ClientCall.Listener
This indicates that the ClientCall may now be capable of sending additional messages (viaClientCall.sendMessage(ReqT)
) without requiring excessive buffering internally. This event is just a suggestion and the application is free to ignore it, however doing so may result in excessive buffering within the ClientCall.Because there is a processing delay to deliver this notification, it is possible for concurrent writes to cause
isReady() == false
within this callback. Handle "spurious" notifications by checkingisReady()
's current value instead of assuming it is nowtrue
. IfisReady() == false
the normal expectations apply, so there would be anotheronReady()
callback.If the type of a call is either
MethodDescriptor.MethodType.UNARY
orMethodDescriptor.MethodType.SERVER_STREAMING
, this callback may not be fired. Calls that send exactly one message should not await this callback.- Overrides:
onReady
in classClientCall.Listener<RespT>
-
onStart
void onStart()
- Specified by:
onStart
in classClientCalls.StartableListener<RespT>
-
-