Xudong Ma | f7f57b7 | 2015-09-24 11:16:07 -0700 | [diff] [blame] | 1 | package io.grpc.testing.integration.nano; |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 2 | |
Kun Zhang | 2ee4d02 | 2015-06-04 16:39:25 -0700 | [diff] [blame] | 3 | import static io.grpc.stub.ClientCalls.asyncUnaryCall; |
| 4 | import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; |
| 5 | import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; |
Carl Mastrangelo | 67fc45d | 2015-08-05 13:56:50 -0700 | [diff] [blame] | 6 | import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; |
Kun Zhang | 2ee4d02 | 2015-06-04 16:39:25 -0700 | [diff] [blame] | 7 | import static io.grpc.stub.ClientCalls.blockingUnaryCall; |
| 8 | import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; |
Kun Zhang | 686dcff | 2015-07-16 12:34:37 -0700 | [diff] [blame] | 9 | import static io.grpc.stub.ClientCalls.futureUnaryCall; |
Kun Zhang | 042b278 | 2015-08-17 15:43:40 -0700 | [diff] [blame] | 10 | import static io.grpc.MethodDescriptor.generateFullMethodName; |
Kun Zhang | 867c76d | 2015-07-13 17:15:34 -0700 | [diff] [blame] | 11 | import static io.grpc.stub.ServerCalls.asyncUnaryCall; |
| 12 | import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; |
| 13 | import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; |
Carl Mastrangelo | 67fc45d | 2015-08-05 13:56:50 -0700 | [diff] [blame] | 14 | import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; |
Lukasz Strzalkowski | 2fbf142 | 2016-04-08 02:28:32 +0200 | [diff] [blame] | 15 | import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; |
| 16 | import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 17 | |
| 18 | import java.io.IOException; |
| 19 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 20 | /** |
| 21 | * <pre> |
| 22 | * Test service that supports all call types. |
| 23 | * </pre> |
| 24 | */ |
Carl Mastrangelo | 72f1e88 | 2016-02-29 18:05:33 -0800 | [diff] [blame] | 25 | @javax.annotation.Generated( |
Eric Anderson | e9643bb | 2016-07-11 16:57:58 -0700 | [diff] [blame] | 26 | value = "by gRPC proto compiler (version 1.1.0-SNAPSHOT)", |
Carl Mastrangelo | 72f1e88 | 2016-02-29 18:05:33 -0800 | [diff] [blame] | 27 | comments = "Source: test.proto") |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 28 | public class TestServiceGrpc { |
| 29 | |
Eric Anderson | be0d7e9 | 2015-09-10 09:47:17 -0700 | [diff] [blame] | 30 | private TestServiceGrpc() {} |
| 31 | |
David P. Baker | 66b984c | 2015-08-21 13:00:26 -0400 | [diff] [blame] | 32 | public static final String SERVICE_NAME = "grpc.testing.TestService"; |
| 33 | |
Kun Zhang | 73acc73 | 2015-06-26 16:32:05 -0700 | [diff] [blame] | 34 | // Static method descriptors that strictly reflect the proto. |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 35 | private static final int ARG_IN_METHOD_UNARY_CALL = 0; |
| 36 | private static final int ARG_OUT_METHOD_UNARY_CALL = 1; |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 37 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 38 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.nano.Test.SimpleRequest, |
| 39 | io.grpc.testing.integration.nano.Test.SimpleResponse> METHOD_UNARY_CALL = |
Kun Zhang | 73acc73 | 2015-06-26 16:32:05 -0700 | [diff] [blame] | 40 | io.grpc.MethodDescriptor.create( |
| 41 | io.grpc.MethodDescriptor.MethodType.UNARY, |
Kun Zhang | 042b278 | 2015-08-17 15:43:40 -0700 | [diff] [blame] | 42 | generateFullMethodName( |
| 43 | "grpc.testing.TestService", "UnaryCall"), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 44 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.SimpleRequest>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 45 | new NanoFactory<io.grpc.testing.integration.nano.Test.SimpleRequest>(ARG_IN_METHOD_UNARY_CALL)), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 46 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.SimpleResponse>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 47 | new NanoFactory<io.grpc.testing.integration.nano.Test.SimpleResponse>(ARG_OUT_METHOD_UNARY_CALL)) |
| 48 | ); |
| 49 | private static final int ARG_IN_METHOD_STREAMING_OUTPUT_CALL = 2; |
| 50 | private static final int ARG_OUT_METHOD_STREAMING_OUTPUT_CALL = 3; |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 51 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 52 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 53 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> METHOD_STREAMING_OUTPUT_CALL = |
Kun Zhang | 73acc73 | 2015-06-26 16:32:05 -0700 | [diff] [blame] | 54 | io.grpc.MethodDescriptor.create( |
| 55 | io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING, |
Kun Zhang | 042b278 | 2015-08-17 15:43:40 -0700 | [diff] [blame] | 56 | generateFullMethodName( |
| 57 | "grpc.testing.TestService", "StreamingOutputCall"), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 58 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 59 | new NanoFactory<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_STREAMING_OUTPUT_CALL)), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 60 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 61 | new NanoFactory<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_STREAMING_OUTPUT_CALL)) |
| 62 | ); |
| 63 | private static final int ARG_IN_METHOD_STREAMING_INPUT_CALL = 4; |
| 64 | private static final int ARG_OUT_METHOD_STREAMING_INPUT_CALL = 5; |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 65 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 66 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.nano.Test.StreamingInputCallRequest, |
| 67 | io.grpc.testing.integration.nano.Test.StreamingInputCallResponse> METHOD_STREAMING_INPUT_CALL = |
Kun Zhang | 73acc73 | 2015-06-26 16:32:05 -0700 | [diff] [blame] | 68 | io.grpc.MethodDescriptor.create( |
| 69 | io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING, |
Kun Zhang | 042b278 | 2015-08-17 15:43:40 -0700 | [diff] [blame] | 70 | generateFullMethodName( |
| 71 | "grpc.testing.TestService", "StreamingInputCall"), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 72 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.StreamingInputCallRequest>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 73 | new NanoFactory<io.grpc.testing.integration.nano.Test.StreamingInputCallRequest>(ARG_IN_METHOD_STREAMING_INPUT_CALL)), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 74 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.StreamingInputCallResponse>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 75 | new NanoFactory<io.grpc.testing.integration.nano.Test.StreamingInputCallResponse>(ARG_OUT_METHOD_STREAMING_INPUT_CALL)) |
| 76 | ); |
| 77 | private static final int ARG_IN_METHOD_FULL_BIDI_CALL = 6; |
| 78 | private static final int ARG_OUT_METHOD_FULL_BIDI_CALL = 7; |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 79 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 80 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 81 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> METHOD_FULL_BIDI_CALL = |
Kun Zhang | 73acc73 | 2015-06-26 16:32:05 -0700 | [diff] [blame] | 82 | io.grpc.MethodDescriptor.create( |
Carl Mastrangelo | 67fc45d | 2015-08-05 13:56:50 -0700 | [diff] [blame] | 83 | io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING, |
Kun Zhang | 042b278 | 2015-08-17 15:43:40 -0700 | [diff] [blame] | 84 | generateFullMethodName( |
| 85 | "grpc.testing.TestService", "FullBidiCall"), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 86 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 87 | new NanoFactory<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_FULL_BIDI_CALL)), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 88 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 89 | new NanoFactory<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_FULL_BIDI_CALL)) |
| 90 | ); |
| 91 | private static final int ARG_IN_METHOD_HALF_BIDI_CALL = 8; |
| 92 | private static final int ARG_OUT_METHOD_HALF_BIDI_CALL = 9; |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 93 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 94 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 95 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> METHOD_HALF_BIDI_CALL = |
Kun Zhang | 73acc73 | 2015-06-26 16:32:05 -0700 | [diff] [blame] | 96 | io.grpc.MethodDescriptor.create( |
Carl Mastrangelo | 67fc45d | 2015-08-05 13:56:50 -0700 | [diff] [blame] | 97 | io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING, |
Kun Zhang | 042b278 | 2015-08-17 15:43:40 -0700 | [diff] [blame] | 98 | generateFullMethodName( |
| 99 | "grpc.testing.TestService", "HalfBidiCall"), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 100 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 101 | new NanoFactory<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_HALF_BIDI_CALL)), |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 102 | io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>marshaller( |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 103 | new NanoFactory<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_HALF_BIDI_CALL)) |
| 104 | ); |
| 105 | |
| 106 | private static final class NanoFactory<T extends com.google.protobuf.nano.MessageNano> |
| 107 | implements io.grpc.protobuf.nano.MessageNanoFactory<T> { |
| 108 | private final int id; |
| 109 | |
| 110 | NanoFactory(int id) { |
| 111 | this.id = id; |
| 112 | } |
| 113 | |
Lukasz Strzalkowski | 2fbf142 | 2016-04-08 02:28:32 +0200 | [diff] [blame] | 114 | @java.lang.Override |
Eric Anderson | 1ee336d | 2015-10-02 20:09:10 -0700 | [diff] [blame] | 115 | public T newInstance() { |
| 116 | Object o; |
| 117 | switch (id) { |
| 118 | case ARG_IN_METHOD_UNARY_CALL: |
| 119 | o = new io.grpc.testing.integration.nano.Test.SimpleRequest(); |
| 120 | break; |
| 121 | case ARG_OUT_METHOD_UNARY_CALL: |
| 122 | o = new io.grpc.testing.integration.nano.Test.SimpleResponse(); |
| 123 | break; |
| 124 | case ARG_IN_METHOD_STREAMING_OUTPUT_CALL: |
| 125 | o = new io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest(); |
| 126 | break; |
| 127 | case ARG_OUT_METHOD_STREAMING_OUTPUT_CALL: |
| 128 | o = new io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse(); |
| 129 | break; |
| 130 | case ARG_IN_METHOD_STREAMING_INPUT_CALL: |
| 131 | o = new io.grpc.testing.integration.nano.Test.StreamingInputCallRequest(); |
| 132 | break; |
| 133 | case ARG_OUT_METHOD_STREAMING_INPUT_CALL: |
| 134 | o = new io.grpc.testing.integration.nano.Test.StreamingInputCallResponse(); |
| 135 | break; |
| 136 | case ARG_IN_METHOD_FULL_BIDI_CALL: |
| 137 | o = new io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest(); |
| 138 | break; |
| 139 | case ARG_OUT_METHOD_FULL_BIDI_CALL: |
| 140 | o = new io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse(); |
| 141 | break; |
| 142 | case ARG_IN_METHOD_HALF_BIDI_CALL: |
| 143 | o = new io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest(); |
| 144 | break; |
| 145 | case ARG_OUT_METHOD_HALF_BIDI_CALL: |
| 146 | o = new io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse(); |
| 147 | break; |
| 148 | default: |
| 149 | throw new AssertionError(); |
| 150 | } |
| 151 | @java.lang.SuppressWarnings("unchecked") |
| 152 | T t = (T) o; |
| 153 | return t; |
| 154 | } |
| 155 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 156 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 157 | /** |
| 158 | * Creates a new async stub that supports all call types for the service |
| 159 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 160 | public static TestServiceStub newStub(io.grpc.Channel channel) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 161 | return new TestServiceStub(channel); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 162 | } |
| 163 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 164 | /** |
| 165 | * Creates a new blocking-style stub that supports unary and streaming output calls on the service |
| 166 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 167 | public static TestServiceBlockingStub newBlockingStub( |
| 168 | io.grpc.Channel channel) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 169 | return new TestServiceBlockingStub(channel); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 170 | } |
| 171 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 172 | /** |
| 173 | * Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service |
| 174 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 175 | public static TestServiceFutureStub newFutureStub( |
| 176 | io.grpc.Channel channel) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 177 | return new TestServiceFutureStub(channel); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 178 | } |
| 179 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 180 | /** |
| 181 | * <pre> |
| 182 | * Test service that supports all call types. |
| 183 | * </pre> |
| 184 | */ |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 185 | public static abstract class TestServiceImplBase implements io.grpc.BindableService, TestService { |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 186 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 187 | /** |
| 188 | * <pre> |
| 189 | * One request followed by one response. |
| 190 | * The server returns the client payload as-is. |
| 191 | * </pre> |
| 192 | */ |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 193 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 194 | public void unaryCall(io.grpc.testing.integration.nano.Test.SimpleRequest request, |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 195 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.SimpleResponse> responseObserver) { |
| 196 | asyncUnimplementedUnaryCall(METHOD_UNARY_CALL, responseObserver); |
| 197 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 198 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 199 | /** |
| 200 | * <pre> |
| 201 | * One request followed by a sequence of responses (streamed download). |
| 202 | * The server returns the payload with client desired type and sizes. |
| 203 | * </pre> |
| 204 | */ |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 205 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 206 | public void streamingOutputCall(io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest request, |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 207 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver) { |
| 208 | asyncUnimplementedUnaryCall(METHOD_STREAMING_OUTPUT_CALL, responseObserver); |
| 209 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 210 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 211 | /** |
| 212 | * <pre> |
| 213 | * A sequence of requests followed by one response (streamed upload). |
| 214 | * The server returns the aggregated size of client payload as the result. |
| 215 | * </pre> |
| 216 | */ |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 217 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 218 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingInputCallRequest> streamingInputCall( |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 219 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingInputCallResponse> responseObserver) { |
| 220 | return asyncUnimplementedStreamingCall(METHOD_STREAMING_INPUT_CALL, responseObserver); |
| 221 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 222 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 223 | /** |
| 224 | * <pre> |
| 225 | * A sequence of requests with each request served by the server immediately. |
| 226 | * As one request could lead to multiple responses, this interface |
| 227 | * demonstrates the idea of full bidirectionality. |
| 228 | * </pre> |
| 229 | */ |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 230 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 231 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest> fullBidiCall( |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 232 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver) { |
| 233 | return asyncUnimplementedStreamingCall(METHOD_FULL_BIDI_CALL, responseObserver); |
| 234 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 235 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 236 | /** |
| 237 | * <pre> |
| 238 | * A sequence of requests followed by a sequence of responses. |
| 239 | * The server buffers all the client requests and then serves them in order. A |
| 240 | * stream of responses are returned to the client when the server starts with |
| 241 | * first request. |
| 242 | * </pre> |
| 243 | */ |
Lukasz Strzalkowski | 2fbf142 | 2016-04-08 02:28:32 +0200 | [diff] [blame] | 244 | @java.lang.Override |
| 245 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest> halfBidiCall( |
| 246 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver) { |
| 247 | return asyncUnimplementedStreamingCall(METHOD_HALF_BIDI_CALL, responseObserver); |
| 248 | } |
| 249 | |
| 250 | @java.lang.Override public io.grpc.ServerServiceDefinition bindService() { |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 251 | return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) |
| 252 | .addMethod( |
| 253 | METHOD_UNARY_CALL, |
| 254 | asyncUnaryCall( |
| 255 | new MethodHandlers< |
| 256 | io.grpc.testing.integration.nano.Test.SimpleRequest, |
| 257 | io.grpc.testing.integration.nano.Test.SimpleResponse>( |
| 258 | this, METHODID_UNARY_CALL))) |
| 259 | .addMethod( |
| 260 | METHOD_STREAMING_OUTPUT_CALL, |
| 261 | asyncServerStreamingCall( |
| 262 | new MethodHandlers< |
| 263 | io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 264 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>( |
| 265 | this, METHODID_STREAMING_OUTPUT_CALL))) |
| 266 | .addMethod( |
| 267 | METHOD_STREAMING_INPUT_CALL, |
| 268 | asyncClientStreamingCall( |
| 269 | new MethodHandlers< |
| 270 | io.grpc.testing.integration.nano.Test.StreamingInputCallRequest, |
| 271 | io.grpc.testing.integration.nano.Test.StreamingInputCallResponse>( |
| 272 | this, METHODID_STREAMING_INPUT_CALL))) |
| 273 | .addMethod( |
| 274 | METHOD_FULL_BIDI_CALL, |
| 275 | asyncBidiStreamingCall( |
| 276 | new MethodHandlers< |
| 277 | io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 278 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>( |
| 279 | this, METHODID_FULL_BIDI_CALL))) |
| 280 | .addMethod( |
| 281 | METHOD_HALF_BIDI_CALL, |
| 282 | asyncBidiStreamingCall( |
| 283 | new MethodHandlers< |
| 284 | io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 285 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>( |
| 286 | this, METHODID_HALF_BIDI_CALL))) |
| 287 | .build(); |
Lukasz Strzalkowski | 2fbf142 | 2016-04-08 02:28:32 +0200 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 291 | /** |
| 292 | * <pre> |
| 293 | * Test service that supports all call types. |
| 294 | * </pre> |
| 295 | */ |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 296 | public static class TestServiceStub extends io.grpc.stub.AbstractStub<TestServiceStub> |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 297 | implements TestService { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 298 | private TestServiceStub(io.grpc.Channel channel) { |
| 299 | super(channel); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 300 | } |
| 301 | |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 302 | private TestServiceStub(io.grpc.Channel channel, |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 303 | io.grpc.CallOptions callOptions) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 304 | super(channel, callOptions); |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 307 | @java.lang.Override |
| 308 | protected TestServiceStub build(io.grpc.Channel channel, |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 309 | io.grpc.CallOptions callOptions) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 310 | return new TestServiceStub(channel, callOptions); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 311 | } |
| 312 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 313 | /** |
| 314 | * <pre> |
| 315 | * One request followed by one response. |
| 316 | * The server returns the client payload as-is. |
| 317 | * </pre> |
| 318 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 319 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 320 | public void unaryCall(io.grpc.testing.integration.nano.Test.SimpleRequest request, |
| 321 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.SimpleResponse> responseObserver) { |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 322 | asyncUnaryCall( |
Eric Anderson | 23e6318 | 2015-09-10 08:36:08 -0700 | [diff] [blame] | 323 | getChannel().newCall(METHOD_UNARY_CALL, getCallOptions()), request, responseObserver); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 324 | } |
| 325 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 326 | /** |
| 327 | * <pre> |
| 328 | * One request followed by a sequence of responses (streamed download). |
| 329 | * The server returns the payload with client desired type and sizes. |
| 330 | * </pre> |
| 331 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 332 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 333 | public void streamingOutputCall(io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest request, |
| 334 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver) { |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 335 | asyncServerStreamingCall( |
Eric Anderson | 23e6318 | 2015-09-10 08:36:08 -0700 | [diff] [blame] | 336 | getChannel().newCall(METHOD_STREAMING_OUTPUT_CALL, getCallOptions()), request, responseObserver); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 337 | } |
| 338 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 339 | /** |
| 340 | * <pre> |
| 341 | * A sequence of requests followed by one response (streamed upload). |
| 342 | * The server returns the aggregated size of client payload as the result. |
| 343 | * </pre> |
| 344 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 345 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 346 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingInputCallRequest> streamingInputCall( |
| 347 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingInputCallResponse> responseObserver) { |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 348 | return asyncClientStreamingCall( |
Eric Anderson | 23e6318 | 2015-09-10 08:36:08 -0700 | [diff] [blame] | 349 | getChannel().newCall(METHOD_STREAMING_INPUT_CALL, getCallOptions()), responseObserver); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 350 | } |
| 351 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 352 | /** |
| 353 | * <pre> |
| 354 | * A sequence of requests with each request served by the server immediately. |
| 355 | * As one request could lead to multiple responses, this interface |
| 356 | * demonstrates the idea of full bidirectionality. |
| 357 | * </pre> |
| 358 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 359 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 360 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest> fullBidiCall( |
| 361 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver) { |
Carl Mastrangelo | 67fc45d | 2015-08-05 13:56:50 -0700 | [diff] [blame] | 362 | return asyncBidiStreamingCall( |
Eric Anderson | 23e6318 | 2015-09-10 08:36:08 -0700 | [diff] [blame] | 363 | getChannel().newCall(METHOD_FULL_BIDI_CALL, getCallOptions()), responseObserver); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 364 | } |
| 365 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 366 | /** |
| 367 | * <pre> |
| 368 | * A sequence of requests followed by a sequence of responses. |
| 369 | * The server buffers all the client requests and then serves them in order. A |
| 370 | * stream of responses are returned to the client when the server starts with |
| 371 | * first request. |
| 372 | * </pre> |
| 373 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 374 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 375 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest> halfBidiCall( |
| 376 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver) { |
Carl Mastrangelo | 67fc45d | 2015-08-05 13:56:50 -0700 | [diff] [blame] | 377 | return asyncBidiStreamingCall( |
Eric Anderson | 23e6318 | 2015-09-10 08:36:08 -0700 | [diff] [blame] | 378 | getChannel().newCall(METHOD_HALF_BIDI_CALL, getCallOptions()), responseObserver); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 382 | /** |
| 383 | * <pre> |
| 384 | * Test service that supports all call types. |
| 385 | * </pre> |
| 386 | */ |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 387 | public static class TestServiceBlockingStub extends io.grpc.stub.AbstractStub<TestServiceBlockingStub> |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 388 | implements TestServiceBlockingClient { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 389 | private TestServiceBlockingStub(io.grpc.Channel channel) { |
| 390 | super(channel); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 391 | } |
| 392 | |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 393 | private TestServiceBlockingStub(io.grpc.Channel channel, |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 394 | io.grpc.CallOptions callOptions) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 395 | super(channel, callOptions); |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 396 | } |
| 397 | |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 398 | @java.lang.Override |
| 399 | protected TestServiceBlockingStub build(io.grpc.Channel channel, |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 400 | io.grpc.CallOptions callOptions) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 401 | return new TestServiceBlockingStub(channel, callOptions); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 402 | } |
| 403 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 404 | /** |
| 405 | * <pre> |
| 406 | * One request followed by one response. |
| 407 | * The server returns the client payload as-is. |
| 408 | * </pre> |
| 409 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 410 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 411 | public io.grpc.testing.integration.nano.Test.SimpleResponse unaryCall(io.grpc.testing.integration.nano.Test.SimpleRequest request) { |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 412 | return blockingUnaryCall( |
Eric Anderson | 4168f67 | 2015-08-04 16:37:00 -0700 | [diff] [blame] | 413 | getChannel(), METHOD_UNARY_CALL, getCallOptions(), request); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 414 | } |
| 415 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 416 | /** |
| 417 | * <pre> |
| 418 | * One request followed by a sequence of responses (streamed download). |
| 419 | * The server returns the payload with client desired type and sizes. |
| 420 | * </pre> |
| 421 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 422 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 423 | public java.util.Iterator<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> streamingOutputCall( |
| 424 | io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest request) { |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 425 | return blockingServerStreamingCall( |
Eric Anderson | 4168f67 | 2015-08-04 16:37:00 -0700 | [diff] [blame] | 426 | getChannel(), METHOD_STREAMING_OUTPUT_CALL, getCallOptions(), request); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 430 | /** |
| 431 | * <pre> |
| 432 | * Test service that supports all call types. |
| 433 | * </pre> |
| 434 | */ |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 435 | public static class TestServiceFutureStub extends io.grpc.stub.AbstractStub<TestServiceFutureStub> |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 436 | implements TestServiceFutureClient { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 437 | private TestServiceFutureStub(io.grpc.Channel channel) { |
| 438 | super(channel); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 439 | } |
| 440 | |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 441 | private TestServiceFutureStub(io.grpc.Channel channel, |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 442 | io.grpc.CallOptions callOptions) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 443 | super(channel, callOptions); |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 444 | } |
| 445 | |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 446 | @java.lang.Override |
| 447 | protected TestServiceFutureStub build(io.grpc.Channel channel, |
Kun Zhang | d3c5b00 | 2015-06-25 20:24:01 -0700 | [diff] [blame] | 448 | io.grpc.CallOptions callOptions) { |
Kun Zhang | eb92967 | 2015-07-17 17:02:58 -0700 | [diff] [blame] | 449 | return new TestServiceFutureStub(channel, callOptions); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 450 | } |
| 451 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 452 | /** |
| 453 | * <pre> |
| 454 | * One request followed by one response. |
| 455 | * The server returns the client payload as-is. |
| 456 | * </pre> |
| 457 | */ |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 458 | @java.lang.Override |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 459 | public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.nano.Test.SimpleResponse> unaryCall( |
| 460 | io.grpc.testing.integration.nano.Test.SimpleRequest request) { |
Kun Zhang | 686dcff | 2015-07-16 12:34:37 -0700 | [diff] [blame] | 461 | return futureUnaryCall( |
Eric Anderson | 23e6318 | 2015-09-10 08:36:08 -0700 | [diff] [blame] | 462 | getChannel().newCall(METHOD_UNARY_CALL, getCallOptions()), request); |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 463 | } |
| 464 | } |
| 465 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 466 | /** |
| 467 | * This will be removed in the next release. |
| 468 | * If your code has been using gRPC-java v0.15.0 or higher already, |
| 469 | * the following changes to your code are suggested: |
| 470 | * <ul> |
| 471 | * <li> replace {@code extends/implements TestService} with {@code extends TestServiceImplBase} for server side;</li> |
| 472 | * <li> replace {@code TestService} with {@code TestServiceStub} for client side;</li> |
| 473 | * <li> replace usage of {@code TestService} with {@code TestServiceImplBase};</li> |
| 474 | * <li> replace usage of {@code AbstractTestService} with {@link TestServiceImplBase};</li> |
| 475 | * <li> replace {@code serverBuilder.addService(TestServiceGrpc.bindService(serviceImpl))} |
| 476 | * with {@code serverBuilder.addService(serviceImpl)};</li> |
| 477 | * <li> if you are mocking stubs using mockito, please do not mock them. |
| 478 | * See the documentation on testing with gRPC-java;</li> |
| 479 | * <li> replace {@code TestServiceBlockingClient} with {@link TestServiceBlockingStub};</li> |
| 480 | * <li> replace {@code TestServiceFutureClient} with {@link TestServiceFutureStub}.</li> |
| 481 | * </ul> |
| 482 | */ |
| 483 | @java.lang.Deprecated public static interface TestService { |
| 484 | |
| 485 | public void unaryCall(io.grpc.testing.integration.nano.Test.SimpleRequest request, |
| 486 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.SimpleResponse> responseObserver); |
| 487 | |
| 488 | public void streamingOutputCall(io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest request, |
| 489 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver); |
| 490 | |
| 491 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingInputCallRequest> streamingInputCall( |
| 492 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingInputCallResponse> responseObserver); |
| 493 | |
| 494 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest> fullBidiCall( |
| 495 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver); |
| 496 | |
| 497 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest> halfBidiCall( |
| 498 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> responseObserver); |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * This will be removed in the next release. |
| 503 | * If your code has been using gRPC-java v0.15.0 or higher already, |
| 504 | * the following changes to your code are suggested: |
| 505 | * <ul> |
| 506 | * <li> replace {@code extends/implements TestService} with {@code extends TestServiceImplBase} for server side;</li> |
| 507 | * <li> replace {@code TestService} with {@code TestServiceStub} for client side;</li> |
| 508 | * <li> replace usage of {@code TestService} with {@code TestServiceImplBase};</li> |
| 509 | * <li> replace usage of {@code AbstractTestService} with {@link TestServiceImplBase};</li> |
| 510 | * <li> replace {@code serverBuilder.addService(TestServiceGrpc.bindService(serviceImpl))} |
| 511 | * with {@code serverBuilder.addService(serviceImpl)};</li> |
| 512 | * <li> if you are mocking stubs using mockito, please do not mock them. |
| 513 | * See the documentation on testing with gRPC-java;</li> |
| 514 | * <li> replace {@code TestServiceBlockingClient} with {@link TestServiceBlockingStub};</li> |
| 515 | * <li> replace {@code TestServiceFutureClient} with {@link TestServiceFutureStub}.</li> |
| 516 | * </ul> |
| 517 | */ |
| 518 | @java.lang.Deprecated public static interface TestServiceBlockingClient { |
| 519 | |
| 520 | public io.grpc.testing.integration.nano.Test.SimpleResponse unaryCall(io.grpc.testing.integration.nano.Test.SimpleRequest request); |
| 521 | |
| 522 | public java.util.Iterator<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse> streamingOutputCall( |
| 523 | io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest request); |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * This will be removed in the next release. |
| 528 | * If your code has been using gRPC-java v0.15.0 or higher already, |
| 529 | * the following changes to your code are suggested: |
| 530 | * <ul> |
| 531 | * <li> replace {@code extends/implements TestService} with {@code extends TestServiceImplBase} for server side;</li> |
| 532 | * <li> replace {@code TestService} with {@code TestServiceStub} for client side;</li> |
| 533 | * <li> replace usage of {@code TestService} with {@code TestServiceImplBase};</li> |
| 534 | * <li> replace usage of {@code AbstractTestService} with {@link TestServiceImplBase};</li> |
| 535 | * <li> replace {@code serverBuilder.addService(TestServiceGrpc.bindService(serviceImpl))} |
| 536 | * with {@code serverBuilder.addService(serviceImpl)};</li> |
| 537 | * <li> if you are mocking stubs using mockito, please do not mock them. |
| 538 | * See the documentation on testing with gRPC-java;</li> |
| 539 | * <li> replace {@code TestServiceBlockingClient} with {@link TestServiceBlockingStub};</li> |
| 540 | * <li> replace {@code TestServiceFutureClient} with {@link TestServiceFutureStub}.</li> |
| 541 | * </ul> |
| 542 | */ |
| 543 | @java.lang.Deprecated public static interface TestServiceFutureClient { |
| 544 | |
| 545 | public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.nano.Test.SimpleResponse> unaryCall( |
| 546 | io.grpc.testing.integration.nano.Test.SimpleRequest request); |
| 547 | } |
| 548 | |
| 549 | /** |
| 550 | * This will be removed in the next release. |
| 551 | * If your code has been using gRPC-java v0.15.0 or higher already, |
| 552 | * the following changes to your code are suggested: |
| 553 | * <ul> |
| 554 | * <li> replace {@code extends/implements TestService} with {@code extends TestServiceImplBase} for server side;</li> |
| 555 | * <li> replace {@code TestService} with {@code TestServiceStub} for client side;</li> |
| 556 | * <li> replace usage of {@code TestService} with {@code TestServiceImplBase};</li> |
| 557 | * <li> replace usage of {@code AbstractTestService} with {@link TestServiceImplBase};</li> |
| 558 | * <li> replace {@code serverBuilder.addService(TestServiceGrpc.bindService(serviceImpl))} |
| 559 | * with {@code serverBuilder.addService(serviceImpl)};</li> |
| 560 | * <li> if you are mocking stubs using mockito, please do not mock them. |
| 561 | * See the documentation on testing with gRPC-java;</li> |
| 562 | * <li> replace {@code TestServiceBlockingClient} with {@link TestServiceBlockingStub};</li> |
| 563 | * <li> replace {@code TestServiceFutureClient} with {@link TestServiceFutureStub}.</li> |
| 564 | * </ul> |
| 565 | */ |
ZHANG Dapeng | f149e4c | 2016-06-29 21:17:03 -0700 | [diff] [blame] | 566 | @java.lang.Deprecated public static abstract class AbstractTestService extends TestServiceImplBase {} |
| 567 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame^] | 568 | /** |
| 569 | * This will be removed in the next release. |
| 570 | * If your code has been using gRPC-java v0.15.0 or higher already, |
| 571 | * the following changes to your code are suggested: |
| 572 | * <ul> |
| 573 | * <li> replace {@code extends/implements TestService} with {@code extends TestServiceImplBase} for server side;</li> |
| 574 | * <li> replace {@code TestService} with {@code TestServiceStub} for client side;</li> |
| 575 | * <li> replace usage of {@code TestService} with {@code TestServiceImplBase};</li> |
| 576 | * <li> replace usage of {@code AbstractTestService} with {@link TestServiceImplBase};</li> |
| 577 | * <li> replace {@code serverBuilder.addService(TestServiceGrpc.bindService(serviceImpl))} |
| 578 | * with {@code serverBuilder.addService(serviceImpl)};</li> |
| 579 | * <li> if you are mocking stubs using mockito, please do not mock them. |
| 580 | * See the documentation on testing with gRPC-java;</li> |
| 581 | * <li> replace {@code TestServiceBlockingClient} with {@link TestServiceBlockingStub};</li> |
| 582 | * <li> replace {@code TestServiceFutureClient} with {@link TestServiceFutureStub}.</li> |
| 583 | * </ul> |
| 584 | */ |
| 585 | @java.lang.Deprecated public static io.grpc.ServerServiceDefinition bindService(final TestService serviceImpl) { |
| 586 | return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) |
| 587 | .addMethod( |
| 588 | METHOD_UNARY_CALL, |
| 589 | asyncUnaryCall( |
| 590 | new MethodHandlers< |
| 591 | io.grpc.testing.integration.nano.Test.SimpleRequest, |
| 592 | io.grpc.testing.integration.nano.Test.SimpleResponse>( |
| 593 | serviceImpl, METHODID_UNARY_CALL))) |
| 594 | .addMethod( |
| 595 | METHOD_STREAMING_OUTPUT_CALL, |
| 596 | asyncServerStreamingCall( |
| 597 | new MethodHandlers< |
| 598 | io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 599 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>( |
| 600 | serviceImpl, METHODID_STREAMING_OUTPUT_CALL))) |
| 601 | .addMethod( |
| 602 | METHOD_STREAMING_INPUT_CALL, |
| 603 | asyncClientStreamingCall( |
| 604 | new MethodHandlers< |
| 605 | io.grpc.testing.integration.nano.Test.StreamingInputCallRequest, |
| 606 | io.grpc.testing.integration.nano.Test.StreamingInputCallResponse>( |
| 607 | serviceImpl, METHODID_STREAMING_INPUT_CALL))) |
| 608 | .addMethod( |
| 609 | METHOD_FULL_BIDI_CALL, |
| 610 | asyncBidiStreamingCall( |
| 611 | new MethodHandlers< |
| 612 | io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 613 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>( |
| 614 | serviceImpl, METHODID_FULL_BIDI_CALL))) |
| 615 | .addMethod( |
| 616 | METHOD_HALF_BIDI_CALL, |
| 617 | asyncBidiStreamingCall( |
| 618 | new MethodHandlers< |
| 619 | io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest, |
| 620 | io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>( |
| 621 | serviceImpl, METHODID_HALF_BIDI_CALL))) |
| 622 | .build(); |
| 623 | } |
| 624 | |
Eric Anderson | d52429d | 2015-11-13 16:50:08 -0800 | [diff] [blame] | 625 | private static final int METHODID_UNARY_CALL = 0; |
| 626 | private static final int METHODID_STREAMING_OUTPUT_CALL = 1; |
| 627 | private static final int METHODID_STREAMING_INPUT_CALL = 2; |
| 628 | private static final int METHODID_FULL_BIDI_CALL = 3; |
| 629 | private static final int METHODID_HALF_BIDI_CALL = 4; |
| 630 | |
| 631 | private static class MethodHandlers<Req, Resp> implements |
| 632 | io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, |
| 633 | io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>, |
| 634 | io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>, |
| 635 | io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> { |
| 636 | private final TestService serviceImpl; |
| 637 | private final int methodId; |
| 638 | |
| 639 | public MethodHandlers(TestService serviceImpl, int methodId) { |
| 640 | this.serviceImpl = serviceImpl; |
| 641 | this.methodId = methodId; |
| 642 | } |
| 643 | |
Carl Mastrangelo | ffe0dce | 2016-03-04 14:15:02 -0800 | [diff] [blame] | 644 | @java.lang.Override |
Eric Anderson | d52429d | 2015-11-13 16:50:08 -0800 | [diff] [blame] | 645 | @java.lang.SuppressWarnings("unchecked") |
| 646 | public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) { |
| 647 | switch (methodId) { |
| 648 | case METHODID_UNARY_CALL: |
| 649 | serviceImpl.unaryCall((io.grpc.testing.integration.nano.Test.SimpleRequest) request, |
| 650 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.SimpleResponse>) responseObserver); |
| 651 | break; |
| 652 | case METHODID_STREAMING_OUTPUT_CALL: |
| 653 | serviceImpl.streamingOutputCall((io.grpc.testing.integration.nano.Test.StreamingOutputCallRequest) request, |
| 654 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>) responseObserver); |
| 655 | break; |
| 656 | default: |
| 657 | throw new AssertionError(); |
| 658 | } |
| 659 | } |
| 660 | |
Carl Mastrangelo | ffe0dce | 2016-03-04 14:15:02 -0800 | [diff] [blame] | 661 | @java.lang.Override |
Eric Anderson | d52429d | 2015-11-13 16:50:08 -0800 | [diff] [blame] | 662 | @java.lang.SuppressWarnings("unchecked") |
| 663 | public io.grpc.stub.StreamObserver<Req> invoke( |
| 664 | io.grpc.stub.StreamObserver<Resp> responseObserver) { |
| 665 | switch (methodId) { |
| 666 | case METHODID_STREAMING_INPUT_CALL: |
| 667 | return (io.grpc.stub.StreamObserver<Req>) serviceImpl.streamingInputCall( |
| 668 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingInputCallResponse>) responseObserver); |
| 669 | case METHODID_FULL_BIDI_CALL: |
| 670 | return (io.grpc.stub.StreamObserver<Req>) serviceImpl.fullBidiCall( |
| 671 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>) responseObserver); |
| 672 | case METHODID_HALF_BIDI_CALL: |
| 673 | return (io.grpc.stub.StreamObserver<Req>) serviceImpl.halfBidiCall( |
| 674 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.nano.Test.StreamingOutputCallResponse>) responseObserver); |
| 675 | default: |
| 676 | throw new AssertionError(); |
| 677 | } |
| 678 | } |
| 679 | } |
| 680 | |
Eric Anderson | 66ab956 | 2016-06-20 15:22:23 -0700 | [diff] [blame] | 681 | public static io.grpc.ServiceDescriptor getServiceDescriptor() { |
| 682 | return new io.grpc.ServiceDescriptor(SERVICE_NAME, |
| 683 | METHOD_UNARY_CALL, |
| 684 | METHOD_STREAMING_OUTPUT_CALL, |
| 685 | METHOD_STREAMING_INPUT_CALL, |
| 686 | METHOD_FULL_BIDI_CALL, |
| 687 | METHOD_HALF_BIDI_CALL); |
| 688 | } |
| 689 | |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 690 | } |