diff --git a/examples/build.gradle b/examples/build.gradle index 87c722e2a7..fddfda58e1 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -24,25 +24,25 @@ protobufCodeGenPlugins = ["java_plugin:$rootDir/compiler/build/binaries/java_plu generateProto.dependsOn ':grpc-compiler:java_pluginExecutable' task routeGuideServer(type: JavaExec) { - main = "io.grpc.examples.RouteGuideServer" + main = "io.grpc.examples.routeguide.RouteGuideServer" description = "Executes the route guide server." classpath = sourceSets.main.runtimeClasspath } task routeGuideClient(type: JavaExec) { - main = "io.grpc.examples.RouteGuideClient" + main = "io.grpc.examples.routeguide.RouteGuideClient" description = "Executes the route guide client." classpath = sourceSets.main.runtimeClasspath } task helloWorldServer(type: JavaExec) { - main = "io.grpc.examples.HelloWorldServer" + main = "io.grpc.examples.helloworld.HelloWorldServer" description = "Executes the hello world server." classpath = sourceSets.main.runtimeClasspath } task helloWorldClient(type: JavaExec) { - main = "io.grpc.examples.HelloWorldClient" + main = "io.grpc.examples.helloworld.HelloWorldClient" description = "Executes the hello world client." classpath = sourceSets.main.runtimeClasspath } \ No newline at end of file diff --git a/examples/src/main/java/io/grpc/examples/HelloWorldClient.java b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java similarity index 83% rename from examples/src/main/java/io/grpc/examples/HelloWorldClient.java rename to examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java index a887801284..eddf24448d 100644 --- a/examples/src/main/java/io/grpc/examples/HelloWorldClient.java +++ b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java @@ -1,8 +1,6 @@ -package io.grpc.examples; +package io.grpc.examples.helloworld; import io.grpc.ChannelImpl; -import io.grpc.examples.Helloworld.HelloReply; -import io.grpc.examples.Helloworld.HelloRequest; import io.grpc.transport.netty.NegotiationType; import io.grpc.transport.netty.NettyChannelBuilder; @@ -33,9 +31,9 @@ public class HelloWorldClient { public void greet(String name) { try { logger.info("Will try to greet " + name + " ..."); - HelloRequest req = HelloRequest.newBuilder().setName(name).build(); - HelloReply reply = blockingStub.sayHello(req); - logger.info("Greeting: " + reply.getMessage()); + HelloRequest request = HelloRequest.newBuilder().setName(name).build(); + HelloResponse response = blockingStub.sayHello(request); + logger.info("Greeting: " + response.getMessage()); } catch (RuntimeException e) { logger.log(Level.WARNING, "RPC failed", e); return; diff --git a/examples/src/main/java/io/grpc/examples/HelloWorldServer.java b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java similarity index 86% rename from examples/src/main/java/io/grpc/examples/HelloWorldServer.java rename to examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java index 68d8f9ecce..393afdfb8e 100644 --- a/examples/src/main/java/io/grpc/examples/HelloWorldServer.java +++ b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java @@ -1,8 +1,6 @@ -package io.grpc.examples; +package io.grpc.examples.helloworld; import io.grpc.ServerImpl; -import io.grpc.examples.Helloworld.HelloReply; -import io.grpc.examples.Helloworld.HelloRequest; import io.grpc.stub.StreamObserver; import io.grpc.transport.netty.NettyServerBuilder; @@ -51,8 +49,8 @@ public class HelloWorldServer { private class GreeterImpl implements GreeterGrpc.Greeter { @Override - public void sayHello(HelloRequest req, StreamObserver responseObserver) { - HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + req.getName()).build(); + public void sayHello(HelloRequest req, StreamObserver responseObserver) { + HelloResponse reply = HelloResponse.newBuilder().setMessage("Hello " + req.getName()).build(); responseObserver.onValue(reply); responseObserver.onCompleted(); } diff --git a/examples/src/main/java/io/grpc/examples/RouteGuideClient.java b/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java similarity index 95% rename from examples/src/main/java/io/grpc/examples/RouteGuideClient.java rename to examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java index acd0642361..b412e607cd 100644 --- a/examples/src/main/java/io/grpc/examples/RouteGuideClient.java +++ b/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java @@ -29,18 +29,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.grpc.examples; +package io.grpc.examples.routeguide; import com.google.common.util.concurrent.SettableFuture; import io.grpc.ChannelImpl; -import io.grpc.examples.RouteGuideGrpc.RouteGuideBlockingStub; -import io.grpc.examples.RouteGuideGrpc.RouteGuideStub; -import io.grpc.examples.RouteGuideOuterClass.Feature; -import io.grpc.examples.RouteGuideOuterClass.Point; -import io.grpc.examples.RouteGuideOuterClass.Rectangle; -import io.grpc.examples.RouteGuideOuterClass.RouteNote; -import io.grpc.examples.RouteGuideOuterClass.RouteSummary; +import io.grpc.examples.routeguide.RouteGuideGrpc.RouteGuideBlockingStub; +import io.grpc.examples.routeguide.RouteGuideGrpc.RouteGuideStub; import io.grpc.stub.StreamObserver; import io.grpc.transport.netty.NegotiationType; import io.grpc.transport.netty.NettyChannelBuilder; diff --git a/examples/src/main/java/io/grpc/examples/RouteGuideServer.java b/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideServer.java similarity index 97% rename from examples/src/main/java/io/grpc/examples/RouteGuideServer.java rename to examples/src/main/java/io/grpc/examples/routeguide/RouteGuideServer.java index 2527b4693a..db457fd705 100644 --- a/examples/src/main/java/io/grpc/examples/RouteGuideServer.java +++ b/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideServer.java @@ -29,7 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.grpc.examples; +package io.grpc.examples.routeguide; import static java.lang.Math.atan2; import static java.lang.Math.cos; @@ -41,11 +41,6 @@ import static java.lang.Math.toRadians; import static java.util.concurrent.TimeUnit.NANOSECONDS; import io.grpc.ServerImpl; -import io.grpc.examples.RouteGuideOuterClass.Feature; -import io.grpc.examples.RouteGuideOuterClass.Point; -import io.grpc.examples.RouteGuideOuterClass.Rectangle; -import io.grpc.examples.RouteGuideOuterClass.RouteNote; -import io.grpc.examples.RouteGuideOuterClass.RouteSummary; import io.grpc.stub.StreamObserver; import io.grpc.transport.netty.NettyServerBuilder; diff --git a/examples/src/main/java/io/grpc/examples/RouteGuideUtil.java b/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideUtil.java similarity index 96% rename from examples/src/main/java/io/grpc/examples/RouteGuideUtil.java rename to examples/src/main/java/io/grpc/examples/routeguide/RouteGuideUtil.java index 5e4680b9c2..65d8700dea 100644 --- a/examples/src/main/java/io/grpc/examples/RouteGuideUtil.java +++ b/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideUtil.java @@ -29,10 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.grpc.examples; - -import io.grpc.examples.RouteGuideOuterClass.Feature; -import io.grpc.examples.RouteGuideOuterClass.Point; +package io.grpc.examples.routeguide; import java.io.IOException; import java.io.InputStream; diff --git a/examples/src/main/proto/helloworld.proto b/examples/src/main/proto/greeter.proto similarity index 89% rename from examples/src/main/proto/helloworld.proto rename to examples/src/main/proto/greeter.proto index a09fdfd91f..92a990976d 100644 --- a/examples/src/main/proto/helloworld.proto +++ b/examples/src/main/proto/greeter.proto @@ -29,14 +29,15 @@ syntax = "proto3"; -option java_package = "io.grpc.examples"; +package grpc.example.helloworld; -package helloworld; +option java_multiple_files = true; +option java_package = "io.grpc.examples.helloworld"; // The greeting service definition. service Greeter { // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} + rpc SayHello (HelloRequest) returns (HelloResponse) {} } // The request message containing the user's name. @@ -45,6 +46,6 @@ message HelloRequest { } // The response message containing the greetings -message HelloReply { +message HelloResponse { string message = 1; } \ No newline at end of file diff --git a/examples/src/main/proto/route_guide.proto b/examples/src/main/proto/route_guide.proto index 8c975d72d0..44b4ca73c2 100644 --- a/examples/src/main/proto/route_guide.proto +++ b/examples/src/main/proto/route_guide.proto @@ -29,9 +29,10 @@ syntax = "proto3"; -option java_package = "io.grpc.examples"; +package grpc.example.routeguide; -package examples; +option java_multiple_files = true; +option java_package = "io.grpc.examples.routeguide"; // Interface exported by the server. service RouteGuide { @@ -66,18 +67,18 @@ service RouteGuide { // Latitudes should be in the range +/- 90 degrees and longitude should be in // the range +/- 180 degrees (inclusive). message Point { - optional int32 latitude = 1; - optional int32 longitude = 2; + int32 latitude = 1; + int32 longitude = 2; } // A latitude-longitude rectangle, represented as two diagonally opposite // points "lo" and "hi". message Rectangle { // One corner of the rectangle. - optional Point lo = 1; + Point lo = 1; // The other corner of the rectangle. - optional Point hi = 2; + Point hi = 2; } // A feature names something at a given point. @@ -85,19 +86,19 @@ message Rectangle { // If a feature could not be named, the name is empty. message Feature { // The name of the feature. - optional string name = 1; + string name = 1; // The point where the feature is detected. - optional Point location = 2; + Point location = 2; } // A RouteNote is a message sent while at a given point. message RouteNote { // The location from which the message is sent. - optional Point location = 1; + Point location = 1; // The message to be sent. - optional string message = 2; + string message = 2; } // A RouteSummary is received in response to a RecordRoute rpc. @@ -107,14 +108,14 @@ message RouteNote { // the distance between each point. message RouteSummary { // The number of points received. - optional int32 point_count = 1; + int32 point_count = 1; // The number of known features passed while traversing the route. - optional int32 feature_count = 2; + int32 feature_count = 2; // The distance covered in metres. - optional int32 distance = 3; + int32 distance = 3; // The duration of the traversal in seconds. - optional int32 elapsed_time = 4; + int32 elapsed_time = 4; } \ No newline at end of file diff --git a/examples/src/main/resources/io/grpc/examples/route_guide_db.json b/examples/src/main/resources/io/grpc/examples/routeguide/route_guide_db.json similarity index 100% rename from examples/src/main/resources/io/grpc/examples/route_guide_db.json rename to examples/src/main/resources/io/grpc/examples/routeguide/route_guide_db.json