Updates generated code to reflect the proto changes in #19

This commit is contained in:
Tim Emiola 2015-02-18 17:22:46 -08:00
parent 813112ec42
commit e342471965
5 changed files with 75 additions and 75 deletions

View File

@ -13,150 +13,150 @@ import static com.google.net.stubby.stub.ServerCalls.asyncUnaryRequestCall;
import static com.google.net.stubby.stub.ServerCalls.asyncStreamingRequestCall; import static com.google.net.stubby.stub.ServerCalls.asyncStreamingRequestCall;
@javax.annotation.Generated("by gRPC proto compiler") @javax.annotation.Generated("by gRPC proto compiler")
public class GreetingsGrpc { public class GreeterGrpc {
private static final com.google.net.stubby.stub.Method<ex.grpc.Helloworld.HelloRequest, private static final com.google.net.stubby.stub.Method<ex.grpc.Helloworld.HelloRequest,
ex.grpc.Helloworld.HelloReply> METHOD_HELLO = ex.grpc.Helloworld.HelloReply> METHOD_SAY_HELLO =
com.google.net.stubby.stub.Method.create( com.google.net.stubby.stub.Method.create(
com.google.net.stubby.MethodType.UNARY, "hello", com.google.net.stubby.MethodType.UNARY, "sayHello",
com.google.net.stubby.proto.ProtoUtils.marshaller(ex.grpc.Helloworld.HelloRequest.PARSER), com.google.net.stubby.proto.ProtoUtils.marshaller(ex.grpc.Helloworld.HelloRequest.PARSER),
com.google.net.stubby.proto.ProtoUtils.marshaller(ex.grpc.Helloworld.HelloReply.PARSER)); com.google.net.stubby.proto.ProtoUtils.marshaller(ex.grpc.Helloworld.HelloReply.PARSER));
public static GreetingsStub newStub(com.google.net.stubby.Channel channel) { public static GreeterStub newStub(com.google.net.stubby.Channel channel) {
return new GreetingsStub(channel, CONFIG); return new GreeterStub(channel, CONFIG);
} }
public static GreetingsBlockingStub newBlockingStub( public static GreeterBlockingStub newBlockingStub(
com.google.net.stubby.Channel channel) { com.google.net.stubby.Channel channel) {
return new GreetingsBlockingStub(channel, CONFIG); return new GreeterBlockingStub(channel, CONFIG);
} }
public static GreetingsFutureStub newFutureStub( public static GreeterFutureStub newFutureStub(
com.google.net.stubby.Channel channel) { com.google.net.stubby.Channel channel) {
return new GreetingsFutureStub(channel, CONFIG); return new GreeterFutureStub(channel, CONFIG);
} }
public static final GreetingsServiceDescriptor CONFIG = public static final GreeterServiceDescriptor CONFIG =
new GreetingsServiceDescriptor(); new GreeterServiceDescriptor();
@javax.annotation.concurrent.Immutable @javax.annotation.concurrent.Immutable
public static class GreetingsServiceDescriptor extends public static class GreeterServiceDescriptor extends
com.google.net.stubby.stub.AbstractServiceDescriptor<GreetingsServiceDescriptor> { com.google.net.stubby.stub.AbstractServiceDescriptor<GreeterServiceDescriptor> {
public final com.google.net.stubby.MethodDescriptor<ex.grpc.Helloworld.HelloRequest, public final com.google.net.stubby.MethodDescriptor<ex.grpc.Helloworld.HelloRequest,
ex.grpc.Helloworld.HelloReply> hello; ex.grpc.Helloworld.HelloReply> sayHello;
private GreetingsServiceDescriptor() { private GreeterServiceDescriptor() {
hello = createMethodDescriptor( sayHello = createMethodDescriptor(
"helloworld.Greetings", METHOD_HELLO); "helloworld.Greeter", METHOD_SAY_HELLO);
} }
private GreetingsServiceDescriptor( private GreeterServiceDescriptor(
java.util.Map<java.lang.String, com.google.net.stubby.MethodDescriptor<?, ?>> methodMap) { java.util.Map<java.lang.String, com.google.net.stubby.MethodDescriptor<?, ?>> methodMap) {
hello = (com.google.net.stubby.MethodDescriptor<ex.grpc.Helloworld.HelloRequest, sayHello = (com.google.net.stubby.MethodDescriptor<ex.grpc.Helloworld.HelloRequest,
ex.grpc.Helloworld.HelloReply>) methodMap.get( ex.grpc.Helloworld.HelloReply>) methodMap.get(
CONFIG.hello.getName()); CONFIG.sayHello.getName());
} }
@java.lang.Override @java.lang.Override
protected GreetingsServiceDescriptor build( protected GreeterServiceDescriptor build(
java.util.Map<java.lang.String, com.google.net.stubby.MethodDescriptor<?, ?>> methodMap) { java.util.Map<java.lang.String, com.google.net.stubby.MethodDescriptor<?, ?>> methodMap) {
return new GreetingsServiceDescriptor(methodMap); return new GreeterServiceDescriptor(methodMap);
} }
@java.lang.Override @java.lang.Override
public com.google.common.collect.ImmutableList<com.google.net.stubby.MethodDescriptor<?, ?>> methods() { public com.google.common.collect.ImmutableList<com.google.net.stubby.MethodDescriptor<?, ?>> methods() {
return com.google.common.collect.ImmutableList.<com.google.net.stubby.MethodDescriptor<?, ?>>of( return com.google.common.collect.ImmutableList.<com.google.net.stubby.MethodDescriptor<?, ?>>of(
hello); sayHello);
} }
} }
public static interface Greetings { public static interface Greeter {
public void hello(ex.grpc.Helloworld.HelloRequest request, public void sayHello(ex.grpc.Helloworld.HelloRequest request,
com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver); com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver);
} }
public static interface GreetingsBlockingClient { public static interface GreeterBlockingClient {
public ex.grpc.Helloworld.HelloReply hello(ex.grpc.Helloworld.HelloRequest request); public ex.grpc.Helloworld.HelloReply sayHello(ex.grpc.Helloworld.HelloRequest request);
} }
public static interface GreetingsFutureClient { public static interface GreeterFutureClient {
public com.google.common.util.concurrent.ListenableFuture<ex.grpc.Helloworld.HelloReply> hello( public com.google.common.util.concurrent.ListenableFuture<ex.grpc.Helloworld.HelloReply> sayHello(
ex.grpc.Helloworld.HelloRequest request); ex.grpc.Helloworld.HelloRequest request);
} }
public static class GreetingsStub extends public static class GreeterStub extends
com.google.net.stubby.stub.AbstractStub<GreetingsStub, GreetingsServiceDescriptor> com.google.net.stubby.stub.AbstractStub<GreeterStub, GreeterServiceDescriptor>
implements Greetings { implements Greeter {
private GreetingsStub(com.google.net.stubby.Channel channel, private GreeterStub(com.google.net.stubby.Channel channel,
GreetingsServiceDescriptor config) { GreeterServiceDescriptor config) {
super(channel, config); super(channel, config);
} }
@java.lang.Override @java.lang.Override
protected GreetingsStub build(com.google.net.stubby.Channel channel, protected GreeterStub build(com.google.net.stubby.Channel channel,
GreetingsServiceDescriptor config) { GreeterServiceDescriptor config) {
return new GreetingsStub(channel, config); return new GreeterStub(channel, config);
} }
@java.lang.Override @java.lang.Override
public void hello(ex.grpc.Helloworld.HelloRequest request, public void sayHello(ex.grpc.Helloworld.HelloRequest request,
com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver) { com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver) {
asyncUnaryCall( asyncUnaryCall(
channel.newCall(config.hello), request, responseObserver); channel.newCall(config.sayHello), request, responseObserver);
} }
} }
public static class GreetingsBlockingStub extends public static class GreeterBlockingStub extends
com.google.net.stubby.stub.AbstractStub<GreetingsBlockingStub, GreetingsServiceDescriptor> com.google.net.stubby.stub.AbstractStub<GreeterBlockingStub, GreeterServiceDescriptor>
implements GreetingsBlockingClient { implements GreeterBlockingClient {
private GreetingsBlockingStub(com.google.net.stubby.Channel channel, private GreeterBlockingStub(com.google.net.stubby.Channel channel,
GreetingsServiceDescriptor config) { GreeterServiceDescriptor config) {
super(channel, config); super(channel, config);
} }
@java.lang.Override @java.lang.Override
protected GreetingsBlockingStub build(com.google.net.stubby.Channel channel, protected GreeterBlockingStub build(com.google.net.stubby.Channel channel,
GreetingsServiceDescriptor config) { GreeterServiceDescriptor config) {
return new GreetingsBlockingStub(channel, config); return new GreeterBlockingStub(channel, config);
} }
@java.lang.Override @java.lang.Override
public ex.grpc.Helloworld.HelloReply hello(ex.grpc.Helloworld.HelloRequest request) { public ex.grpc.Helloworld.HelloReply sayHello(ex.grpc.Helloworld.HelloRequest request) {
return blockingUnaryCall( return blockingUnaryCall(
channel.newCall(config.hello), request); channel.newCall(config.sayHello), request);
} }
} }
public static class GreetingsFutureStub extends public static class GreeterFutureStub extends
com.google.net.stubby.stub.AbstractStub<GreetingsFutureStub, GreetingsServiceDescriptor> com.google.net.stubby.stub.AbstractStub<GreeterFutureStub, GreeterServiceDescriptor>
implements GreetingsFutureClient { implements GreeterFutureClient {
private GreetingsFutureStub(com.google.net.stubby.Channel channel, private GreeterFutureStub(com.google.net.stubby.Channel channel,
GreetingsServiceDescriptor config) { GreeterServiceDescriptor config) {
super(channel, config); super(channel, config);
} }
@java.lang.Override @java.lang.Override
protected GreetingsFutureStub build(com.google.net.stubby.Channel channel, protected GreeterFutureStub build(com.google.net.stubby.Channel channel,
GreetingsServiceDescriptor config) { GreeterServiceDescriptor config) {
return new GreetingsFutureStub(channel, config); return new GreeterFutureStub(channel, config);
} }
@java.lang.Override @java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<ex.grpc.Helloworld.HelloReply> hello( public com.google.common.util.concurrent.ListenableFuture<ex.grpc.Helloworld.HelloReply> sayHello(
ex.grpc.Helloworld.HelloRequest request) { ex.grpc.Helloworld.HelloRequest request) {
return unaryFutureCall( return unaryFutureCall(
channel.newCall(config.hello), request); channel.newCall(config.sayHello), request);
} }
} }
public static com.google.net.stubby.ServerServiceDefinition bindService( public static com.google.net.stubby.ServerServiceDefinition bindService(
final Greetings serviceImpl) { final Greeter serviceImpl) {
return com.google.net.stubby.ServerServiceDefinition.builder("helloworld.Greetings") return com.google.net.stubby.ServerServiceDefinition.builder("helloworld.Greeter")
.addMethod(createMethodDefinition( .addMethod(createMethodDefinition(
METHOD_HELLO, METHOD_SAY_HELLO,
asyncUnaryRequestCall( asyncUnaryRequestCall(
new com.google.net.stubby.stub.ServerCalls.UnaryRequestMethod< new com.google.net.stubby.stub.ServerCalls.UnaryRequestMethod<
ex.grpc.Helloworld.HelloRequest, ex.grpc.Helloworld.HelloRequest,
@ -165,7 +165,7 @@ public class GreetingsGrpc {
public void invoke( public void invoke(
ex.grpc.Helloworld.HelloRequest request, ex.grpc.Helloworld.HelloRequest request,
com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver) { com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver) {
serviceImpl.hello(request, responseObserver); serviceImpl.sayHello(request, responseObserver);
} }
}))).build(); }))).build();
} }

View File

@ -2,10 +2,10 @@ package ex.grpc;
import com.google.net.stubby.stub.StreamObserver; import com.google.net.stubby.stub.StreamObserver;
public class GreetingsImpl implements GreetingsGrpc.Greetings { public class GreeterImpl implements GreeterGrpc.Greeter {
@Override @Override
public void hello(Helloworld.HelloRequest req, public void sayHello(Helloworld.HelloRequest req,
StreamObserver<Helloworld.HelloReply> responseObserver) { StreamObserver<Helloworld.HelloReply> responseObserver) {
Helloworld.HelloReply reply = Helloworld.HelloReply.newBuilder().setMessage( Helloworld.HelloReply reply = Helloworld.HelloReply.newBuilder().setMessage(
"Hello " + req.getName()).build(); "Hello " + req.getName()).build();

View File

@ -13,13 +13,13 @@ public class GreetingsClient {
private final Logger logger = Logger.getLogger( private final Logger logger = Logger.getLogger(
GreetingsClient.class.getName()); GreetingsClient.class.getName());
private final ChannelImpl channel; private final ChannelImpl channel;
private final GreetingsGrpc.GreetingsBlockingStub blockingStub; private final GreeterGrpc.GreeterBlockingStub blockingStub;
public GreetingsClient(String host, int port) { public GreetingsClient(String host, int port) {
channel = NettyChannelBuilder.forAddress(host, port) channel = NettyChannelBuilder.forAddress(host, port)
.negotiationType(NegotiationType.PLAINTEXT) .negotiationType(NegotiationType.PLAINTEXT)
.build(); .build();
blockingStub = GreetingsGrpc.newBlockingStub(channel); blockingStub = GreeterGrpc.newBlockingStub(channel);
} }
public void shutdown() throws InterruptedException { public void shutdown() throws InterruptedException {
@ -31,7 +31,7 @@ public class GreetingsClient {
logger.fine("Will try to greet " + name + " ..."); logger.fine("Will try to greet " + name + " ...");
Helloworld.HelloRequest req = Helloworld.HelloRequest req =
Helloworld.HelloRequest.newBuilder().setName(name).build(); Helloworld.HelloRequest.newBuilder().setName(name).build();
Helloworld.HelloReply reply = blockingStub.hello(req); Helloworld.HelloReply reply = blockingStub.sayHello(req);
logger.info("Greeting: " + reply.getMessage()); logger.info("Greeting: " + reply.getMessage());
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.log(Level.WARNING, "RPC failed", e); logger.log(Level.WARNING, "RPC failed", e);

View File

@ -16,7 +16,7 @@ public class GreetingsServer {
private void start() throws Exception { private void start() throws Exception {
server = NettyServerBuilder.forPort(port) server = NettyServerBuilder.forPort(port)
.addService(GreetingsGrpc.bindService(new GreetingsImpl())) .addService(GreeterGrpc.bindService(new GreeterImpl()))
.build(); .build();
server.startAsync(); server.startAsync();
server.awaitRunning(5, TimeUnit.SECONDS); server.awaitRunning(5, TimeUnit.SECONDS);

View File

@ -1,5 +1,5 @@
// Generated by the protocol buffer compiler. DO NOT EDIT! // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: src/main/proto/helloworld.proto // source: helloworld.proto
package ex.grpc; package ex.grpc;
@ -915,11 +915,11 @@ public final class Helloworld {
descriptor; descriptor;
static { static {
java.lang.String[] descriptorData = { java.lang.String[] descriptorData = {
"\n\037src/main/proto/helloworld.proto\022\nhello" + "\n\020helloworld.proto\022\nhelloworld\"\034\n\014HelloR" +
"world\"\034\n\014HelloRequest\022\014\n\004name\030\001 \001(\t\"\035\n\nH" + "equest\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n\007me" +
"elloReply\022\017\n\007message\030\001 \001(\t2H\n\tGreetings\022" + "ssage\030\001 \001(\t2I\n\007Greeter\022>\n\010sayHello\022\030.hel" +
";\n\005hello\022\030.helloworld.HelloRequest\032\026.hel" + "loworld.HelloRequest\032\026.helloworld.HelloR" +
"loworld.HelloReply\"\000B\t\n\007ex.grpcb\006proto3" "eply\"\000B\t\n\007ex.grpcb\006proto3"
}; };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {