2626import io .grpc .ServerCall ;
2727import io .grpc .ServerCallHandler ;
2828import io .grpc .Status ;
29- import io .grpc .StatusException ;
30- import io .grpc .StatusRuntimeException ;
3129
3230/**
3331 * Utility functions for adapting {@link ServerCallHandler}s to application service implementation,
@@ -47,14 +45,6 @@ private ServerCalls() {
4745 * Creates a {@link ServerCallHandler} for a unary call method of the service.
4846 *
4947 * @param method an adaptor to the actual method on the service implementation.
50- * <p>
51- * <h3>Server errors</h3>
52- * If the throwable sent to the server's outbound {@link StreamObserver}'s onError
53- * is a {@link StatusException} or {@link StatusRuntimeException}, that status code will be sent
54- * and UNKNOWN status code otherwise. Its description will be encoded to the stream trailer, but
55- * the cause (which may contain server application's information) will not. After the stream
56- * trailer with END_STREAM is sent, the server side call is considered to be closed.
57- * </p>
5848 */
5949 public static <ReqT , RespT > ServerCallHandler <ReqT , RespT > asyncUnaryCall (
6050 UnaryMethod <ReqT , RespT > method ) {
@@ -65,22 +55,6 @@ public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncUnaryCall(
6555 * Creates a {@link ServerCallHandler} for a server streaming method of the service.
6656 *
6757 * @param method an adaptor to the actual method on the service implementation.
68- * <p>
69- * <h3>Client errors</h3>
70- * The server's request stream observer will receive an
71- * onError callback with a {@link io.grpc.StatusRuntimeException} for the cancellation with the
72- * message 'Client cancelled', and exception cause set to null because the actual exception
73- * passed by the client to onError is never actually transmitted to the server and the server just
74- * receives a RST_STREAM frame indicating cancellation by the client.
75- * </p>
76- * <p>
77- * <h3>Server errors</h3>
78- * If the throwable sent to the server's outbound {@link StreamObserver}'s onError
79- * is a {@link StatusException} or {@link StatusRuntimeException}, that status code will be sent
80- * and UNKNOWN status code otherwise. Its description will be encoded to the stream trailer, but
81- * the cause (which may contain server application's information) will not. After the stream
82- * trailer with END_STREAM is sent, the server side call is considered to be closed.
83- * </p>
8458 */
8559 public static <ReqT , RespT > ServerCallHandler <ReqT , RespT > asyncServerStreamingCall (
8660 ServerStreamingMethod <ReqT , RespT > method ) {
@@ -91,22 +65,6 @@ public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncServerStreamingC
9165 * Creates a {@link ServerCallHandler} for a client streaming method of the service.
9266 *
9367 * @param method an adaptor to the actual method on the service implementation.
94- * <p>
95- * <h3>Client errors</h3>
96- * The server's request stream observer will receive an
97- * onError callback with a {@link io.grpc.StatusRuntimeException} for the cancellation with the
98- * message 'Client cancelled', and exception cause set to null because the actual exception
99- * passed by the client to onError is never actually transmitted to the server and the server just
100- * receives a RST_STREAM frame indicating cancellation by the client.
101- * </p>
102- * <p>
103- * <h3>Server errors</h3>
104- * If the throwable sent to the server's outbound {@link StreamObserver}'s onError
105- * is a {@link StatusException} or {@link StatusRuntimeException}, that status code will be sent
106- * and UNKNOWN status code otherwise. Its description will be encoded to the stream trailer, but
107- * the cause (which may contain server application's information) will not. After the stream
108- * trailer with END_STREAM is sent, the server side call is considered to be closed.
109- * </p>
11068 */
11169 public static <ReqT , RespT > ServerCallHandler <ReqT , RespT > asyncClientStreamingCall (
11270 ClientStreamingMethod <ReqT , RespT > method ) {
@@ -117,22 +75,6 @@ public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncClientStreamingC
11775 * Creates a {@link ServerCallHandler} for a bidi streaming method of the service.
11876 *
11977 * @param method an adaptor to the actual method on the service implementation.
120- * <p>
121- * <h3>Client errors</h3>
122- * The server's request stream observer will receive an
123- * onError callback with a {@link io.grpc.StatusRuntimeException} for the cancellation with the
124- * message 'Client cancelled', and exception cause set to null because the actual exception
125- * passed by the client to onError is never actually transmitted to the server and the server just
126- * receives a RST_STREAM frame indicating cancellation by the client.
127- * </p>
128- * <p>
129- * <h3>Server errors</h3>
130- * If the throwable sent to the server's outbound {@link StreamObserver}'s onError
131- * is a {@link StatusException} or {@link StatusRuntimeException}, that status code will be sent
132- * and UNKNOWN status code otherwise. Its description will be encoded to the stream trailer, but
133- * the cause (which may contain server application's information) will not. After the stream
134- * trailer with END_STREAM is sent, the server side call is considered to be closed.
135- * </p>
13678 */
13779 public static <ReqT , RespT > ServerCallHandler <ReqT , RespT > asyncBidiStreamingCall (
13880 BidiStreamingMethod <ReqT , RespT > method ) {
@@ -143,27 +85,91 @@ public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCal
14385 * Adaptor to a unary call method.
14486 */
14587 public interface UnaryMethod <ReqT , RespT > extends UnaryRequestMethod <ReqT , RespT > {
88+ /**
89+ * Invoke the method.
90+ *
91+ * @param request the request message from the client
92+ * @param responseObserver the observer to receive the single response. Calling {@code
93+ * responseObserver}'s {@link StreamObserver#onCompleted} or {@link
94+ * StreamObserver#onError} is the end of the RPC. {@code onCompleted()} will close the RPC
95+ * with status code OK. {@code onError()} will convert the Throwable to a Status with {@link
96+ * Status#fromThrowable} and trailers with {@link Status#trailersFromThrowable}. The {@link
97+ * Status#getCause} is not sent to the client, except if done by an interceptor. Callers
98+ * generally create a Throwable with {@link Status#asException()}, {@link
99+ * Status#asException(Metadata)}, {@link Status#asRuntimeException()}, or {@link
100+ * Status#asRuntimeException(Metadata)}.
101+ */
146102 @ Override void invoke (ReqT request , StreamObserver <RespT > responseObserver );
147103 }
148104
149105 /**
150106 * Adaptor to a server streaming method.
151107 */
152108 public interface ServerStreamingMethod <ReqT , RespT > extends UnaryRequestMethod <ReqT , RespT > {
109+ /**
110+ * Invoke the method.
111+ *
112+ * @param request the request message from the client
113+ * @param responseObserver the observer to receive the response stream. Calling {@code
114+ * responseObserver}'s {@link StreamObserver#onCompleted} or {@link
115+ * StreamObserver#onError} is the end of the RPC. {@code onCompleted()} will close the RPC
116+ * with status code OK. {@code onError()} will convert the Throwable to a Status with {@link
117+ * Status#fromThrowable} and trailers with {@link Status#trailersFromThrowable}. The {@link
118+ * Status#getCause} is not sent to the client, except if done by an interceptor. Callers
119+ * generally create a Throwable with {@link Status#asException()}, {@link
120+ * Status#asException(Metadata)}, {@link Status#asRuntimeException()}, or {@link
121+ * Status#asRuntimeException(Metadata)}.
122+ */
153123 @ Override void invoke (ReqT request , StreamObserver <RespT > responseObserver );
154124 }
155125
156126 /**
157127 * Adaptor to a client streaming method.
158128 */
159129 public interface ClientStreamingMethod <ReqT , RespT > extends StreamingRequestMethod <ReqT , RespT > {
130+ /**
131+ * Invoke the method.
132+ *
133+ * <h3>Client errors</h3>
134+ * The Throwable received by the server's request stream observer when converted to a status
135+ * with Status.fromThrowable(), always has the status code CANCELLED.
136+ *
137+ * @param responseObserver the observer to receive the single response. Calling {@code
138+ * responseObserver}'s {@link StreamObserver#onCompleted} or {@link
139+ * StreamObserver#onError} is the end of the RPC. {@code onCompleted()} will close the RPC
140+ * with status code OK. {@code onError()} will convert the Throwable to a Status with {@link
141+ * Status#fromThrowable} and trailers with {@link Status#trailersFromThrowable}. The {@link
142+ * Status#getCause} is not sent to the client, except if done by an interceptor. Callers
143+ * generally create a Throwable with {@link Status#asException()}, {@link
144+ * Status#asException(Metadata)}, {@link Status#asRuntimeException()}, or {@link
145+ * Status#asRuntimeException(Metadata)}.
146+ * @return a stream observer for receiving the request stream from the client
147+ */
160148 @ Override StreamObserver <ReqT > invoke (StreamObserver <RespT > responseObserver );
161149 }
162150
163151 /**
164152 * Adaptor to a bidirectional streaming method.
165153 */
166154 public interface BidiStreamingMethod <ReqT , RespT > extends StreamingRequestMethod <ReqT , RespT > {
155+ /**
156+ * Invoke the method.
157+ *
158+ * <h3>Client errors</h3>
159+ * The Throwable received by the server's request stream observer when converted to a status
160+ * with Status.fromThrowable(), always has the status code CANCELLED.
161+ *
162+ * @param responseObserver the observer to receive the response stream. Calling {@code
163+ * responseObserver}'s {@link StreamObserver#onCompleted} or {@link
164+ * StreamObserver#onError} is the end of the RPC. {@code onCompleted()} will close the RPC
165+ * with status code OK. {@code onError()} will convert the Throwable to a Status with {@link
166+ * Status#fromThrowable} and trailers with {@link Status#trailersFromThrowable}. The {@link
167+ * Status#getCause} is not sent to the client, except if done by an interceptor. Callers
168+ * generally create a Throwable with {@link Status#asException()}, {@link
169+ * Status#asException(Metadata)}, {@link Status#asRuntimeException()}, or {@link
170+ * Status#asRuntimeException(Metadata)}.
171+ * @return a stream observer for receiving the request stream from the client
172+ */
167173 @ Override StreamObserver <ReqT > invoke (StreamObserver <RespT > responseObserver );
168174 }
169175
0 commit comments