Skip to content

Commit 690b26e

Browse files
committed
Sanitize ClientCalls.
- Remove blockingClientStreamingCall() which is not used, and we don't actually want that API. - Rename duplexStreamingCall() to asyncDuplexStreamingCall() to align with other async methods. - In unary call and client streaming call, do not request for additional response after the first response.
1 parent 79f3f02 commit 690b26e

File tree

10 files changed

+103
-111
lines changed

10 files changed

+103
-111
lines changed

benchmarks/src/generated/main/grpc/io/grpc/testing/TestServiceGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
44
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
55
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6-
import static io.grpc.stub.ClientCalls.duplexStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
77
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
88
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
99
import static io.grpc.stub.ClientCalls.unaryFutureCall;
@@ -139,7 +139,7 @@ public void unaryCall(io.grpc.testing.SimpleRequest request,
139139
@java.lang.Override
140140
public io.grpc.stub.StreamObserver<io.grpc.testing.SimpleRequest> streamingCall(
141141
io.grpc.stub.StreamObserver<io.grpc.testing.SimpleResponse> responseObserver) {
142-
return duplexStreamingCall(
142+
return asyncDuplexStreamingCall(
143143
channel.newCall(config.streamingCall, callOptions), responseObserver);
144144
}
145145
}

benchmarks/src/generated/main/grpc/io/grpc/testing/WorkerGrpc.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
44
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
55
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6-
import static io.grpc.stub.ClientCalls.duplexStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
77
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
88
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
99
import static io.grpc.stub.ClientCalls.unaryFutureCall;
@@ -127,14 +127,14 @@ protected WorkerStub build(io.grpc.Channel channel,
127127
@java.lang.Override
128128
public io.grpc.stub.StreamObserver<io.grpc.testing.ClientArgs> runTest(
129129
io.grpc.stub.StreamObserver<io.grpc.testing.ClientStatus> responseObserver) {
130-
return duplexStreamingCall(
130+
return asyncDuplexStreamingCall(
131131
channel.newCall(config.runTest, callOptions), responseObserver);
132132
}
133133

134134
@java.lang.Override
135135
public io.grpc.stub.StreamObserver<io.grpc.testing.ServerArgs> runServer(
136136
io.grpc.stub.StreamObserver<io.grpc.testing.ServerStatus> responseObserver) {
137-
return duplexStreamingCall(
137+
return asyncDuplexStreamingCall(
138138
channel.newCall(config.runServer, callOptions), responseObserver);
139139
}
140140
}

benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ protected void startStreamingCalls(int callsPerChannel,
408408
channel.newCall(pingPongMethod, CALL_OPTIONS);
409409
final AtomicReference<StreamObserver<ByteBuf>> requestObserverRef =
410410
new AtomicReference<StreamObserver<ByteBuf>>();
411-
StreamObserver<ByteBuf> requestObserver = ClientCalls.duplexStreamingCall(streamingCall,
411+
StreamObserver<ByteBuf> requestObserver = ClientCalls.asyncDuplexStreamingCall(
412+
streamingCall,
412413
new StreamObserver<ByteBuf>() {
413414
@Override
414415
public void onValue(ByteBuf value) {
@@ -452,7 +453,8 @@ protected void startFlowControlledStreamingCalls(int callsPerChannel,
452453
channel.newCall(flowControlledStreaming, CALL_OPTIONS);
453454
final AtomicReference<StreamObserver<ByteBuf>> requestObserverRef =
454455
new AtomicReference<StreamObserver<ByteBuf>>();
455-
StreamObserver<ByteBuf> requestObserver = ClientCalls.duplexStreamingCall(streamingCall,
456+
StreamObserver<ByteBuf> requestObserver = ClientCalls.asyncDuplexStreamingCall(
457+
streamingCall,
456458
new StreamObserver<ByteBuf>() {
457459
@Override
458460
public void onValue(ByteBuf value) {

compiler/src/java_plugin/cpp/java_generator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static void PrintStub(const google::protobuf::ServiceDescriptor* service,
449449
case ASYNC_CALL:
450450
if (server_streaming) {
451451
if (client_streaming) {
452-
(*vars)["calls_method"] = "duplexStreamingCall";
452+
(*vars)["calls_method"] = "asyncDuplexStreamingCall";
453453
(*vars)["params"] = "responseObserver";
454454
} else {
455455
(*vars)["calls_method"] = "asyncServerStreamingCall";
@@ -652,7 +652,7 @@ void PrintImports(Printer* p, bool generate_nano) {
652652
"import static "
653653
"io.grpc.stub.ClientCalls.asyncClientStreamingCall;\n"
654654
"import static "
655-
"io.grpc.stub.ClientCalls.duplexStreamingCall;\n"
655+
"io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;\n"
656656
"import static "
657657
"io.grpc.stub.ClientCalls.blockingUnaryCall;\n"
658658
"import static "

compiler/src/test/golden/TestService.java.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.grpc.testing.integration;
33
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
44
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
55
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6-
import static io.grpc.stub.ClientCalls.duplexStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
77
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
88
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
99
import static io.grpc.stub.ClientCalls.unaryFutureCall;
@@ -210,14 +210,14 @@ public class TestServiceGrpc {
210210
@java.lang.Override
211211
public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> fullDuplexCall(
212212
io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
213-
return duplexStreamingCall(
213+
return asyncDuplexStreamingCall(
214214
channel.newCall(config.fullDuplexCall, callOptions), responseObserver);
215215
}
216216

217217
@java.lang.Override
218218
public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> halfDuplexCall(
219219
io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
220-
return duplexStreamingCall(
220+
return asyncDuplexStreamingCall(
221221
channel.newCall(config.halfDuplexCall, callOptions), responseObserver);
222222
}
223223
}

compiler/src/test/golden/TestServiceNano.java.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.grpc.testing.integration;
33
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
44
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
55
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6-
import static io.grpc.stub.ClientCalls.duplexStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
77
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
88
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
99
import static io.grpc.stub.ClientCalls.unaryFutureCall;
@@ -272,14 +272,14 @@ public class TestServiceGrpc {
272272
@java.lang.Override
273273
public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> fullDuplexCall(
274274
io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
275-
return duplexStreamingCall(
275+
return asyncDuplexStreamingCall(
276276
channel.newCall(config.fullDuplexCall, callOptions), responseObserver);
277277
}
278278

279279
@java.lang.Override
280280
public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> halfDuplexCall(
281281
io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
282-
return duplexStreamingCall(
282+
return asyncDuplexStreamingCall(
283283
channel.newCall(config.halfDuplexCall, callOptions), responseObserver);
284284
}
285285
}

examples/src/generated/main/grpc/io/grpc/examples/helloworld/GreeterGrpc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
44
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
55
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6-
import static io.grpc.stub.ClientCalls.duplexStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
77
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
88
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
99
import static io.grpc.stub.ClientCalls.unaryFutureCall;

examples/src/generated/main/grpc/io/grpc/examples/routeguide/RouteGuideGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
44
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
55
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6-
import static io.grpc.stub.ClientCalls.duplexStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
77
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
88
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
99
import static io.grpc.stub.ClientCalls.unaryFutureCall;
@@ -192,7 +192,7 @@ public io.grpc.stub.StreamObserver<io.grpc.examples.routeguide.Point> recordRout
192192
@java.lang.Override
193193
public io.grpc.stub.StreamObserver<io.grpc.examples.routeguide.RouteNote> routeChat(
194194
io.grpc.stub.StreamObserver<io.grpc.examples.routeguide.RouteNote> responseObserver) {
195-
return duplexStreamingCall(
195+
return asyncDuplexStreamingCall(
196196
channel.newCall(config.routeChat, callOptions), responseObserver);
197197
}
198198
}

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/TestServiceGrpc.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
44
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
55
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6-
import static io.grpc.stub.ClientCalls.duplexStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
77
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
88
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
99
import static io.grpc.stub.ClientCalls.unaryFutureCall;
@@ -240,14 +240,14 @@ public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Messages.Streamin
240240
@java.lang.Override
241241
public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Messages.StreamingOutputCallRequest> fullDuplexCall(
242242
io.grpc.stub.StreamObserver<io.grpc.testing.integration.Messages.StreamingOutputCallResponse> responseObserver) {
243-
return duplexStreamingCall(
243+
return asyncDuplexStreamingCall(
244244
channel.newCall(config.fullDuplexCall, callOptions), responseObserver);
245245
}
246246

247247
@java.lang.Override
248248
public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Messages.StreamingOutputCallRequest> halfDuplexCall(
249249
io.grpc.stub.StreamObserver<io.grpc.testing.integration.Messages.StreamingOutputCallResponse> responseObserver) {
250-
return duplexStreamingCall(
250+
return asyncDuplexStreamingCall(
251251
channel.newCall(config.halfDuplexCall, callOptions), responseObserver);
252252
}
253253
}

0 commit comments

Comments
 (0)