• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 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.internal;
18 
19 import io.grpc.Metadata;
20 import io.grpc.Status;
21 
22 /** An observer of client-side stream events. */
23 public interface ClientStreamListener extends StreamListener {
24   /**
25    * Called upon receiving all header information from the remote end-point. Note that transports
26    * are not required to call this method if no header information is received, this would occur
27    * when a stream immediately terminates with an error and only
28    * {@link #closed(io.grpc.Status, RpcProgress, Metadata)} is called.
29    *
30    * <p>This method should return quickly, as the same thread may be used to process other streams.
31    *
32    * @param headers the fully buffered received headers.
33    */
headersRead(Metadata headers)34   void headersRead(Metadata headers);
35 
36   /**
37    * Called when the stream is fully closed. {@link
38    * io.grpc.Status.Code#OK} is the only status code that is guaranteed
39    * to have been sent from the remote server. Any other status code may have been caused by
40    * abnormal stream termination. This is guaranteed to always be the final call on a listener. No
41    * further callbacks will be issued.
42    *
43    * <p>This method should return quickly, as the same thread may be used to process other streams.
44    *
45    * @param status details about the remote closure
46    * @param rpcProgress RPC progress when client stream listener is closed
47    * @param trailers trailing metadata
48    */
closed(Status status, RpcProgress rpcProgress, Metadata trailers)49   void closed(Status status, RpcProgress rpcProgress, Metadata trailers);
50 
51   /**
52    * The progress of the RPC when client stream listener is closed.
53    */
54   enum RpcProgress {
55     /**
56      * The RPC is processed by the server normally.
57      */
58     PROCESSED,
59     /**
60      * The stream on the wire is created but not processed by the server's application logic.
61      */
62     REFUSED,
63     /**
64      * The RPC is dropped (by load balancer).
65      */
66     DROPPED,
67     /**
68      * The stream is closed even before anything leaves the client.
69      */
70     MISCARRIED
71   }
72 }
73