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 /** 20 * Specialization of {@link StreamObserver} implemented by clients in order to interact with the 21 * advanced features of a call such as flow-control. 22 */ 23 public interface ClientResponseObserver<ReqT, RespT> extends StreamObserver<RespT> { 24 /** 25 * Called by the runtime prior to the start of a call to provide a reference to the 26 * {@link ClientCallStreamObserver} for the outbound stream. This can be used to listen to 27 * onReady events, disable auto inbound flow and perform other advanced functions. 28 * 29 * <p>Only the methods {@link ClientCallStreamObserver#setOnReadyHandler(Runnable)} and 30 * {@link ClientCallStreamObserver#disableAutoRequestWithInitial(int)} may be called within 31 * this callback 32 * 33 * <pre> 34 * // Copy an iterator to the request stream under flow-control 35 * someStub.fullDuplexCall(new ClientResponseObserver<ReqT, RespT>() { 36 * public void beforeStart(final ClientCallStreamObserver<Req> requestStream) { 37 * StreamObservers.copyWithFlowControl(someIterator, requestStream); 38 * }); 39 * </pre> 40 */ beforeStart(final ClientCallStreamObserver<ReqT> requestStream)41 void beforeStart(final ClientCallStreamObserver<ReqT> requestStream); 42 } 43