Rename unaryFutureCall to futureUnaryCall

This commit is contained in:
Kun Zhang 2015-07-16 12:34:37 -07:00
parent 690b26eb93
commit 686dcff217
10 changed files with 21 additions and 21 deletions

View File

@ -6,7 +6,7 @@ import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall; import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall; import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
@ -196,7 +196,7 @@ public class TestServiceGrpc {
@java.lang.Override @java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.SimpleResponse> unaryCall( public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.SimpleResponse> unaryCall(
io.grpc.testing.SimpleRequest request) { io.grpc.testing.SimpleRequest request) {
return unaryFutureCall( return futureUnaryCall(
channel.newCall(config.unaryCall, callOptions), request); channel.newCall(config.unaryCall, callOptions), request);
} }
} }

View File

@ -6,7 +6,7 @@ import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall; import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall; import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;

View File

@ -475,7 +475,7 @@ static void PrintStub(const google::protobuf::ServiceDescriptor* service,
<< "Future interface doesn't support streaming. " << "Future interface doesn't support streaming. "
<< "client_streaming=" << client_streaming << ", " << "client_streaming=" << client_streaming << ", "
<< "server_streaming=" << server_streaming; << "server_streaming=" << server_streaming;
(*vars)["calls_method"] = "unaryFutureCall"; (*vars)["calls_method"] = "futureUnaryCall";
p->Print( p->Print(
*vars, *vars,
"return $calls_method$(\n" "return $calls_method$(\n"
@ -658,7 +658,7 @@ void PrintImports(Printer* p, bool generate_nano) {
"import static " "import static "
"io.grpc.stub.ClientCalls.blockingServerStreamingCall;\n" "io.grpc.stub.ClientCalls.blockingServerStreamingCall;\n"
"import static " "import static "
"io.grpc.stub.ClientCalls.unaryFutureCall;\n" "io.grpc.stub.ClientCalls.futureUnaryCall;\n"
"import static " "import static "
"io.grpc.stub.ServerCalls.asyncUnaryCall;\n" "io.grpc.stub.ServerCalls.asyncUnaryCall;\n"
"import static " "import static "

View File

@ -6,7 +6,7 @@ import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall; import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall; import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
@ -281,7 +281,7 @@ public class TestServiceGrpc {
@java.lang.Override @java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Test.SimpleResponse> unaryCall( public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Test.SimpleResponse> unaryCall(
io.grpc.testing.integration.Test.SimpleRequest request) { io.grpc.testing.integration.Test.SimpleRequest request) {
return unaryFutureCall( return futureUnaryCall(
channel.newCall(config.unaryCall, callOptions), request); channel.newCall(config.unaryCall, callOptions), request);
} }
} }

View File

@ -6,7 +6,7 @@ import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall; import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall; import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
@ -343,7 +343,7 @@ public class TestServiceGrpc {
@java.lang.Override @java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Test.SimpleResponse> unaryCall( public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Test.SimpleResponse> unaryCall(
io.grpc.testing.integration.Test.SimpleRequest request) { io.grpc.testing.integration.Test.SimpleRequest request) {
return unaryFutureCall( return futureUnaryCall(
channel.newCall(config.unaryCall, callOptions), request); channel.newCall(config.unaryCall, callOptions), request);
} }
} }

View File

@ -6,7 +6,7 @@ import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall; import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall; import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
@ -171,7 +171,7 @@ public class GreeterGrpc {
@java.lang.Override @java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.helloworld.HelloResponse> sayHello( public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.helloworld.HelloResponse> sayHello(
io.grpc.examples.helloworld.HelloRequest request) { io.grpc.examples.helloworld.HelloRequest request) {
return unaryFutureCall( return futureUnaryCall(
channel.newCall(config.sayHello, callOptions), request); channel.newCall(config.sayHello, callOptions), request);
} }
} }

View File

@ -6,7 +6,7 @@ import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall; import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall; import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
@ -256,7 +256,7 @@ public class RouteGuideGrpc {
@java.lang.Override @java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.routeguide.Feature> getFeature( public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.routeguide.Feature> getFeature(
io.grpc.examples.routeguide.Point request) { io.grpc.examples.routeguide.Point request) {
return unaryFutureCall( return futureUnaryCall(
channel.newCall(config.getFeature, callOptions), request); channel.newCall(config.getFeature, callOptions), request);
} }
} }

