From 00e23cfd2a6f70a17ebaafebdd0eaf62533c1fa1 Mon Sep 17 00:00:00 2001 From: Jayant Kolhe Date: Wed, 4 Feb 2015 09:44:55 -0800 Subject: [PATCH 01/13] Update Step_0.md --- Step_0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Step_0.md b/Step_0.md index 3fec8376d1a..1a2dbcb2fe5 100644 --- a/Step_0.md +++ b/Step_0.md @@ -37,5 +37,5 @@ The service stanza of the message is an example of protobuf service IDL receives a request containing a name and returns a response containing a message. -Next, in [Step-1](Step-1.md), we'll use protoc to generate client code from +Next, in [Step_1](Step_1.md), we'll use protoc to generate client code from this IDL. From b9c24a11dd66a89ed9ce4f4ff4c93f22e46ffc1c Mon Sep 17 00:00:00 2001 From: Jayant Kolhe Date: Wed, 4 Feb 2015 09:46:09 -0800 Subject: [PATCH 02/13] Update Step_0.md --- Step_0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Step_0.md b/Step_0.md index 1a2dbcb2fe5..02a2b04c0e3 100644 --- a/Step_0.md +++ b/Step_0.md @@ -37,5 +37,5 @@ The service stanza of the message is an example of protobuf service IDL receives a request containing a name and returns a response containing a message. -Next, in [Step_1](Step_1.md), we'll use protoc to generate client code from +Next, in [Step - 1](Step_1.md), we'll use protoc to generate client code from this IDL. From 15dd5da9f5a1cd6783ae9640ebfe02efbdcfedbc Mon Sep 17 00:00:00 2001 From: Jayant Kolhe Date: Wed, 4 Feb 2015 09:56:29 -0800 Subject: [PATCH 03/13] Update Step_1.md --- Step_1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Step_1.md b/Step_1.md index 4ac68aba5df..da85cb4e10f 100644 --- a/Step_1.md +++ b/Step_1.md @@ -29,5 +29,5 @@ $ protoc -I . helloworld.proto --plugin=protoc-gen-grpc=external/grpc_java/bins/ --java_out=src/main/java ``` -Next, in [Step-2](Step-2.md), we'll use the generated Stub implementation to +Next, in [Step - 2](Step_2.md), we'll use the generated Stub implementation to write a client that uses the generated code to make a call to a service. From 5a92194fb0c3fb6936b8144f98853f0b9a234a0f Mon Sep 17 00:00:00 2001 From: Jayant Kolhe Date: Wed, 4 Feb 2015 09:57:40 -0800 Subject: [PATCH 04/13] Update Step_2.md --- Step_2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Step_2.md b/Step_2.md index dd134a989c5..32c578f18a9 100644 --- a/Step_2.md +++ b/Step_2.md @@ -72,7 +72,7 @@ $ mvn package ``` It can also be run, but doing so now would end up a with a failure as there is -no server available yet. The [next step](Step-3.md), describes how to +no server available yet. The [next step](Step_3.md), describes how to implement, build and run a server that supports the service description. ## Notes From 99a1fe644087da862af2287c452b38b7fd4f1b9c Mon Sep 17 00:00:00 2001 From: Dan Ciruli Date: Wed, 4 Feb 2015 10:07:45 -0800 Subject: [PATCH 05/13] Fixed 2 typos. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a668f3b1cd..c0fc227b29b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gRPC Helloworld Tutorial +# gRPC Hello World Tutorial ## TODO: move this to the tutorial sub-folder @@ -8,7 +8,7 @@ various features of gRPC. When you finish the tutorial, you will be able to -- Create an protobuf schema that defines a simple RPC service +- Create a protobuf schema that defines a simple RPC service - Create a Java server that implements the schema interface - Create a Java client that accesses the server - Create a Go client that accesses the Java server From cdf7f84d073ef17da2b73de53cdcc0164368e109 Mon Sep 17 00:00:00 2001 From: Mugur Marculescu Date: Wed, 4 Feb 2015 20:14:08 -0800 Subject: [PATCH 06/13] Attempt to Fix broken link to helloworld.proto Actually Fix broken link to helloworld.proto --- Step_0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Step_0.md b/Step_0.md index 02a2b04c0e3..a346f77e814 100644 --- a/Step_0.md +++ b/Step_0.md @@ -5,7 +5,7 @@ a message from a remote client. The message contains the users's name and sends back a greeting to that person. It's shown below in full; it's actually contained in separate file -[helloworld.proto](helloworld.proto). +[helloworld.proto](src/main/proto/helloworld.proto). ``` syntax = "proto3"; From 5d8c3b264c89fb1598e4cc418e2c0c4c417d5c4b Mon Sep 17 00:00:00 2001 From: Mugur Marculescu Date: Wed, 4 Feb 2015 21:21:37 -0800 Subject: [PATCH 07/13] Fixing a couple of typos and grammer issues. --- README.md | 18 +++++++++--------- Step_0.md | 6 +++--- Step_1.md | 4 ++-- Step_2.md | 10 +++++----- Step_3.md | 16 ++++++++-------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index c0fc227b29b..41b79ba883d 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,16 @@ ## TODO: move this to the tutorial sub-folder A great way to get introduced to gRPC is to work through this tutorial, which -walks you through the construction of simple client and server that introduces +walks you through the construction of a simple client and server and introduces various features of gRPC. When you finish the tutorial, you will be able to -- Create a protobuf schema that defines a simple RPC service -- Create a Java server that implements the schema interface -- Create a Java client that accesses the server -- Create a Go client that accesses the Java server -- Update the service with advanced features like RPC streaming +- Create a protobuf schema that defines a simple RPC service. +- Create a Java server that implements the schema interface. +- Create a Java client that accesses the server. +- Create a Go client that accesses the Java server. +- Update the service with advanced features like RPC streaming. # Get Started @@ -22,7 +22,7 @@ If you just want to read the tutorial, you can go straight to the next step: [St # Working with the code You can follow along with this tutorial and hack on the code in the comfort of -your own computer. In this way you can get hands-on practice of really writing +your own computer. This way you can get hands-on practice of really writing gRPC code. The tutorial relies on the use of the Git versioning system for source code @@ -61,7 +61,7 @@ for instructions. # Install Maven -To simplify building and the managing of gRPC's dependencies, the java client +To simplify building and the managing of gRPC's dependencies, the Java client are server are structured as a standard [Maven](http://maven.apache.org/guides/getting-started/) project. See [Install Maven](http://maven.apache.org/users/index.html) for instructions. @@ -76,6 +76,6 @@ Go gRPC requires Go 1.4, the latest version of Go. See gRPC uses the latest version of the protocol buffer compiler, protoc. For following this tutorial, the protoc is not strictly necessary, as all the -generated code is checked into the Git repository. If you want to experiment +generated code is checked into the Git repository. If you want to experiment with generating the code yourself, download and install protoc from its [Git repo](https://github.com/google/protobuf) diff --git a/Step_0.md b/Step_0.md index a346f77e814..07c5bc5690f 100644 --- a/Step_0.md +++ b/Step_0.md @@ -1,10 +1,10 @@ # Step-0: define a service This section presents an example of a simple service definition that receives -a message from a remote client. The message contains the users's name and +a message from a remote client. The message contains the user's name and sends back a greeting to that person. -It's shown below in full; it's actually contained in separate file +It's shown below in full; it's actually contained in separate file. [helloworld.proto](src/main/proto/helloworld.proto). ``` @@ -33,7 +33,7 @@ service Greeting { ``` The service stanza of the message is an example of protobuf service IDL -(Interface Defintion Language). Here, it defines a simple service that +(Interface Defintion Language). Here, it defines a simple service that receives a request containing a name and returns a response containing a message. diff --git a/Step_1.md b/Step_1.md index da85cb4e10f..c7aed326c38 100644 --- a/Step_1.md +++ b/Step_1.md @@ -1,6 +1,6 @@ # Step-1: Generate a service client. -In this step, we use protoc to generate the java Stub classes. A Stub is the +In this step, we use protoc to generate the Java Stub classes. A Stub is the name gRPC uses for the code that initiates contact with a gRPC service running remotely via the internet. @@ -11,7 +11,7 @@ First, you'll need to build the protobuf plugin that generates the rpc classes. `protoc` uses other tools called plugins to add additional features to generated code. -The grpc Java Stub classes are created using a grpc java plugin, but first the +The gRPC Java Stub classes are created using a gRPC Java plugin, but first the plugin must be built and installed. To build the plugin: diff --git a/Step_2.md b/Step_2.md index 32c578f18a9..eafe70b6923 100644 --- a/Step_2.md +++ b/Step_2.md @@ -1,15 +1,15 @@ # Step-2: Write a service client. This step uses the generated code to write a simple client to access the hello -service. The full client is in [GreetingsClient.java](src/main/java/ex/grpc/GreetingsClient.java). +service. The full client is in [GreetingsClient.java](src/main/java/ex/grpc/GreetingsClient.java). ## Configuring the service to connect to. -The client contains uses a Stub to contact the service. The internet address -is configured in the client constructor. gRPC Channel is the abstraction over +The client contains uses a Stub to contact the service. The internet address +is configured in the client constructor. gRPC Channel is the abstraction over transport handling; its constructor accepts the host name and port of the -service. The channel in turn is used to construct the Stub. +service. The channel in turn is used to construct the Stub. ``` @@ -77,7 +77,7 @@ implement, build and run a server that supports the service description. ## Notes -- the client uses a blocking stub. This means that the RPC call waits for the +- The client uses a blocking stub. This means that the RPC call waits for the server to respond, and will either return a response or raise an exception. - gRPC Java has other kinds of stubs that make non-blocking calls to the diff --git a/Step_3.md b/Step_3.md index 56d6e7cfd3a..bba8f0aa3fb 100644 --- a/Step_3.md +++ b/Step_3.md @@ -1,16 +1,16 @@ # Step-3: Implement a server. This step extends the generated server skeleton code to write a simple server -that provides the hello service. This in introduces two new classes +that provides the hello service. This introduces two new classes: - a service implementation [GreetingsImpl.java](src/main/java/ex/grpc/GreetingsImpl.java). -- a server that hosts the service implementation and allows to accessed over the network: [GreetingsServer.java](src/main/java/ex/grpc/GreetingsServer.java). +- a server that hosts the service implementation and allows access over the network: [GreetingsServer.java](src/main/java/ex/grpc/GreetingsServer.java). ## Service implementation -[GreetingsSImpl.java](src/main/java/ex/grpc/GreetingsImpl.java) -implements the behaviour we require of our GreetingService. There are a +[GreetingsImpl.java](src/main/java/ex/grpc/GreetingsImpl.java) +implements the behaviour we require of our GreetingService. There are a number of important features of gRPC being used here: ``` @@ -39,7 +39,7 @@ number of important features of gRPC being used here: ## Server implementation [GreetingsServer.java](src/main/java/ex/grpc/GreetingsServer.java) shows the -other main feature to required to provde gRPC service; how to allow a service +other main feature required to provde the gRPC service; how to allow a service implementation to be accessed from the network. ``` @@ -68,14 +68,14 @@ $ mvn package ## Try them out -We've added simple shell scripts to simplifying running the examples. Now -that they are built, you can run the server with. +We've added simple shell scripts to simplifying running the examples. Now +that they are built, you can run the server with: ``` $ ./run_greetings_server.sh ``` -In another termainal window and confirm that it receives a message. +and in another termainal window and confirm that it receives a message. ``` $ ./run_greetings_client.sh From d2828d9b1b0341e068741516fc91702a96844519 Mon Sep 17 00:00:00 2001 From: Mugur Marculescu Date: Wed, 4 Feb 2015 21:50:56 -0800 Subject: [PATCH 08/13] Another grammar fix. --- Step_3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Step_3.md b/Step_3.md index bba8f0aa3fb..d2d7f4788db 100644 --- a/Step_3.md +++ b/Step_3.md @@ -75,7 +75,7 @@ that they are built, you can run the server with: $ ./run_greetings_server.sh ``` -and in another termainal window and confirm that it receives a message. +and in another termainal window confirm that it receives a message. ``` $ ./run_greetings_client.sh From 8c92a90a4a3bdd0bd5ec37b7f9ad412cd0cd7f1f Mon Sep 17 00:00:00 2001 From: Mugur Marculescu Date: Wed, 4 Feb 2015 21:52:45 -0800 Subject: [PATCH 09/13] Another typo fix. --- Step_3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Step_3.md b/Step_3.md index d2d7f4788db..7b03cdf585f 100644 --- a/Step_3.md +++ b/Step_3.md @@ -75,7 +75,7 @@ that they are built, you can run the server with: $ ./run_greetings_server.sh ``` -and in another termainal window confirm that it receives a message. +and in another terminal window confirm that it receives a message. ``` $ ./run_greetings_client.sh From a14935fceeaa9111579a65e85929b9a171debe43 Mon Sep 17 00:00:00 2001 From: Mugur Marculescu Date: Thu, 5 Feb 2015 16:14:17 -0800 Subject: [PATCH 10/13] Another typo. --- Step_0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Step_0.md b/Step_0.md index 07c5bc5690f..d0745b0dd1f 100644 --- a/Step_0.md +++ b/Step_0.md @@ -33,7 +33,7 @@ service Greeting { ``` The service stanza of the message is an example of protobuf service IDL -(Interface Defintion Language). Here, it defines a simple service that +(Interface Definition Language). Here, it defines a simple service that receives a request containing a name and returns a response containing a message. From 8f505f74e420a5fe52cf084a55117f5c73e11774 Mon Sep 17 00:00:00 2001 From: Tim Emiola Date: Thu, 5 Feb 2015 17:34:47 -0800 Subject: [PATCH 11/13] Adds the common protos along with a README.md --- protos/README.md | 12 +++++++ protos/helloworld.proto | 51 ++++++++++++++++++++++++++ protos/math.proto | 79 +++++++++++++++++++++++++++++++++++++++++ protos/stock.proto | 71 ++++++++++++++++++++++++++++++++++++ 4 files changed, 213 insertions(+) create mode 100644 protos/README.md create mode 100644 protos/helloworld.proto create mode 100644 protos/math.proto create mode 100644 protos/stock.proto diff --git a/protos/README.md b/protos/README.md new file mode 100644 index 00000000000..29639a68f44 --- /dev/null +++ b/protos/README.md @@ -0,0 +1,12 @@ +# Example protos + +## Contents + +- helloworld.proto + A very simple example used in the overview. + +- stock.proto + A detailed example that's described in detail in the tutorial. + +- math.proto + Another detailed example for further reference. diff --git a/protos/helloworld.proto b/protos/helloworld.proto new file mode 100644 index 00000000000..aa44b851f43 --- /dev/null +++ b/protos/helloworld.proto @@ -0,0 +1,51 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +option java_package = "ex.grpc"; + +package helloworld; + +// The request message containing the user's name. +message HelloRequest { + optional string name = 1; +} + +// The response message containing the greetings +message HelloReply { + optional string message = 1; +} + +// The greeting service definition. +service Greetings { + // Sends a greeting + rpc hello (HelloRequest) returns (HelloReply) { + } +} diff --git a/protos/math.proto b/protos/math.proto new file mode 100644 index 00000000000..46a33aeee53 --- /dev/null +++ b/protos/math.proto @@ -0,0 +1,79 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package math; + +message DivArgs { + optional int64 dividend = 1; + optional int64 divisor = 2; +} + +message DivReply { + optional int64 quotient = 1; + optional int64 remainder = 2; +} + +message FibArgs { + optional int64 limit = 1; +} + +message Num { + optional int64 num = 1; +} + +message FibReply { + optional int64 count = 1; +} + +service Math { + // Div divides args.dividend by args.divisor and returns the quotient and + // remainder. + rpc Div (DivArgs) returns (DivReply) { + } + + // DivMany accepts an arbitrary number of division args from the client stream + // and sends back the results in the reply stream. The stream continues until + // the client closes its end; the server does the same after sending all the + // replies. The stream ends immediately if either end aborts. + rpc DivMany (stream DivArgs) returns (stream DivReply) { + } + + // Fib generates numbers in the Fibonacci sequence. If args.limit > 0, Fib + // generates up to limit numbers; otherwise it continues until the call is + // canceled. + rpc Fib (FibArgs) returns (stream Num) { + } + + // Sum sums a stream of numbers, returning the final result once the stream + // is closed. + rpc Sum (stream Num) returns (Num) { + } +} diff --git a/protos/stock.proto b/protos/stock.proto new file mode 100644 index 00000000000..dcb677e4733 --- /dev/null +++ b/protos/stock.proto @@ -0,0 +1,71 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package examples; + +// Protocol type definitions +message StockRequest { + optional string symbol = 1; + optional int32 num_trades_to_watch = 2; +}; + +message StockReply { + optional float price = 1; + optional string symbol = 2; +}; + +// Interface exported by the server +service Stock { + // A simple blocking RPC. + // + // Obtains the last traded price for the given Stock. + rpc GetLastTradePrice(StockRequest) returns (StockReply) { + }; + + // A Unidirectional server-to-client streaming RPC. + // + // Streams future prices for a given symbol. + rpc WatchFutureTrades(StockRequest) returns (stream StockReply) { + }; + + // A Unidirectional client-to-server streaming RPC. + // + // Gets the highest traded price for a series of symbols + rpc GetHighestTradePrice(stream StockRequest) returns (StockReply) { + }; + + // Bidirectional streaming RPC. + // + // Gets the most recent traded price of series of trades. + rpc GetLastTradePriceMultiple(stream StockRequest) returns + (stream StockReply) { + }; +}; From bb9e6f4e7ce17d5a06e10a487e65ed6a1473155a Mon Sep 17 00:00:00 2001 From: Tim Emiola Date: Fri, 6 Feb 2015 12:56:33 -0800 Subject: [PATCH 12/13] removed superfluous semi-colons --- protos/stock.proto | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/protos/stock.proto b/protos/stock.proto index dcb677e4733..49efbf2730a 100644 --- a/protos/stock.proto +++ b/protos/stock.proto @@ -35,12 +35,12 @@ package examples; message StockRequest { optional string symbol = 1; optional int32 num_trades_to_watch = 2; -}; +} message StockReply { optional float price = 1; optional string symbol = 2; -}; +} // Interface exported by the server service Stock { @@ -48,24 +48,24 @@ service Stock { // // Obtains the last traded price for the given Stock. rpc GetLastTradePrice(StockRequest) returns (StockReply) { - }; + } // A Unidirectional server-to-client streaming RPC. // // Streams future prices for a given symbol. rpc WatchFutureTrades(StockRequest) returns (stream StockReply) { - }; + } // A Unidirectional client-to-server streaming RPC. // // Gets the highest traded price for a series of symbols rpc GetHighestTradePrice(stream StockRequest) returns (StockReply) { - }; + } // Bidirectional streaming RPC. // // Gets the most recent traded price of series of trades. rpc GetLastTradePriceMultiple(stream StockRequest) returns (stream StockReply) { - }; -}; + } +} From f751995e86eacf7a475f7fb7ee52d2e45ab0b599 Mon Sep 17 00:00:00 2001 From: Tim Emiola Date: Fri, 6 Feb 2015 13:59:50 -0800 Subject: [PATCH 13/13] Update README.md --- protos/README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/protos/README.md b/protos/README.md index 29639a68f44..374d4350aca 100644 --- a/protos/README.md +++ b/protos/README.md @@ -3,10 +3,8 @@ ## Contents - helloworld.proto - A very simple example used in the overview. - + - A very simple example used in the overview. - stock.proto - A detailed example that's described in detail in the tutorial. - + - A detailed example that's described in detail in the tutorial. - math.proto - Another detailed example for further reference. + - Another detailed example for further reference.