• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc.stub;
18 
19 import io.grpc.ExperimentalApi;
20 
21 /**
22  * Specialization of {@link StreamObserver} implemented by clients in order to interact with the
23  * advanced features of a call such as flow-control.
24  */
25 @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4693")
26 public interface ClientResponseObserver<ReqT, RespT> extends StreamObserver<RespT> {
27   /**
28    * Called by the runtime priot to the start of a call to provide a reference to the
29    * {@link ClientCallStreamObserver} for the outbound stream. This can be used to listen to
30    * onReady events, disable auto inbound flow and perform other advanced functions.
31    *
32    * <p>Only the methods {@link ClientCallStreamObserver#setOnReadyHandler(Runnable)} and
33    * {@link ClientCallStreamObserver#disableAutoInboundFlowControl()} may be called within this
34    * callback
35    *
36    * <pre>
37    *   // Copy an iterator to the request stream under flow-control
38    *   someStub.fullDuplexCall(new ClientResponseObserver&lt;ReqT, RespT&gt;() {
39    *     public void beforeStart(final ClientCallStreamObserver&lt;Req&gt; requestStream) {
40    *       StreamObservers.copyWithFlowControl(someIterator, requestStream);
41    *   });
42    * </pre>
43    */
beforeStart(final ClientCallStreamObserver<ReqT> requestStream)44   void beforeStart(final ClientCallStreamObserver<ReqT> requestStream);
45 }
46