View File

@ -6,7 +6,7 @@ import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall; import static io.grpc.stub.ClientCalls.asyncDuplexStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall; import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
@ -317,14 +317,14 @@ public class TestServiceGrpc {
@java.lang.Override @java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.EmptyProtos.Empty> emptyCall( public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.EmptyProtos.Empty> emptyCall(
com.google.protobuf.EmptyProtos.Empty request) { com.google.protobuf.EmptyProtos.Empty request) {
return unaryFutureCall( return futureUnaryCall(
channel.newCall(config.emptyCall, callOptions), request); channel.newCall(config.emptyCall, callOptions), request);
} }
@java.lang.Override @java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Messages.SimpleResponse> unaryCall( public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Messages.SimpleResponse> unaryCall(
io.grpc.testing.integration.Messages.SimpleRequest request) { io.grpc.testing.integration.Messages.SimpleRequest request) {
return unaryFutureCall( return futureUnaryCall(
channel.newCall(config.unaryCall, callOptions), request); channel.newCall(config.unaryCall, callOptions), request);
} }
} }

View File

@ -101,7 +101,7 @@ public class ClientCalls {
*/ */
public static <ReqT, RespT> RespT blockingUnaryCall(ClientCall<ReqT, RespT> call, ReqT param) { public static <ReqT, RespT> RespT blockingUnaryCall(ClientCall<ReqT, RespT> call, ReqT param) {
try { try {
return getUnchecked(unaryFutureCall(call, param)); return getUnchecked(futureUnaryCall(call, param));
} catch (Throwable t) { } catch (Throwable t) {
call.cancel(); call.cancel();
throw Throwables.propagate(t); throw Throwables.propagate(t);
@ -126,7 +126,7 @@ public class ClientCalls {
* *
* @return a future for the single response message. * @return a future for the single response message.
*/ */
public static <ReqT, RespT> ListenableFuture<RespT> unaryFutureCall( public static <ReqT, RespT> ListenableFuture<RespT> futureUnaryCall(
ClientCall<ReqT, RespT> call, ClientCall<ReqT, RespT> call,
ReqT param) { ReqT param) {
GrpcFuture<RespT> responseFuture = new GrpcFuture<RespT>(call); GrpcFuture<RespT> responseFuture = new GrpcFuture<RespT>(call);

View File

@ -67,7 +67,7 @@ public class ClientCallsTest {
@Test public void unaryFutureCallSuccess() throws Exception { @Test public void unaryFutureCallSuccess() throws Exception {
Integer req = 2; Integer req = 2;
ListenableFuture<String> future = ClientCalls.unaryFutureCall(call, req); ListenableFuture<String> future = ClientCalls.futureUnaryCall(call, req);
ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null); ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class)); verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class));
ClientCall.Listener<String> listener = listenerCaptor.getValue(); ClientCall.Listener<String> listener = listenerCaptor.getValue();
@ -80,7 +80,7 @@ public class ClientCallsTest {
@Test public void unaryFutureCallFailed() throws Exception { @Test public void unaryFutureCallFailed() throws Exception {
Integer req = 2; Integer req = 2;
ListenableFuture<String> future = ClientCalls.unaryFutureCall(call, req); ListenableFuture<String> future = ClientCalls.futureUnaryCall(call, req);
ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null); ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class)); verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class));
ClientCall.Listener<String> listener = listenerCaptor.getValue(); ClientCall.Listener<String> listener = listenerCaptor.getValue();
@ -96,7 +96,7 @@ public class ClientCallsTest {
@Test public void unaryFutureCallCancelled() throws Exception { @Test public void unaryFutureCallCancelled() throws Exception {
Integer req = 2; Integer req = 2;
ListenableFuture<String> future = ClientCalls.unaryFutureCall(call, req); ListenableFuture<String> future = ClientCalls.futureUnaryCall(call, req);
ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null); ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class)); verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class));
ClientCall.Listener<String> listener = listenerCaptor.getValue(); ClientCall.Listener<String> listener = listenerCaptor.getValue();