Class StateCheckingResponseObserver<V>

java.lang.Object
com.google.api.gax.rpc.StateCheckingResponseObserver<V>
All Implemented Interfaces:
ResponseObserver<V>

public abstract class StateCheckingResponseObserver<V> extends Object implements ResponseObserver<V>
Base implementation of ResponseObserver that performs state sanity checks.
  • Constructor Details

    • StateCheckingResponseObserver

      public StateCheckingResponseObserver()
  • Method Details

    • onStart

      public final void onStart(StreamController controller)
      Called before the stream is started. This must be invoked synchronously on the same thread that called ServerStreamingCallable.call(Object, ResponseObserver, ApiCallContext)

      Allows for disabling flow control and early stream termination via StreamController.

      This implementation simply delegates to onStartImpl(StreamController) after ensuring consistent state.

      Specified by:
      onStart in interface ResponseObserver<V>
      Parameters:
      controller - The controller for the stream.
    • onResponse

      public final void onResponse(V response)
      Receives a value from the stream.

      Can be called many times but is never called after ResponseObserver.onError(Throwable) or ResponseObserver.onComplete() are called.

      Clients may may receive 0 or more onResponse callbacks.

      If an exception is thrown by an implementation the caller will terminate the stream by calling ResponseObserver.onError(Throwable) with the caught exception as the cause.

      This implementation simply delegates to onResponseImpl(Object) after ensuring consistent state.

      Specified by:
      onResponse in interface ResponseObserver<V>
      Parameters:
      response - the value passed to the stream
    • onComplete

      public final void onComplete()
      Receives a notification of successful stream completion.

      May only be called once, and if called, it must be the last method called. In particular, if an exception is thrown by an implementation of onComplete, no further calls to any method are allowed.

      This implementation simply delegates to onCompleteImpl() after ensuring consistent state.

      Specified by:
      onComplete in interface ResponseObserver<V>
    • onError

      public final void onError(Throwable t)
      Receives a terminating error from the stream.

      May only be called once, and if called, it must be the last method called. In particular, if an exception is thrown by an implementation of onError, no further calls to any method are allowed.

      This implementation simply delegates to onErrorImpl(Throwable) after ensuring consistent state.

      Specified by:
      onError in interface ResponseObserver<V>
      Parameters:
      t - the error occurred on the stream
    • onStartImpl

      protected abstract void onStartImpl(StreamController controller)
      See Also:
    • onResponseImpl

      protected abstract void onResponseImpl(V response)
      See Also:
    • onErrorImpl

      protected abstract void onErrorImpl(Throwable t)
      See Also:
    • onCompleteImpl

      protected abstract void onCompleteImpl()
      See Also: