From 8536e0767e936895c2f38c5d77d582621bafd22a Mon Sep 17 00:00:00 2001 From: Tim Emiola Date: Fri, 23 Jan 2015 17:12:39 -0800 Subject: [PATCH] Step-0: define a service --- Step_0.md | 40 ++++++++++++++++++++++++++++++++++++++++ helloworld.proto | 20 ++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Step_0.md create mode 100644 helloworld.proto diff --git a/Step_0.md b/Step_0.md new file mode 100644 index 00000000000..695fb1a4323 --- /dev/null +++ b/Step_0.md @@ -0,0 +1,40 @@ +# Step-0: define a service + +This section presents an example of a very simple service definition that +receives a message from a remote client. The messages contains the users's +name and sends's back a greeting for that person. + +Here it is in full; to be used to generate gRPC code it's defined in it's own +file [helloworld.proto](helloworld.proto). + +``` +syntax = "proto3"; + +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 Greeting { + + // Sends a greeting + rpc hello (HelloRequest) returns (HelloReply) { + } +} + +``` + +The service stanza of the messages is an example of protobuf service IDL +(Interface Defintion Language). Here, it defines a very simple service that +receives a request and returns a response. + +Next in [Step-1](Step-1.md), we'll use protoc to generate code this simple +definition. diff --git a/helloworld.proto b/helloworld.proto new file mode 100644 index 00000000000..a7f5bfbb4d1 --- /dev/null +++ b/helloworld.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +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 Greeting { + // Sends a greeting + rpc hello (HelloRequest) returns (HelloReply) { + } +}