stub: Document blocking exceptions and async extension types

invoke() needed to be re-defined for Javadoc to display the method.
This commit is contained in:
Eric Anderson 2020-06-10 12:21:46 -07:00 committed by Eric Anderson
parent 37107d297b
commit c3ea8e7c91
2 changed files with 38 additions and 6 deletions

View File

@ -59,6 +59,9 @@ public final class ClientCalls {
/** /**
* Executes a unary call with a response {@link StreamObserver}. The {@code call} should not be * Executes a unary call with a response {@link StreamObserver}. The {@code call} should not be
* already started. After calling this method, {@code call} should no longer be used. * already started. After calling this method, {@code call} should no longer be used.
*
* <p>If the provided {@code responseObserver} is an instance of {@link ClientResponseObserver},
* {@code beforeStart()} will be called.
*/ */
public static <ReqT, RespT> void asyncUnaryCall( public static <ReqT, RespT> void asyncUnaryCall(
ClientCall<ReqT, RespT> call, ReqT req, StreamObserver<RespT> responseObserver) { ClientCall<ReqT, RespT> call, ReqT req, StreamObserver<RespT> responseObserver) {
@ -69,6 +72,9 @@ public final class ClientCalls {
* Executes a server-streaming call with a response {@link StreamObserver}. The {@code call} * Executes a server-streaming call with a response {@link StreamObserver}. The {@code call}
* should not be already started. After calling this method, {@code call} should no longer be * should not be already started. After calling this method, {@code call} should no longer be
* used. * used.
*
* <p>If the provided {@code responseObserver} is an instance of {@link ClientResponseObserver},
* {@code beforeStart()} will be called.
*/ */
public static <ReqT, RespT> void asyncServerStreamingCall( public static <ReqT, RespT> void asyncServerStreamingCall(
ClientCall<ReqT, RespT> call, ReqT req, StreamObserver<RespT> responseObserver) { ClientCall<ReqT, RespT> call, ReqT req, StreamObserver<RespT> responseObserver) {
@ -80,7 +86,10 @@ public final class ClientCalls {
* The {@code call} should not be already started. After calling this method, {@code call} * The {@code call} should not be already started. After calling this method, {@code call}
* should no longer be used. * should no longer be used.
* *
* @return request stream observer. * <p>If the provided {@code responseObserver} is an instance of {@link ClientResponseObserver},
* {@code beforeStart()} will be called.
*
* @return request stream observer. It will extend {@link ClientCallStreamObserver}
*/ */
public static <ReqT, RespT> StreamObserver<ReqT> asyncClientStreamingCall( public static <ReqT, RespT> StreamObserver<ReqT> asyncClientStreamingCall(
ClientCall<ReqT, RespT> call, ClientCall<ReqT, RespT> call,
@ -92,7 +101,10 @@ public final class ClientCalls {
* Executes a bidirectional-streaming call. The {@code call} should not be already started. * Executes a bidirectional-streaming call. The {@code call} should not be already started.
* After calling this method, {@code call} should no longer be used. * After calling this method, {@code call} should no longer be used.
* *
* @return request stream observer. * <p>If the provided {@code responseObserver} is an instance of {@link ClientResponseObserver},
* {@code beforeStart()} will be called.
*
* @return request stream observer. It will extend {@link ClientCallStreamObserver}
*/ */
public static <ReqT, RespT> StreamObserver<ReqT> asyncBidiStreamingCall( public static <ReqT, RespT> StreamObserver<ReqT> asyncBidiStreamingCall(
ClientCall<ReqT, RespT> call, StreamObserver<RespT> responseObserver) { ClientCall<ReqT, RespT> call, StreamObserver<RespT> responseObserver) {
@ -104,6 +116,7 @@ public final class ClientCalls {
* started. After calling this method, {@code call} should no longer be used. * started. After calling this method, {@code call} should no longer be used.
* *
* @return the single response message. * @return the single response message.
* @throws StatusRuntimeException on error
*/ */
public static <ReqT, RespT> RespT blockingUnaryCall(ClientCall<ReqT, RespT> call, ReqT req) { public static <ReqT, RespT> RespT blockingUnaryCall(ClientCall<ReqT, RespT> call, ReqT req) {
try { try {
@ -120,6 +133,7 @@ public final class ClientCalls {
* started. After calling this method, {@code call} should no longer be used. * started. After calling this method, {@code call} should no longer be used.
* *
* @return the single response message. * @return the single response message.
* @throws StatusRuntimeException on error
*/ */
public static <ReqT, RespT> RespT blockingUnaryCall( public static <ReqT, RespT> RespT blockingUnaryCall(
Channel channel, MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, ReqT req) { Channel channel, MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, ReqT req) {
@ -158,6 +172,8 @@ public final class ClientCalls {
* response stream. The {@code call} should not be already started. After calling this method, * response stream. The {@code call} should not be already started. After calling this method,
* {@code call} should no longer be used. * {@code call} should no longer be used.
* *
* <p>The returned iterator may throw {@link StatusRuntimeException} on error.
*
* @return an iterator over the response stream. * @return an iterator over the response stream.
*/ */
// TODO(louiscryan): Not clear if we want to use this idiom for 'simple' stubs. // TODO(louiscryan): Not clear if we want to use this idiom for 'simple' stubs.
@ -173,6 +189,8 @@ public final class ClientCalls {
* response stream. The {@code call} should not be already started. After calling this method, * response stream. The {@code call} should not be already started. After calling this method,
* {@code call} should no longer be used. * {@code call} should no longer be used.
* *
* <p>The returned iterator may throw {@link StatusRuntimeException} on error.
*
* @return an iterator over the response stream. * @return an iterator over the response stream.
*/ */
// TODO(louiscryan): Not clear if we want to use this idiom for 'simple' stubs. // TODO(louiscryan): Not clear if we want to use this idiom for 'simple' stubs.

View File

@ -84,22 +84,30 @@ public final class ServerCalls {
/** /**
* Adaptor to a unary call method. * Adaptor to a unary call method.
*/ */
public interface UnaryMethod<ReqT, RespT> extends UnaryRequestMethod<ReqT, RespT> {} public interface UnaryMethod<ReqT, RespT> extends UnaryRequestMethod<ReqT, RespT> {
@Override void invoke(ReqT request, StreamObserver<RespT> responseObserver);
}
/** /**
* Adaptor to a server streaming method. * Adaptor to a server streaming method.
*/ */
public interface ServerStreamingMethod<ReqT, RespT> extends UnaryRequestMethod<ReqT, RespT> {} public interface ServerStreamingMethod<ReqT, RespT> extends UnaryRequestMethod<ReqT, RespT> {
@Override void invoke(ReqT request, StreamObserver<RespT> responseObserver);
}
/** /**
* Adaptor to a client streaming method. * Adaptor to a client streaming method.
*/ */
public interface ClientStreamingMethod<ReqT, RespT> extends StreamingRequestMethod<ReqT, RespT> {} public interface ClientStreamingMethod<ReqT, RespT> extends StreamingRequestMethod<ReqT, RespT> {
@Override StreamObserver<ReqT> invoke(StreamObserver<RespT> responseObserver);
}
/** /**
* Adaptor to a bidirectional streaming method. * Adaptor to a bidirectional streaming method.
*/ */
public interface BidiStreamingMethod<ReqT, RespT> extends StreamingRequestMethod<ReqT, RespT> {} public interface BidiStreamingMethod<ReqT, RespT> extends StreamingRequestMethod<ReqT, RespT> {
@Override StreamObserver<ReqT> invoke(StreamObserver<RespT> responseObserver);
}
private static final class UnaryServerCallHandler<ReqT, RespT> private static final class UnaryServerCallHandler<ReqT, RespT>
implements ServerCallHandler<ReqT, RespT> { implements ServerCallHandler<ReqT, RespT> {
@ -296,10 +304,16 @@ public final class ServerCalls {
} }
private interface UnaryRequestMethod<ReqT, RespT> { private interface UnaryRequestMethod<ReqT, RespT> {
/**
* The provided {@code responseObserver} will extend {@link ServerCallStreamObserver}.
*/
void invoke(ReqT request, StreamObserver<RespT> responseObserver); void invoke(ReqT request, StreamObserver<RespT> responseObserver);
} }
private interface StreamingRequestMethod<ReqT, RespT> { private interface StreamingRequestMethod<ReqT, RespT> {
/**
* The provided {@code responseObserver} will extend {@link ServerCallStreamObserver}.
*/
StreamObserver<ReqT> invoke(StreamObserver<RespT> responseObserver); StreamObserver<ReqT> invoke(StreamObserver<RespT> responseObserver);
} }