aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-10-07 12:37:58 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-10-07 12:37:58 -0700
commit8d5396aac17012492a54c17c1215440f8109aa2d (patch)
tree5771137593d6abea196c6a575b0006123ef4c912 /examples
parent54030dd67f2b67d02d0d894f90eb54c1f5b53358 (diff)
parent0862bcf8d8f7759dfcce1de897d8db81fcd5d296 (diff)
Resolved merge conflicts
Diffstat (limited to 'examples')
-rw-r--r--examples/node/greeter_client.js2
-rw-r--r--examples/node/greeter_server.js2
-rw-r--r--examples/node/package.json10
-rw-r--r--examples/node/route_guide/route_guide_client.js4
-rw-r--r--examples/node/route_guide/route_guide_server.js4
-rw-r--r--examples/python/README.md55
-rw-r--r--examples/python/helloworld/README.md114
-rw-r--r--examples/python/helloworld/helloworld_pb2.py202
-rw-r--r--examples/python/route_guide/README.md300
9 files changed, 265 insertions, 428 deletions
diff --git a/examples/node/greeter_client.js b/examples/node/greeter_client.js
index ddc8abbbed..175f8e6b5a 100644
--- a/examples/node/greeter_client.js
+++ b/examples/node/greeter_client.js
@@ -33,7 +33,7 @@
var PROTO_PATH = __dirname + '/helloworld.proto';
-var grpc = require('grpc');
+var grpc = require('../../');
var hello_proto = grpc.load(PROTO_PATH).helloworld;
function main() {
diff --git a/examples/node/greeter_server.js b/examples/node/greeter_server.js
index 44b44afaaf..3600c8bfbf 100644
--- a/examples/node/greeter_server.js
+++ b/examples/node/greeter_server.js
@@ -33,7 +33,7 @@
var PROTO_PATH = __dirname + '/helloworld.proto';
-var grpc = require('grpc');
+var grpc = require('../../');
var hello_proto = grpc.load(PROTO_PATH).helloworld;
/**
diff --git a/examples/node/package.json b/examples/node/package.json
deleted file mode 100644
index f0a044f05e..0000000000
--- a/examples/node/package.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "name": "grpc-demo",
- "version": "0.11.0",
- "dependencies": {
- "async": "^0.9.0",
- "grpc": "~0.11.0",
- "minimist": "^1.1.0",
- "underscore": "^1.8.2"
- }
-}
diff --git a/examples/node/route_guide/route_guide_client.js b/examples/node/route_guide/route_guide_client.js
index 1da6c69025..525d68f44c 100644
--- a/examples/node/route_guide/route_guide_client.js
+++ b/examples/node/route_guide/route_guide_client.js
@@ -31,8 +31,8 @@ var async = require('async');
var fs = require('fs');
var parseArgs = require('minimist');
var path = require('path');
-var _ = require('underscore');
-var grpc = require('grpc');
+var _ = require('lodash');
+var grpc = require('../../../');
var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide;
var client = new routeguide.RouteGuide('localhost:50051',
grpc.Credentials.createInsecure());
diff --git a/examples/node/route_guide/route_guide_server.js b/examples/node/route_guide/route_guide_server.js
index faae3087fd..5bb81446f0 100644
--- a/examples/node/route_guide/route_guide_server.js
+++ b/examples/node/route_guide/route_guide_server.js
@@ -30,8 +30,8 @@
var fs = require('fs');
var parseArgs = require('minimist');
var path = require('path');
-var _ = require('underscore');
-var grpc = require('grpc');
+var _ = require('lodash');
+var grpc = require('../../../');
var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide;
var COORD_FACTOR = 1e7;
diff --git a/examples/python/README.md b/examples/python/README.md
new file mode 100644
index 0000000000..7b48c824ba
--- /dev/null
+++ b/examples/python/README.md
@@ -0,0 +1,55 @@
+gRPC in 3 minutes (Python)
+========================
+
+Background
+-------------
+For this sample, we've already generated the server and client stubs from
+[helloworld.proto][] and we'll be using a specific reference platform.
+
+Prerequisites
+-------------
+
+- Debian 8.2 "Jessie" platform with `root` access
+- `git`
+- `python2.7`
+- `pip`
+- Python development headers
+
+Set-up
+-------
+ ```sh
+ $ # install the gRPC Core:
+ $ sudo apt-get install libgrpc-dev
+ $ # install gRPC Python:
+ $ sudo pip install -U grpcio==0.11.0b1
+ $ # Since this "hello, world" example uses protocol buffers:
+ $ sudo pip install -U protobuf==3.0.0a3
+ $ # Clone the repository to get the example code:
+ $ git clone https://github.com/grpc/grpc
+ $ # Navigate to the "hello, world" Python example:
+ $ cd grpc/examples/python/helloworld
+ ```
+
+Try it!
+-------
+
+- Run the server
+
+ ```sh
+ $ python2.7 greeter_server.py &
+ ```
+
+- Run the client
+
+ ```sh
+ $ python2.7 greeter_client.py
+ ```
+
+Tutorial
+--------
+
+You can find a more detailed tutorial in [gRPC Basics: Python][]
+
+[helloworld.proto]:../protos/helloworld.proto
+[Install gRPC Python]:../../src/python#installation
+[gRPC Basics: Python]:http://www.grpc.io/docs/tutorials/basic/python.html
diff --git a/examples/python/helloworld/README.md b/examples/python/helloworld/README.md
index 070b9e8837..e889863a23 100644
--- a/examples/python/helloworld/README.md
+++ b/examples/python/helloworld/README.md
@@ -1,113 +1 @@
-# gRPC Python Hello World
-
-This is a quick introduction with a simple example and installation instructions: for a more complete tutorial see [gRPC Basics: Python](../route_guide).
-
-### Install gRPC
-Make sure you have built gRPC Python from source on your system. Follow the instructions here:
-[https://github.com/grpc/grpc/blob/master/src/python/README.md](https://github.com/grpc/grpc/blob/master/src/python/README.md).
-
-This gives you a python virtual environment with installed gRPC Python
-in GRPC_ROOT/python2.7_virtual_environment. GRPC_ROOT is the path to which you
-have cloned the [gRPC git repo](https://github.com/grpc/grpc).
-
-### Get the source code
-
-The example code for our Hello World and our other examples live in the `examples`
-directory. Clone this repository to your local machine by running the
-following command:
-
-
-```sh
-$ git clone https://github.com/grpc/grpc.git
-```
-
-Change your current directory to examples/python/helloworld
-
-```sh
-$ cd examples/python/helloworld/
-```
-
-### Defining a service
-
-The first step in creating our example is to define a *service*: an RPC
-service specifies the methods that can be called remotely with their parameters
-and return types. As you saw in the
-[overview](#protocolbuffers) above, gRPC does this using [protocol
-buffers](https://developers.google.com/protocol-buffers/docs/overview). We
-use the protocol buffers interface definition language (IDL) to define our
-service methods, and define the parameters and return
-types as protocol buffer message types. Both the client and the
-server use interface code generated from the service definition.
-
-Here's our example service definition. The `Greeting`
-service has one method, `hello`, that lets the server receive a single
-`HelloRequest`
-message from the remote client containing the user's name, then send back
-a greeting in a single `HelloReply`. This is the simplest type of RPC you
-can specify in gRPC.
-
-```
-syntax = "proto3";
-
-option java_package = "io.grpc.examples";
-
-package helloworld;
-
-// The greeting service definition.
-service Greeter {
- // Sends a greeting
- rpc SayHello (HelloRequest) returns (HelloReply) {}
-}
-
-// The request message containing the user's name.
-message HelloRequest {
- string name = 1;
-}
-
-// The response message containing the greetings
-message HelloReply {
- string message = 1;
-}
-
-```
-
-<a name="generating"></a>
-### Generating gRPC code
-
-Once we've defined our service, we use the protocol buffer compiler
-`protoc` to generate the special client and server code we need to create
-our application. The generated code contains both stub code for clients to
-use and an abstract interface for servers to implement, both with the method
-defined in our `Greeting` service.
-
-To generate the client and server side interfaces:
-
-```sh
-$ ./run_codegen.sh
-```
-Which internally invokes the proto-compiler as:
-
-```sh
-$ protoc -I ../../protos --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ../../protos/helloworld.proto
-```
-
-### The client
-
-Client-side code can be found in [greeter_client.py](greeter_client.py).
-
-You can run the client using:
-
-```sh
-$ ./run_client.sh
-```
-
-
-### The server
-
-Server side code can be found in [greeter_server.py](greeter_server.py).
-
-You can run the server using:
-
-```sh
-$ ./run_server.sh
-```
+[This code's documentation lives on the grpc.io site.](http://www.grpc.io/docs)
diff --git a/examples/python/helloworld/helloworld_pb2.py b/examples/python/helloworld/helloworld_pb2.py
new file mode 100644
index 0000000000..1b2674e4c8
--- /dev/null
+++ b/examples/python/helloworld/helloworld_pb2.py
@@ -0,0 +1,202 @@
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: helloworld.proto
+
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import message as _message
+from google.protobuf import reflection as _reflection
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+
+
+DESCRIPTOR = _descriptor.FileDescriptor(
+ name='helloworld.proto',
+ package='helloworld',
+ syntax='proto3',
+ serialized_pb=b'\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x18\n\x10io.grpc.examples\xa2\x02\x03HLWb\x06proto3'
+)
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
+
+
+
+
+_HELLOREQUEST = _descriptor.Descriptor(
+ name='HelloRequest',
+ full_name='helloworld.HelloRequest',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='name', full_name='helloworld.HelloRequest.name', index=0,
+ number=1, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=b"".decode('utf-8'),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=32,
+ serialized_end=60,
+)
+
+
+_HELLOREPLY = _descriptor.Descriptor(
+ name='HelloReply',
+ full_name='helloworld.HelloReply',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='message', full_name='helloworld.HelloReply.message', index=0,
+ number=1, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=b"".decode('utf-8'),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=62,
+ serialized_end=91,
+)
+
+DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST
+DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY
+
+HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict(
+ DESCRIPTOR = _HELLOREQUEST,
+ __module__ = 'helloworld_pb2'
+ # @@protoc_insertion_point(class_scope:helloworld.HelloRequest)
+ ))
+_sym_db.RegisterMessage(HelloRequest)
+
+HelloReply = _reflection.GeneratedProtocolMessageType('HelloReply', (_message.Message,), dict(
+ DESCRIPTOR = _HELLOREPLY,
+ __module__ = 'helloworld_pb2'
+ # @@protoc_insertion_point(class_scope:helloworld.HelloReply)
+ ))
+_sym_db.RegisterMessage(HelloReply)
+
+
+DESCRIPTOR.has_options = True
+DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), b'\n\020io.grpc.examples\242\002\003HLW')
+import abc
+from grpc.beta import implementations as beta_implementations
+from grpc.early_adopter import implementations as early_adopter_implementations
+from grpc.framework.alpha import utilities as alpha_utilities
+from grpc.framework.common import cardinality
+from grpc.framework.interfaces.face import utilities as face_utilities
+class EarlyAdopterGreeterServicer(object):
+ """<fill me in later!>"""
+ __metaclass__ = abc.ABCMeta
+ @abc.abstractmethod
+ def SayHello(self, request, context):
+ raise NotImplementedError()
+class EarlyAdopterGreeterServer(object):
+ """<fill me in later!>"""
+ __metaclass__ = abc.ABCMeta
+ @abc.abstractmethod
+ def start(self):
+ raise NotImplementedError()
+ @abc.abstractmethod
+ def stop(self):
+ raise NotImplementedError()
+class EarlyAdopterGreeterStub(object):
+ """<fill me in later!>"""
+ __metaclass__ = abc.ABCMeta
+ @abc.abstractmethod
+ def SayHello(self, request):
+ raise NotImplementedError()
+ SayHello.async = None
+def early_adopter_create_Greeter_server(servicer, port, private_key=None, certificate_chain=None):
+ import helloworld_pb2
+ import helloworld_pb2
+ method_service_descriptions = {
+ "SayHello": alpha_utilities.unary_unary_service_description(
+ servicer.SayHello,
+ helloworld_pb2.HelloRequest.FromString,
+ helloworld_pb2.HelloReply.SerializeToString,
+ ),
+ }
+ return early_adopter_implementations.server("helloworld.Greeter", method_service_descriptions, port, private_key=private_key, certificate_chain=certificate_chain)
+def early_adopter_create_Greeter_stub(host, port, metadata_transformer=None, secure=False, root_certificates=None, private_key=None, certificate_chain=None, server_host_override=None):
+ import helloworld_pb2
+ import helloworld_pb2
+ method_invocation_descriptions = {
+ "SayHello": alpha_utilities.unary_unary_invocation_description(
+ helloworld_pb2.HelloRequest.SerializeToString,
+ helloworld_pb2.HelloReply.FromString,
+ ),
+ }
+ return early_adopter_implementations.stub("helloworld.Greeter", method_invocation_descriptions, host, port, metadata_transformer=metadata_transformer, secure=secure, root_certificates=root_certificates, private_key=private_key, certificate_chain=certificate_chain, server_host_override=server_host_override)
+
+class BetaGreeterServicer(object):
+ """<fill me in later!>"""
+ __metaclass__ = abc.ABCMeta
+ @abc.abstractmethod
+ def SayHello(self, request, context):
+ raise NotImplementedError()
+
+class BetaGreeterStub(object):
+ """The interface to which stubs will conform."""
+ __metaclass__ = abc.ABCMeta
+ @abc.abstractmethod
+ def SayHello(self, request, timeout):
+ raise NotImplementedError()
+ SayHello.future = None
+
+def beta_create_Greeter_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None):
+ import helloworld_pb2
+ import helloworld_pb2
+ request_deserializers = {
+ ('helloworld.Greeter', 'SayHello'): helloworld_pb2.HelloRequest.FromString,
+ }
+ response_serializers = {
+ ('helloworld.Greeter', 'SayHello'): helloworld_pb2.HelloReply.SerializeToString,
+ }
+ method_implementations = {
+ ('helloworld.Greeter', 'SayHello'): face_utilities.unary_unary_inline(servicer.SayHello),
+ }
+ server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout)
+ return beta_implementations.server(method_implementations, options=server_options)
+
+def beta_create_Greeter_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None):
+ import helloworld_pb2
+ import helloworld_pb2
+ request_serializers = {
+ ('helloworld.Greeter', 'SayHello'): helloworld_pb2.HelloRequest.SerializeToString,
+ }
+ response_deserializers = {
+ ('helloworld.Greeter', 'SayHello'): helloworld_pb2.HelloReply.FromString,
+ }
+ cardinalities = {
+ 'SayHello': cardinality.Cardinality.UNARY_UNARY,
+ }
+ stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size)
+ return beta_implementations.dynamic_stub(channel, 'helloworld.Greeter', cardinalities, options=stub_options)
+# @@protoc_insertion_point(module_scope)
diff --git a/examples/python/route_guide/README.md b/examples/python/route_guide/README.md
index cb1aa7d78a..17b8a8edd5 100644
--- a/examples/python/route_guide/README.md
+++ b/examples/python/route_guide/README.md
@@ -1,299 +1 @@
-#gRPC Basics: Python
-
-This tutorial provides a basic Python programmer's introduction to working with gRPC. By walking through this example you'll learn how to:
-
-- Define a service in a .proto file.
-- Generate server and client code using the protocol buffer compiler.
-- Use the Python gRPC API to write a simple client and server for your service.
-
-It assumes that you have read the [Getting started](https://github.com/grpc/grpc/tree/master/examples) guide and are familiar with [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial uses the proto3 version of the protocol buffers language, which is currently in alpha release:you can find out more in the [proto3 language guide](https://developers.google.com/protocol-buffers/docs/proto3) and see the [release notes](https://github.com/google/protobuf/releases) for the new version in the protocol buffers Github repository.
-
-This isn't a comprehensive guide to using gRPC in Python: more reference documentation is coming soon.
-
-
-## Why use gRPC?
-
-This example is a simple route mapping application that lets clients get information about features on their route, create a summary of their route, and exchange route information such as traffic updates with the server and other clients.
-
-With gRPC you can define your service once in a .proto file and implement clients and servers in any of gRPC's supported languages, which in turn can be run in environments ranging from servers inside Google to your own tablet, with all the complexity of communication between different languages and environments is handled for you by gRPC. You also get all the advantages of working with protocol buffers, including efficient serialization, a simple IDL, and easy interface updating.
-
-## Example code and setup
-
-The example code for this tutorial is in [examples/python/route_guide](.). To download the example, clone this repository by running the following command:
-```shell
-$ git clone https://github.com/grpc/grpc.git
-```
-
-Then change your current directory to `examples/python/route_guide`:
-```shell
-$ cd examples/python/route_guide
-```
-
-You also should have the relevant tools installed to generate the server and client interface code - if you don't already, follow the setup instructions in [the Python quick start guide](../helloworld).
-
-## Defining the service
-
-Your first step (as you'll know from [Getting started](https://github.com/grpc/grpc/tree/master/examples)) is to 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 [`examples/protos/route_guide.proto`](../../protos/route_guide.proto).
-
-To define a service, you specify a named `service` in your .proto file:
-
-```protobuf
-service RouteGuide {
- // (Method definitions not shown)
-}
-```
-
-Then you define `rpc` methods inside your service definition, specifying their request and response types. gRPC lets you define four kinds of service method, all of which are used in the `RouteGuide` service:
-
-- A *simple RPC* where the client sends a request to the server using the stub and waits for a response to come back, just like a normal function call.
-```protobuf
- // Obtains the feature at a given position.
- rpc GetFeature(Point) returns (Feature) {}
-```
-
-- A *response-streaming RPC* where the client sends a request to the server and gets a stream to read a sequence of messages back. The client reads from the returned stream until there are no more messages. As you can see in the example, you specify a response-streaming method by placing the `stream` keyword before the *response* type.
-```protobuf
- // Obtains the Features available within the given Rectangle. Results are
- // streamed rather than returned at once (e.g. in a response message with a
- // repeated field), as the rectangle may cover a large area and contain a
- // huge number of features.
- rpc ListFeatures(Rectangle) returns (stream Feature) {}
-```
-
-- A *request-streaming RPC* where the client writes a sequence of messages and sends them to the server, again using a provided stream. Once the client has finished writing the messages, it waits for the server to read them all and return its response. You specify a request-streaming method by placing the `stream` keyword before the *request* type.
-```protobuf
- // Accepts a stream of Points on a route being traversed, returning a
- // RouteSummary when traversal is completed.
- rpc RecordRoute(stream Point) returns (RouteSummary) {}
-```
-
-- A *bidirectionally-streaming RPC* where both sides send a sequence of messages using a read-write stream. The two streams operate independently, so clients and servers can read and write in whatever order they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes. The order of messages in each stream is preserved. You specify this type of method by placing the `stream` keyword before both the request and the response.
-```protobuf
- // Accepts a stream of RouteNotes sent while a route is being traversed,
- // while receiving other RouteNotes (e.g. from other users).
- rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-```
-
-Your .proto file also contains protocol buffer message type definitions for all the request and response types used in our service methods - for example, here's the `Point` message type:
-```protobuf
-// Points are represented as latitude-longitude pairs in the E7 representation
-// (degrees multiplied by 10**7 and rounded to the nearest integer).
-// Latitudes should be in the range +/- 90 degrees and longitude should be in
-// the range +/- 180 degrees (inclusive).
-message Point {
- int32 latitude = 1;
- int32 longitude = 2;
-}
-```
-
-## Generating client and server code
-
-Next you need to generate the gRPC client and server interfaces from your .proto service definition. You do this using the protocol buffer compiler `protoc` with a special gRPC Python plugin. Make sure you've installed protoc and followed the gRPC Python plugin [installation instructions](https://github.com/grpc/grpc/blob/master/INSTALL) first):
-
-With `protoc` and the gRPC Python plugin installed, use the following command to generate the Python code:
-
-```shell
-$ protoc -I ../../protos --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ../../protos/route_guide.proto
-```
-
-Note that as we've already provided a version of the generated code in the example repository, running this command regenerates the appropriate file rather than creates a new one. The generated code file is called `route_guide_pb2.py` and contains:
-- classes for the messages defined in route_guide.proto
-- abstract classes for the service defined in route_guide.proto
- - `BetaRouteGuideServicer`, which defines the interface for implementations of the RouteGuide service
- - `BetaRouteGuideStub`, which can be used by clients to invoke RouteGuide RPCs
-- functions for application use
- - `beta_create_RouteGuide_server`, which creates a gRPC server given a `BetaRouteGuideServicer` object
- - `beta_create_RouteGuide_stub`, which can be used by clients to create a stub object
-
-<a name="server"></a>
-## Creating the server
-
-First let's look at how you create a `RouteGuide` server. If you're only interested in creating gRPC clients, you can skip this section and go straight to [Creating the client](#client) (though you might find it interesting anyway!).
-
-Creating and running a `RouteGuide` server breaks down into two work items:
-- Implementing the servicer interface generated from our service definition with functions that perform the actual "work" of the service.
-- Running a gRPC server to listen for requests from clients and transmit responses.
-
-You can find the example `RouteGuide` server in [route_guide_server.py](route_guide_server.py).
-
-### Implementing RouteGuide
-
-`route_guide_server.py` has a `RouteGuideServicer` class that implements the generated interface `route_guide_pb2.BetaRouteGuideServicer`:
-
-```python
-# RouteGuideServicer provides an implementation of the methods of the RouteGuide service.
-class RouteGuideServicer(route_guide_pb2.BetaRouteGuideServicer):
-```
-
-`RouteGuideServicer` implements all the `RouteGuide` service methods.
-
-#### Simple RPC
-
-Let's look at the simplest type first, `GetFeature`, which just gets a `Point` from the client and returns the corresponding feature information from its database in a `Feature`.
-
-```python
- def GetFeature(self, request, context):
- feature = get_feature(self.db, request)
- if feature is None:
- return route_guide_pb2.Feature(name="", location=request)
- else:
- return feature
-```
-
-The method is passed a `route_guide_pb2.Point` request for the RPC, and a `ServicerContext` object that provides RPC-specific information such as timeout limits. It returns a `route_guide_pb2.Feature` response.
-
-#### Response-streaming RPC
-
-Now let's look at the next method. `ListFeatures` is a response-streaming RPC that sends multiple `Feature`s to the client.
-
-```python
- def ListFeatures(self, request, context):
- left = min(request.lo.longitude, request.hi.longitude)
- right = max(request.lo.longitude, request.hi.longitude)
- top = max(request.lo.latitude, request.hi.latitude)
- bottom = min(request.lo.latitude, request.hi.latitude)
- for feature in self.db:
- if (feature.location.longitude >= left and
- feature.location.longitude <= right and
- feature.location.latitude >= bottom and
- feature.location.latitude <= top):
- yield feature
-```
-
-Here the request message is a `route_guide_pb2.Rectangle` within which the client wants to find `Feature`s. Instead of returning a single response the method yields zero or more responses.
-
-#### Request-streaming RPC
-
-The request-streaming method `RecordRoute` uses an [iterator](https://docs.python.org/2/library/stdtypes.html#iterator-types) of request values and returns a single response value.
-
-```python
- def RecordRoute(self, request_iterator, context):
- point_count = 0
- feature_count = 0
- distance = 0.0
- prev_point = None
-
- start_time = time.time()
- for point in request_iterator:
- point_count += 1
- if get_feature(self.db, point):
- feature_count += 1
- if prev_point:
- distance += get_distance(prev_point, point)
- prev_point = point
-
- elapsed_time = time.time() - start_time
- return route_guide_pb2.RouteSummary(point_count=point_count,
- feature_count=feature_count,
- distance=int(distance),
- elapsed_time=int(elapsed_time))
-```
-
-#### Bidirectional streaming RPC
-
-Lastly let's look at the bidirectionally-streaming method `RouteChat`.
-
-```python
- def RouteChat(self, request_iterator, context):
- prev_notes = []
- for new_note in request_iterator:
- for prev_note in prev_notes:
- if prev_note.location == new_note.location:
- yield prev_note
- prev_notes.append(new_note)
-```
-
-This method's semantics are a combination of those of the request-streaming method and the response-streaming method. It is passed an iterator of request values and is itself an iterator of response values.
-
-### Starting the server
-
-Once you have implemented all the `RouteGuide` methods, the next step is to start up a gRPC server so that clients can actually use your service:
-
-```python
-def serve():
- server = route_guide_pb2.beta_create_RouteGuide_server(RouteGuideServicer())
- server.add_insecure_port('[::]:50051')
- server.start()
-```
-
-Because `start()` does not block you may need to sleep-loop if there is nothing else for your code to do while serving.
-
-<a name="client"></a>
-## Creating the client
-
-You can see the complete example client code in [route_guide_client.py](route_guide_client.py).
-
-### Creating a stub
-
-To call service methods, we first need to create a *stub*.
-
-We use the `beta_create_RouteGuide_stub` function of the `route_guide_pb2` module, generated from our .proto.
-
-```python
-channel = implementations.insecure_channel('localhost', 50051)
-stub = beta_create_RouteGuide_stub(channel)
-```
-
-The returned object implements all the methods defined by the `BetaRouteGuideStub` interface.
-
-### Calling service methods
-
-For RPC methods that return a single response ("response-unary" methods), gRPC Python supports both synchronous (blocking) and asynchronous (non-blocking) control flow semantics. For response-streaming RPC methods, calls immediately return an iterator of response values. Calls to that iterator's `next()` method block until the response to be yielded from the iterator becomes available.
-
-#### Simple RPC
-
-A synchronous call to the simple RPC `GetFeature` is nearly as straightforward as calling a local method. The RPC call waits for the server to respond, and will either return a response or raise an exception:
-
-```python
-feature = stub.GetFeature(point, timeout_in_seconds)
-```
-
-An asynchronous call to `GetFeature` is similar, but like calling a local method asynchronously in a thread pool:
-
-```python
-feature_future = stub.GetFeature.future(point, timeout_in_seconds)
-feature = feature_future.result()
-```
-
-#### Response-streaming RPC
-
-Calling the response-streaming `ListFeatures` is similar to working with sequence types:
-
-```python
-for feature in stub.ListFeatures(rectangle, timeout_in_seconds):
-```
-
-#### Request-streaming RPC
-
-Calling the request-streaming `RecordRoute` is similar to passing a sequence to a local method. Like the simple RPC above that also returns a single response, it can be called synchronously or asynchronously:
-
-```python
-route_summary = stub.RecordRoute(point_sequence, timeout_in_seconds)
-```
-
-```python
-route_summary_future = stub.RecordRoute.future(point_sequence, timeout_in_seconds)
-route_summary = route_summary_future.result()
-```
-
-#### Bidirectional streaming RPC
-
-Calling the bidirectionally-streaming `RouteChat` has (as is the case on the service-side) a combination of the request-streaming and response-streaming semantics:
-
-```python
-for received_route_note in stub.RouteChat(sent_routes, timeout_in_seconds):
-```
-
-## Try it out!
-
-Run the server, which will listen on port 50051:
-
-```shell
-$ python route_guide_server.py
-```
-
-Run the client (in a different terminal):
-
-```shell
-$ python route_guide_client.py
-```
+[This code's documentation lives on the grpc.io site.](http://www.grpc.io/docs/tutorials/basic/python.html)