diff --git a/content/docs/quickstart/java.md b/content/docs/quickstart/java.md index d6b4a29..c63a457 100644 --- a/content/docs/quickstart/java.md +++ b/content/docs/quickstart/java.md @@ -21,9 +21,9 @@ clones the entire repository, but you just need the examples for this quickstart and other tutorials): ```sh -$ # Clone the repository at the latest release to get the example code: +# Clone the repository at the latest release to get the example code: $ git clone -b {{< param grpc_java_release_tag >}} https://github.com/grpc/grpc-java -$ # Navigate to the Java examples: +# Navigate to the Java examples: $ cd grpc-java/examples ``` @@ -31,23 +31,23 @@ $ cd grpc-java/examples From the `examples` directory: -1. Compile the client and server + 1. Compile the client and server - ```sh - $ ./gradlew installDist - ``` + ```sh + $ ./gradlew installDist + ``` -2. Run the server + 2. Run the server - ```sh - $ ./build/install/examples/bin/hello-world-server - ``` + ```sh + $ ./build/install/examples/bin/hello-world-server + ``` -3. In another terminal, run the client + 3. In another terminal, run the client - ```sh - $ ./build/install/examples/bin/hello-world-client - ``` + ```sh + $ ./build/install/examples/bin/hello-world-client + ``` Congratulations! You've just run a client-server application with gRPC. @@ -62,7 +62,7 @@ server and the client "stub" have a `SayHello` RPC method that takes a server, and that this method is defined like this: -```java +```protobuf // The greeting service definition. service Greeter { // Sends a greeting @@ -83,7 +83,7 @@ Let's update this so that the `Greeter` service has two methods. Edit `src/main/proto/helloworld.proto` and update it with a new `SayHelloAgain` method, with the same request and response types: -```java +```protobuf // The greeting service definition. service Greeter { // Sends a greeting @@ -138,7 +138,6 @@ private class GreeterImpl extends GreeterGrpc.GreeterImplBase { responseObserver.onCompleted(); } } -... ``` #### Update the client @@ -173,23 +172,23 @@ public void greet(String name) { Just like we did before, from the `examples` directory: -1. Compile the client and server + 1. Compile the client and server - ```sh - $ ./gradlew installDist - ``` + ```sh + $ ./gradlew installDist + ``` -2. Run the server + 2. Run the server - ```sh - $ ./build/install/examples/bin/hello-world-server - ``` + ```sh + $ ./build/install/examples/bin/hello-world-server + ``` -3. In another terminal, run the client + 3. In another terminal, run the client - ```sh - $ ./build/install/examples/bin/hello-world-client - ``` + ```sh + $ ./build/install/examples/bin/hello-world-client + ``` ### What's next diff --git a/content/docs/tutorials/basic/java.md b/content/docs/tutorials/basic/java.md index 83e2c18..5142788 100644 --- a/content/docs/tutorials/basic/java.md +++ b/content/docs/tutorials/basic/java.md @@ -65,7 +65,7 @@ define the gRPC *service* and the method *request* and *response* types using [protocol buffers](https://developers.google.com/protocol-buffers/docs/overview). You can see the complete .proto file in -[`grpc-java/examples/src/main/proto/route_guide.proto`](https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/route_guide.proto). +[grpc-java/examples/src/main/proto/route_guide.proto](https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/route_guide.proto). As we're generating Java code in this example, we've specified a `java_package` file option in our .proto: @@ -167,9 +167,8 @@ a special gRPC Java plugin. You need to use the both proto2 and proto3 syntax) in order to generate gRPC services. When using Gradle or Maven, the protoc build plugin can generate the necessary -code as part of the build. You can refer to the README for -how to generate code from your own .proto files. +code as part of the build. You can refer to the [grpc-java README][] for +how to generate code from your own `.proto` files. The following classes are generated from our service definition: @@ -214,7 +213,7 @@ private static class RouteGuideService extends RouteGuideGrpc.RouteGuideImplBase } ``` -#### Simple RPC +#### Simple RPC `RouteGuideService` implements all our service methods. Let's look at the simplest type first, `GetFeature`, which just gets a `Point` from @@ -300,6 +299,7 @@ RPC, we use the response observer's `onCompleted()` method to tell gRPC that we've finished writing responses. ##### Client-side streaming RPC + Now let's look at something a little more complicated: the client-side streaming method `RecordRoute`, where we get a stream of `Point`s from the client and return a single `RouteSummary` with information about their trip. @@ -675,10 +675,10 @@ for our client-streaming method. Although each side will always get the other's messages in the order they were written, both the client and server can read and write in any order — the streams operate completely independently. - ### Try it out! -Follow the instructions in the example directory -[README](https://github.com/grpc/grpc-java/blob/master/examples/README.md) to -build and run the client and server. +Follow the instructions in the [example directory README][] to build and run the +client and server. +[example directory README]: https://github.com/grpc/grpc-java/blob/master/examples/README.md +[grpc-java README]: https://github.com/grpc/grpc-java/blob/master/README.md