Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 1 | package io.grpc.testing.integration; |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 2 | |
| 3 | import static io.grpc.stub.ClientCalls.asyncUnaryCall; |
| 4 | import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; |
| 5 | import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; |
| 6 | import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; |
| 7 | import static io.grpc.stub.ClientCalls.blockingUnaryCall; |
| 8 | import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; |
| 9 | import static io.grpc.stub.ClientCalls.futureUnaryCall; |
| 10 | import static io.grpc.MethodDescriptor.generateFullMethodName; |
| 11 | import static io.grpc.stub.ServerCalls.asyncUnaryCall; |
| 12 | import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; |
| 13 | import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; |
| 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; |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 17 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 18 | /** |
| 19 | * <pre> |
| 20 | * Test service that supports all call types. |
| 21 | * </pre> |
| 22 | */ |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 23 | @javax.annotation.Generated( |
Eric Anderson | e9643bb | 2016-07-11 16:57:58 -0700 | [diff] [blame] | 24 | value = "by gRPC proto compiler (version 1.1.0-SNAPSHOT)", |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 25 | comments = "Source: test.proto") |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 26 | public class TestServiceGrpc { |
| 27 | |
| 28 | private TestServiceGrpc() {} |
| 29 | |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 30 | public static final String SERVICE_NAME = "grpc.testing.TestService"; |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 31 | |
| 32 | // Static method descriptors that strictly reflect the proto. |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 33 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 34 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.SimpleRequest, |
| 35 | io.grpc.testing.integration.Test.SimpleResponse> METHOD_UNARY_CALL = |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 36 | io.grpc.MethodDescriptor.create( |
| 37 | io.grpc.MethodDescriptor.MethodType.UNARY, |
| 38 | generateFullMethodName( |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 39 | "grpc.testing.TestService", "UnaryCall"), |
| 40 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.SimpleRequest.getDefaultInstance()), |
| 41 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.SimpleResponse.getDefaultInstance())); |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 42 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 43 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest, |
| 44 | io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_STREAMING_OUTPUT_CALL = |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 45 | io.grpc.MethodDescriptor.create( |
| 46 | io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING, |
| 47 | generateFullMethodName( |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 48 | "grpc.testing.TestService", "StreamingOutputCall"), |
| 49 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()), |
| 50 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance())); |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 51 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 52 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingInputCallRequest, |
| 53 | io.grpc.testing.integration.Test.StreamingInputCallResponse> METHOD_STREAMING_INPUT_CALL = |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 54 | io.grpc.MethodDescriptor.create( |
| 55 | io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING, |
| 56 | generateFullMethodName( |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 57 | "grpc.testing.TestService", "StreamingInputCall"), |
| 58 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallRequest.getDefaultInstance()), |
| 59 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallResponse.getDefaultInstance())); |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 60 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 61 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest, |
| 62 | io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_FULL_BIDI_CALL = |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 63 | io.grpc.MethodDescriptor.create( |
| 64 | io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING, |
| 65 | generateFullMethodName( |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 66 | "grpc.testing.TestService", "FullBidiCall"), |
| 67 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()), |
| 68 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance())); |
Eric Anderson | 7c722e4 | 2016-06-07 15:00:29 -0700 | [diff] [blame] | 69 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 70 | public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest, |
| 71 | io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_HALF_BIDI_CALL = |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 72 | io.grpc.MethodDescriptor.create( |
| 73 | io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING, |
| 74 | generateFullMethodName( |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 75 | "grpc.testing.TestService", "HalfBidiCall"), |
| 76 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()), |
| 77 | io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance())); |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 78 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 79 | /** |
| 80 | * Creates a new async stub that supports all call types for the service |
| 81 | */ |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 82 | public static TestServiceStub newStub(io.grpc.Channel channel) { |
| 83 | return new TestServiceStub(channel); |
| 84 | } |
| 85 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 86 | /** |
| 87 | * Creates a new blocking-style stub that supports unary and streaming output calls on the service |
| 88 | */ |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 89 | public static TestServiceBlockingStub newBlockingStub( |
| 90 | io.grpc.Channel channel) { |
| 91 | return new TestServiceBlockingStub(channel); |
| 92 | } |
| 93 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 94 | /** |
| 95 | * Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service |
| 96 | */ |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 97 | public static TestServiceFutureStub newFutureStub( |
| 98 | io.grpc.Channel channel) { |
| 99 | return new TestServiceFutureStub(channel); |
| 100 | } |
| 101 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 102 | /** |
| 103 | * <pre> |
| 104 | * Test service that supports all call types. |
| 105 | * </pre> |
| 106 | */ |
ZHANG Dapeng | 8f5adf8 | 2016-07-22 16:35:00 -0700 | [diff] [blame] | 107 | public static abstract class TestServiceImplBase implements io.grpc.BindableService { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 108 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 109 | /** |
| 110 | * <pre> |
| 111 | * One request followed by one response. |
| 112 | * The server returns the client payload as-is. |
| 113 | * </pre> |
| 114 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 115 | public void unaryCall(io.grpc.testing.integration.Test.SimpleRequest request, |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 116 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.SimpleResponse> responseObserver) { |
| 117 | asyncUnimplementedUnaryCall(METHOD_UNARY_CALL, responseObserver); |
| 118 | } |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 119 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 120 | /** |
| 121 | * <pre> |
| 122 | * One request followed by a sequence of responses (streamed download). |
| 123 | * The server returns the payload with client desired type and sizes. |
| 124 | * </pre> |
| 125 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 126 | public void streamingOutputCall(io.grpc.testing.integration.Test.StreamingOutputCallRequest request, |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 127 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) { |
| 128 | asyncUnimplementedUnaryCall(METHOD_STREAMING_OUTPUT_CALL, responseObserver); |
| 129 | } |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 130 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 131 | /** |
| 132 | * <pre> |
| 133 | * A sequence of requests followed by one response (streamed upload). |
| 134 | * The server returns the aggregated size of client payload as the result. |
| 135 | * </pre> |
| 136 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 137 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallRequest> streamingInputCall( |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 138 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallResponse> responseObserver) { |
| 139 | return asyncUnimplementedStreamingCall(METHOD_STREAMING_INPUT_CALL, responseObserver); |
| 140 | } |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 141 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 142 | /** |
| 143 | * <pre> |
| 144 | * A sequence of requests with each request served by the server immediately. |
| 145 | * As one request could lead to multiple responses, this interface |
| 146 | * demonstrates the idea of full bidirectionality. |
| 147 | * </pre> |
| 148 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 149 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> fullBidiCall( |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 150 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) { |
| 151 | return asyncUnimplementedStreamingCall(METHOD_FULL_BIDI_CALL, responseObserver); |
| 152 | } |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 153 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 154 | /** |
| 155 | * <pre> |
| 156 | * A sequence of requests followed by a sequence of responses. |
| 157 | * The server buffers all the client requests and then serves them in order. A |
| 158 | * stream of responses are returned to the client when the server starts with |
| 159 | * first request. |
| 160 | * </pre> |
| 161 | */ |
Lukasz Strzalkowski | 2fbf142 | 2016-04-08 02:28:32 +0200 | [diff] [blame] | 162 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> halfBidiCall( |
| 163 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) { |
| 164 | return asyncUnimplementedStreamingCall(METHOD_HALF_BIDI_CALL, responseObserver); |
| 165 | } |
| 166 | |
| 167 | @java.lang.Override public io.grpc.ServerServiceDefinition bindService() { |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 168 | return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) |
| 169 | .addMethod( |
| 170 | METHOD_UNARY_CALL, |
| 171 | asyncUnaryCall( |
| 172 | new MethodHandlers< |
| 173 | io.grpc.testing.integration.Test.SimpleRequest, |
| 174 | io.grpc.testing.integration.Test.SimpleResponse>( |
| 175 | this, METHODID_UNARY_CALL))) |
| 176 | .addMethod( |
| 177 | METHOD_STREAMING_OUTPUT_CALL, |
| 178 | asyncServerStreamingCall( |
| 179 | new MethodHandlers< |
| 180 | io.grpc.testing.integration.Test.StreamingOutputCallRequest, |
| 181 | io.grpc.testing.integration.Test.StreamingOutputCallResponse>( |
| 182 | this, METHODID_STREAMING_OUTPUT_CALL))) |
| 183 | .addMethod( |
| 184 | METHOD_STREAMING_INPUT_CALL, |
| 185 | asyncClientStreamingCall( |
| 186 | new MethodHandlers< |
| 187 | io.grpc.testing.integration.Test.StreamingInputCallRequest, |
| 188 | io.grpc.testing.integration.Test.StreamingInputCallResponse>( |
| 189 | this, METHODID_STREAMING_INPUT_CALL))) |
| 190 | .addMethod( |
| 191 | METHOD_FULL_BIDI_CALL, |
| 192 | asyncBidiStreamingCall( |
| 193 | new MethodHandlers< |
| 194 | io.grpc.testing.integration.Test.StreamingOutputCallRequest, |
| 195 | io.grpc.testing.integration.Test.StreamingOutputCallResponse>( |
| 196 | this, METHODID_FULL_BIDI_CALL))) |
| 197 | .addMethod( |
| 198 | METHOD_HALF_BIDI_CALL, |
| 199 | asyncBidiStreamingCall( |
| 200 | new MethodHandlers< |
| 201 | io.grpc.testing.integration.Test.StreamingOutputCallRequest, |
| 202 | io.grpc.testing.integration.Test.StreamingOutputCallResponse>( |
| 203 | this, METHODID_HALF_BIDI_CALL))) |
| 204 | .build(); |
Lukasz Strzalkowski | 2fbf142 | 2016-04-08 02:28:32 +0200 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
nmittler | 7e8b504 | 2016-04-15 12:52:00 -0700 | [diff] [blame] | 208 | /** |
| 209 | * <pre> |
| 210 | * Test service that supports all call types. |
| 211 | * </pre> |
| 212 | */ |
ZHANG Dapeng | 8f5adf8 | 2016-07-22 16:35:00 -0700 | [diff] [blame] | 213 | public static final class TestServiceStub extends io.grpc.stub.AbstractStub<TestServiceStub> { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 214 | private TestServiceStub(io.grpc.Channel channel) { |
| 215 | super(channel); |
| 216 | } |
| 217 | |
| 218 | private TestServiceStub(io.grpc.Channel channel, |
| 219 | io.grpc.CallOptions callOptions) { |
| 220 | super(channel, callOptions); |
| 221 | } |
| 222 | |
| 223 | @java.lang.Override |
| 224 | protected TestServiceStub build(io.grpc.Channel channel, |
| 225 | io.grpc.CallOptions callOptions) { |
| 226 | return new TestServiceStub(channel, callOptions); |
| 227 | } |
| 228 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 229 | /** |
| 230 | * <pre> |
| 231 | * One request followed by one response. |
| 232 | * The server returns the client payload as-is. |
| 233 | * </pre> |
| 234 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 235 | public void unaryCall(io.grpc.testing.integration.Test.SimpleRequest request, |
| 236 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.SimpleResponse> responseObserver) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 237 | asyncUnaryCall( |
| 238 | getChannel().newCall(METHOD_UNARY_CALL, getCallOptions()), request, responseObserver); |
| 239 | } |
| 240 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 241 | /** |
| 242 | * <pre> |
| 243 | * One request followed by a sequence of responses (streamed download). |
| 244 | * The server returns the payload with client desired type and sizes. |
| 245 | * </pre> |
| 246 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 247 | public void streamingOutputCall(io.grpc.testing.integration.Test.StreamingOutputCallRequest request, |
| 248 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 249 | asyncServerStreamingCall( |
| 250 | getChannel().newCall(METHOD_STREAMING_OUTPUT_CALL, getCallOptions()), request, responseObserver); |
| 251 | } |
| 252 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 253 | /** |
| 254 | * <pre> |
| 255 | * A sequence of requests followed by one response (streamed upload). |
| 256 | * The server returns the aggregated size of client payload as the result. |
| 257 | * </pre> |
| 258 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 259 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallRequest> streamingInputCall( |
| 260 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallResponse> responseObserver) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 261 | return asyncClientStreamingCall( |
| 262 | getChannel().newCall(METHOD_STREAMING_INPUT_CALL, getCallOptions()), responseObserver); |
| 263 | } |
| 264 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 265 | /** |
| 266 | * <pre> |
| 267 | * A sequence of requests with each request served by the server immediately. |
| 268 | * As one request could lead to multiple responses, this interface |
| 269 | * demonstrates the idea of full bidirectionality. |
| 270 | * </pre> |
| 271 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 272 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> fullBidiCall( |
| 273 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 274 | return asyncBidiStreamingCall( |
| 275 | getChannel().newCall(METHOD_FULL_BIDI_CALL, getCallOptions()), responseObserver); |
| 276 | } |
| 277 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 278 | /** |
| 279 | * <pre> |
| 280 | * A sequence of requests followed by a sequence of responses. |
| 281 | * The server buffers all the client requests and then serves them in order. A |
| 282 | * stream of responses are returned to the client when the server starts with |
| 283 | * first request. |
| 284 | * </pre> |
| 285 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 286 | public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> halfBidiCall( |
| 287 | io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 288 | return asyncBidiStreamingCall( |
| 289 | getChannel().newCall(METHOD_HALF_BIDI_CALL, getCallOptions()), responseObserver); |
| 290 | } |
| 291 | } |
| 292 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 293 | /** |
| 294 | * <pre> |
| 295 | * Test service that supports all call types. |
| 296 | * </pre> |
| 297 | */ |
ZHANG Dapeng | 8f5adf8 | 2016-07-22 16:35:00 -0700 | [diff] [blame] | 298 | public static final class TestServiceBlockingStub extends io.grpc.stub.AbstractStub<TestServiceBlockingStub> { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 299 | private TestServiceBlockingStub(io.grpc.Channel channel) { |
| 300 | super(channel); |
| 301 | } |
| 302 | |
| 303 | private TestServiceBlockingStub(io.grpc.Channel channel, |
| 304 | io.grpc.CallOptions callOptions) { |
| 305 | super(channel, callOptions); |
| 306 | } |
| 307 | |
| 308 | @java.lang.Override |
| 309 | protected TestServiceBlockingStub build(io.grpc.Channel channel, |
| 310 | io.grpc.CallOptions callOptions) { |
| 311 | return new TestServiceBlockingStub(channel, callOptions); |
| 312 | } |
| 313 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 314 | /** |
| 315 | * <pre> |
| 316 | * One request followed by one response. |
| 317 | * The server returns the client payload as-is. |
| 318 | * </pre> |
| 319 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 320 | public io.grpc.testing.integration.Test.SimpleResponse unaryCall(io.grpc.testing.integration.Test.SimpleRequest request) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 321 | return blockingUnaryCall( |
| 322 | getChannel(), METHOD_UNARY_CALL, getCallOptions(), request); |
| 323 | } |
| 324 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 325 | /** |
| 326 | * <pre> |
| 327 | * One request followed by a sequence of responses (streamed download). |
| 328 | * The server returns the payload with client desired type and sizes. |
| 329 | * </pre> |
| 330 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 331 | public java.util.Iterator<io.grpc.testing.integration.Test.StreamingOutputCallResponse> streamingOutputCall( |
| 332 | io.grpc.testing.integration.Test.StreamingOutputCallRequest request) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 333 | return blockingServerStreamingCall( |
| 334 | getChannel(), METHOD_STREAMING_OUTPUT_CALL, getCallOptions(), request); |
| 335 | } |
| 336 | } |
| 337 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 338 | /** |
| 339 | * <pre> |
| 340 | * Test service that supports all call types. |
| 341 | * </pre> |
| 342 | */ |
ZHANG Dapeng | 8f5adf8 | 2016-07-22 16:35:00 -0700 | [diff] [blame] | 343 | public static final class TestServiceFutureStub extends io.grpc.stub.AbstractStub<TestServiceFutureStub> { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 344 | private TestServiceFutureStub(io.grpc.Channel channel) { |
| 345 | super(channel); |
| 346 | } |
| 347 | |
| 348 | private TestServiceFutureStub(io.grpc.Channel channel, |
| 349 | io.grpc.CallOptions callOptions) { |
| 350 | super(channel, callOptions); |
| 351 | } |
| 352 | |
| 353 | @java.lang.Override |
| 354 | protected TestServiceFutureStub build(io.grpc.Channel channel, |
| 355 | io.grpc.CallOptions callOptions) { |
| 356 | return new TestServiceFutureStub(channel, callOptions); |
| 357 | } |
| 358 | |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 359 | /** |
| 360 | * <pre> |
| 361 | * One request followed by one response. |
| 362 | * The server returns the client payload as-is. |
| 363 | * </pre> |
| 364 | */ |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 365 | public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Test.SimpleResponse> unaryCall( |
| 366 | io.grpc.testing.integration.Test.SimpleRequest request) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 367 | return futureUnaryCall( |
| 368 | getChannel().newCall(METHOD_UNARY_CALL, getCallOptions()), request); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | private static final int METHODID_UNARY_CALL = 0; |
| 373 | private static final int METHODID_STREAMING_OUTPUT_CALL = 1; |
| 374 | private static final int METHODID_STREAMING_INPUT_CALL = 2; |
| 375 | private static final int METHODID_FULL_BIDI_CALL = 3; |
| 376 | private static final int METHODID_HALF_BIDI_CALL = 4; |
| 377 | |
| 378 | private static class MethodHandlers<Req, Resp> implements |
| 379 | io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, |
| 380 | io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>, |
| 381 | io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>, |
| 382 | io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> { |
ZHANG Dapeng | 8f5adf8 | 2016-07-22 16:35:00 -0700 | [diff] [blame] | 383 | private final TestServiceImplBase serviceImpl; |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 384 | private final int methodId; |
| 385 | |
ZHANG Dapeng | 8f5adf8 | 2016-07-22 16:35:00 -0700 | [diff] [blame] | 386 | public MethodHandlers(TestServiceImplBase serviceImpl, int methodId) { |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 387 | this.serviceImpl = serviceImpl; |
| 388 | this.methodId = methodId; |
| 389 | } |
| 390 | |
| 391 | @java.lang.Override |
| 392 | @java.lang.SuppressWarnings("unchecked") |
| 393 | public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) { |
| 394 | switch (methodId) { |
| 395 | case METHODID_UNARY_CALL: |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 396 | serviceImpl.unaryCall((io.grpc.testing.integration.Test.SimpleRequest) request, |
| 397 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.SimpleResponse>) responseObserver); |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 398 | break; |
| 399 | case METHODID_STREAMING_OUTPUT_CALL: |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 400 | serviceImpl.streamingOutputCall((io.grpc.testing.integration.Test.StreamingOutputCallRequest) request, |
| 401 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse>) responseObserver); |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 402 | break; |
| 403 | default: |
| 404 | throw new AssertionError(); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | @java.lang.Override |
| 409 | @java.lang.SuppressWarnings("unchecked") |
| 410 | public io.grpc.stub.StreamObserver<Req> invoke( |
| 411 | io.grpc.stub.StreamObserver<Resp> responseObserver) { |
| 412 | switch (methodId) { |
| 413 | case METHODID_STREAMING_INPUT_CALL: |
| 414 | return (io.grpc.stub.StreamObserver<Req>) serviceImpl.streamingInputCall( |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 415 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallResponse>) responseObserver); |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 416 | case METHODID_FULL_BIDI_CALL: |
| 417 | return (io.grpc.stub.StreamObserver<Req>) serviceImpl.fullBidiCall( |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 418 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse>) responseObserver); |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 419 | case METHODID_HALF_BIDI_CALL: |
| 420 | return (io.grpc.stub.StreamObserver<Req>) serviceImpl.halfBidiCall( |
Eric Anderson | b22bcdf | 2016-03-29 14:13:28 -0700 | [diff] [blame] | 421 | (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse>) responseObserver); |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 422 | default: |
| 423 | throw new AssertionError(); |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | |
Eric Anderson | 66ab956 | 2016-06-20 15:22:23 -0700 | [diff] [blame] | 428 | public static io.grpc.ServiceDescriptor getServiceDescriptor() { |
| 429 | return new io.grpc.ServiceDescriptor(SERVICE_NAME, |
| 430 | METHOD_UNARY_CALL, |
| 431 | METHOD_STREAMING_OUTPUT_CALL, |
| 432 | METHOD_STREAMING_INPUT_CALL, |
| 433 | METHOD_FULL_BIDI_CALL, |
| 434 | METHOD_HALF_BIDI_CALL); |
| 435 | } |
| 436 | |
Eric Anderson | 99a6d8d | 2016-03-22 11:31:36 -0700 | [diff] [blame] | 437 | } |