mirror of https://github.com/grpc/grpc.git
commit
04ec4701e3
911 changed files with 37644 additions and 24358 deletions
@ -0,0 +1,47 @@ |
||||
bind( |
||||
name = "nanopb", |
||||
actual = "//third_party/nanopb", |
||||
) |
||||
|
||||
bind( |
||||
name = "libssl", |
||||
actual = "@submodule_boringssl//:ssl", |
||||
) |
||||
|
||||
bind( |
||||
name = "zlib", |
||||
actual = "@submodule_zlib//:z", |
||||
) |
||||
|
||||
bind( |
||||
name = "protobuf", |
||||
actual = "@submodule_protobuf//:protobuf", |
||||
) |
||||
|
||||
bind( |
||||
name = "protobuf_clib", |
||||
actual = "@submodule_protobuf//:protoc_lib", |
||||
) |
||||
|
||||
bind( |
||||
name = "protocol_compiler", |
||||
actual = "@submodule_protobuf//:protoc", |
||||
) |
||||
|
||||
new_local_repository( |
||||
name = "submodule_boringssl", |
||||
path = "third_party/boringssl-with-bazel", |
||||
build_file = "third_party/boringssl-with-bazel/BUILD", |
||||
) |
||||
|
||||
new_local_repository( |
||||
name = "submodule_zlib", |
||||
path = "third_party/zlib", |
||||
build_file = "third_party/zlib.BUILD", |
||||
) |
||||
|
||||
new_local_repository( |
||||
name = "submodule_protobuf", |
||||
path = "third_party/protobuf", |
||||
build_file = "third_party/protobuf/BUILD", |
||||
) |
@ -0,0 +1,46 @@ |
||||
# Copyright 2017, 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. |
||||
|
||||
licenses(["notice"]) # 3-clause BSD |
||||
|
||||
package(default_visibility = ["//:__subpackages__"]) |
||||
|
||||
load(":cc_grpc_library.bzl", "cc_grpc_library") |
||||
|
||||
proto_library( |
||||
name = "well_known_protos_list", |
||||
srcs = ["@submodule_protobuf//:well_known_protos"], |
||||
) |
||||
|
||||
cc_grpc_library( |
||||
name = "well_known_protos", |
||||
srcs = "well_known_protos_list", |
||||
deps = [], |
||||
proto_only = True, |
||||
) |
@ -0,0 +1,61 @@ |
||||
"""Generates and compiles C++ grpc stubs from proto_library rules.""" |
||||
|
||||
load("//:bazel/generate_cc.bzl", "generate_cc") |
||||
|
||||
def cc_grpc_library(name, srcs, deps, proto_only, **kwargs): |
||||
"""Generates C++ grpc classes from a .proto file. |
||||
|
||||
Assumes the generated classes will be used in cc_api_version = 2. |
||||
|
||||
Arguments: |
||||
name: name of rule. |
||||
srcs: a single proto_library, which wraps the .proto files with services. |
||||
deps: a list of C++ proto_library (or cc_proto_library) which provides |
||||
the compiled code of any message that the services depend on. |
||||
**kwargs: rest of arguments, e.g., compatible_with and visibility. |
||||
""" |
||||
if len(srcs) > 1: |
||||
fail("Only one srcs value supported", "srcs") |
||||
|
||||
proto_target = "_" + name + "_only" |
||||
codegen_target = "_" + name + "_codegen" |
||||
codegen_grpc_target = "_" + name + "_grpc_codegen" |
||||
proto_deps = ["_" + dep + "_only" for dep in deps if dep.find(':') == -1] |
||||
proto_deps += [dep.split(':')[0] + ':' + "_" + dep.split(':')[1] + "_only" for dep in deps if dep.find(':') != -1] |
||||
|
||||
native.proto_library( |
||||
name = proto_target, |
||||
srcs = srcs, |
||||
deps = proto_deps, |
||||
**kwargs |
||||
) |
||||
|
||||
generate_cc( |
||||
name = codegen_target, |
||||
srcs = [proto_target], |
||||
**kwargs |
||||
) |
||||
|
||||
if not proto_only: |
||||
generate_cc( |
||||
name = codegen_grpc_target, |
||||
srcs = [proto_target], |
||||
plugin = "//:grpc_cpp_plugin", |
||||
**kwargs |
||||
) |
||||
|
||||
native.cc_library( |
||||
name = name, |
||||
srcs = [":" + codegen_grpc_target, ":" + codegen_target], |
||||
hdrs = [":" + codegen_grpc_target, ":" + codegen_target], |
||||
deps = deps + ["//:grpc++", "//:grpc++_codegen_proto", "//external:protobuf"], |
||||
**kwargs |
||||
) |
||||
else: |
||||
native.cc_library( |
||||
name = name, |
||||
srcs = [":" + codegen_target], |
||||
hdrs = [":" + codegen_target], |
||||
deps = deps + ["//external:protobuf"], |
||||
**kwargs |
||||
) |
@ -0,0 +1,68 @@ |
||||
"""Generates C++ grpc stubs from proto_library rules. |
||||
|
||||
This is an internal rule used by cc_grpc_library, and shouldn't be used |
||||
directly. |
||||
""" |
||||
|
||||
def generate_cc_impl(ctx): |
||||
"""Implementation of the generate_cc rule.""" |
||||
protos = [f for src in ctx.attr.srcs for f in src.proto.direct_sources] |
||||
includes = [f for src in ctx.attr.srcs for f in src.proto.transitive_imports] |
||||
outs = [] |
||||
if ctx.executable.plugin: |
||||
outs += [proto.basename[:-len(".proto")] + ".grpc.pb.h" for proto in protos] |
||||
outs += [proto.basename[:-len(".proto")] + ".grpc.pb.cc" for proto in protos] |
||||
else: |
||||
outs += [proto.basename[:-len(".proto")] + ".pb.h" for proto in protos] |
||||
outs += [proto.basename[:-len(".proto")] + ".pb.cc" for proto in protos] |
||||
out_files = [ctx.new_file(out) for out in outs] |
||||
# The following should be replaced with ctx.configuration.buildout |
||||
# whenever this is added to Skylark. |
||||
dir_out = out_files[0].dirname[:-len(protos[0].dirname)] |
||||
|
||||
arguments = [] |
||||
if ctx.executable.plugin: |
||||
arguments += ["--plugin=protoc-gen-PLUGIN=" + ctx.executable.plugin.path] |
||||
arguments += ["--PLUGIN_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] |
||||
additional_input = [ctx.executable.plugin] |
||||
else: |
||||
arguments += ["--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] |
||||
additional_input = [] |
||||
arguments += ["-I{0}={0}".format(include.path) for include in includes] |
||||
arguments += [proto.path for proto in protos] |
||||
|
||||
ctx.action( |
||||
inputs = protos + includes + additional_input, |
||||
outputs = out_files, |
||||
executable = ctx.executable._protoc, |
||||
arguments = arguments, |
||||
) |
||||
|
||||
return struct(files=set(out_files)) |
||||
|
||||
generate_cc = rule( |
||||
attrs = { |
||||
"srcs": attr.label_list( |
||||
mandatory = True, |
||||
non_empty = True, |
||||
providers = ["proto"], |
||||
), |
||||
"plugin": attr.label( |
||||
executable = True, |
||||
providers = ["files_to_run"], |
||||
cfg = "host", |
||||
), |
||||
"flags": attr.string_list( |
||||
mandatory = False, |
||||
allow_empty = True, |
||||
), |
||||
"_protoc": attr.label( |
||||
default = Label("//external:protocol_compiler"), |
||||
executable = True, |
||||
cfg = "host", |
||||
), |
||||
}, |
||||
# We generate .h files, so we need to output to genfiles. |
||||
output_to_genfiles = True, |
||||
implementation = generate_cc_impl, |
||||
) |
@ -0,0 +1,68 @@ |
||||
# Copyright 2016, 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. |
||||
|
||||
# |
||||
# This is for the gRPC build system. This isn't intended to be used outsite of |
||||
# the BUILD file for gRPC. It contains the mapping for the template system we |
||||
# use to generate other platform's build system files. |
||||
# |
||||
|
||||
def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language = "C++"): |
||||
copts = [] |
||||
if language.upper() == "C": |
||||
copts = ["-std=c99"] |
||||
native.cc_library( |
||||
name = name, |
||||
srcs = srcs, |
||||
hdrs = hdrs + public_hdrs, |
||||
deps = deps + ["//external:" + dep for dep in external_deps], |
||||
copts = copts, |
||||
linkopts = ["-pthread"], |
||||
includes = [ |
||||
"include" |
||||
] |
||||
) |
||||
|
||||
def grpc_proto_plugin(name, srcs = [], deps = []): |
||||
native.cc_binary( |
||||
name = name, |
||||
srcs = srcs, |
||||
deps = deps, |
||||
) |
||||
|
||||
load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library") |
||||
|
||||
def grpc_proto_library(name, srcs = [], deps = [], well_known_deps = [], has_services = True): |
||||
cc_grpc_library( |
||||
name = name, |
||||
srcs = srcs, |
||||
deps = deps, |
||||
proto_only = not has_services, |
||||
) |
||||
|
@ -0,0 +1,32 @@ |
||||
# Copyright 2017, 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. |
||||
|
||||
module GrpcBuildConfig |
||||
CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-2.dll' |
||||
end |
@ -0,0 +1,29 @@ |
||||
# C++ Performance Notes |
||||
|
||||
## Streaming write buffering |
||||
|
||||
Generally, each write operation (Write(), WritesDone()) implies a syscall. |
||||
gRPC will try to batch together separate write operations from different |
||||
threads, but currently cannot automatically infer batching in a single stream. |
||||
|
||||
If message k+1 in a stream does not rely on responses from message k, it's |
||||
possible to enable write batching by passing a WriteOptions argument to Write |
||||
with the buffer_hint set: |
||||
|
||||
~~~{.cpp} |
||||
stream_writer->Write(message, WriteOptions().set_buffer_hint()); |
||||
~~~ |
||||
|
||||
The write will be buffered until one of the following is true: |
||||
- the per-stream buffer is filled (controllable with the channel argument |
||||
GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE) - this prevents infinite buffering leading |
||||
to OOM |
||||
- a subsequent Write without buffer_hint set is posted |
||||
- the call is finished for writing (WritesDone() called on the client, |
||||
or Finish() called on an async server stream, or the service handler returns |
||||
for a sync server stream) |
||||
|
||||
## Completion Queues and Threading in the Async API |
||||
|
||||
Right now, the best performance trade-off is having numcpu's threads and one |
||||
completion queue per thread. |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 39 KiB |
@ -1,30 +1,65 @@ |
||||
#gRPC Naming and Discovery Support |
||||
# gRPC Name Resolution |
||||
|
||||
## Overview |
||||
|
||||
gRPC supports DNS as the default name-system. A number of alternative name-systems are used in various deployments. We propose an API that is general enough to support a range of name-systems and the corresponding syntax for names. The gRPC client library in various languages will provide a plugin mechanism so resolvers for different name-systems can be plugged in. |
||||
gRPC supports DNS as the default name-system. A number of alternative |
||||
name-systems are used in various deployments. We support an API that is |
||||
general enough to support a range of name-systems and the corresponding |
||||
syntax for names. The gRPC client library in various languages will |
||||
provide a plugin mechanism so resolvers for different name-systems can |
||||
be plugged in. |
||||
|
||||
## Detailed Proposal |
||||
## Detailed Design |
||||
|
||||
A fully qualified, self contained name used for gRPC channel construction uses the syntax: |
||||
### Name Syntax |
||||
|
||||
A fully qualified, self contained name used for gRPC channel construction |
||||
uses the syntax: |
||||
|
||||
``` |
||||
scheme://authority/endpoint_name |
||||
``` |
||||
|
||||
Here, scheme indicates the name-system to be used. Example schemes to be supported include: |
||||
Here, `scheme` indicates the name-system to be used. Currently, we |
||||
support the following schemes: |
||||
|
||||
- `dns` |
||||
|
||||
- `ipv4` (IPv4 address) |
||||
|
||||
- `ipv6` (IPv6 address) |
||||
|
||||
- `unix` (path to unix domain socket -- unix systems only) |
||||
|
||||
* `dns` |
||||
In the future, additional schemes such as `etcd` could be added. |
||||
|
||||
* `etcd` |
||||
The `authority` indicates some scheme-specific bootstrap information, e.g., |
||||
for DNS, the authority may include the IP[:port] of the DNS server to |
||||
use. Often, a DNS name may be used as the authority, since the ability to |
||||
resolve DNS names is already built into all gRPC client libraries. |
||||
|
||||
Authority indicates some scheme-specific bootstrap information, e.g., for DNS, the authority may include the IP[:port] of the DNS server to use. Often, a DNS name may used as the authority, since the ability to resolve DNS names is already built into all gRPC client libraries. |
||||
Finally, the `endpoint_name` indicates a concrete name to be looked up |
||||
in a given name-system identified by the scheme and the authority. The |
||||
syntax of the endpoint name is dictated by the scheme in use. |
||||
|
||||
Finally, the endpoint_name indicates a concrete name to be looked up in a given name-system identified by the scheme and the authority. The syntax of endpoint name is dictated by the scheme in use. |
||||
### Resolver Plugins |
||||
|
||||
### Plugins |
||||
The gRPC client library will use the specified scheme to pick the right |
||||
resolver plugin and pass it the fully qualified name string. |
||||
|
||||
The gRPC client library will switch on the scheme to pick the right resolver plugin and pass it the fully qualified name string. |
||||
Resolvers should be able to contact the authority and get a resolution |
||||
that they return back to the gRPC client library. The returned contents |
||||
include: |
||||
|
||||
Resolvers should be able to contact the authority and get a resolution that they return back to the gRPC client library. The returned contents include a list of IP:port, an optional config and optional auth config data to be used for channel authentication. The plugin API allows the resolvers to continuously watch an endpoint_name and return updated resolutions as needed. |
||||
- A list of resolved addresses, each of which has three attributes: |
||||
- The address itself, including both IP address and port. |
||||
- A boolean indicating whether the address is a backend address (i.e., |
||||
the address to use to contact the server directly) or a balancer |
||||
address (for cases where [external load balancing](load-balancing.md) |
||||
is in use). |
||||
- The name of the balancer, if the address is a balancer address. |
||||
This will be used to perform peer authorization. |
||||
- A [service config](service_config.md). |
||||
|
||||
The plugin API allows the resolvers to continuously watch an endpoint |
||||
and return updated resolutions as needed. |
||||
|
@ -0,0 +1,195 @@ |
||||
Negative HTTP/2 Interop Test Case Descriptions |
||||
======================================= |
||||
|
||||
Client and server use |
||||
[test.proto](../src/proto/grpc/testing/test.proto). |
||||
|
||||
Server |
||||
------ |
||||
The code for the custom http2 server can be found |
||||
[here](https://github.com/grpc/grpc/tree/master/test/http2_test). |
||||
It is responsible for handling requests and sending responses, and also for |
||||
fulfilling the behavior of each particular test case. |
||||
|
||||
Server should accept these arguments: |
||||
* --port=PORT |
||||
* The port the server will run on. For example, "8080" |
||||
* --test_case=TESTCASE |
||||
* The name of the test case to execute. For example, "goaway" |
||||
|
||||
Client |
||||
------ |
||||
|
||||
Clients implement test cases that test certain functionality. Each client is |
||||
provided the test case it is expected to run as a command-line parameter. Names |
||||
should be lowercase and without spaces. |
||||
|
||||
Clients should accept these arguments: |
||||
* --server_host=HOSTNAME |
||||
* The server host to connect to. For example, "localhost" or "127.0.0.1" |
||||
* --server_port=PORT |
||||
* The server port to connect to. For example, "8080" |
||||
* --test_case=TESTCASE |
||||
* The name of the test case to execute. For example, "goaway" |
||||
|
||||
Note |
||||
----- |
||||
|
||||
Note that the server and client must be invoked with the same test case or else |
||||
the test will be meaningless. For convenience, we provide a shell script wrapper |
||||
that invokes both server and client at the same time, with the same test_case. |
||||
This is the preferred way to run these tests. |
||||
|
||||
## Test Cases |
||||
|
||||
### goaway |
||||
|
||||
This test verifies that the client correctly responds to a goaway sent by the |
||||
server. The client should handle the goaway by switching to a new stream without |
||||
the user application having to do a thing. |
||||
|
||||
Client Procedure: |
||||
1. Client sends two UnaryCall requests (and sleeps for 1 second in-between). |
||||
TODO: resolve [9300](https://github.com/grpc/grpc/issues/9300) and remove the 1 second sleep |
||||
|
||||
``` |
||||
{ |
||||
response_size: 314159 |
||||
payload:{ |
||||
body: 271828 bytes of zeros |
||||
} |
||||
} |
||||
``` |
||||
|
||||
Client asserts: |
||||
* Both calls are successful. |
||||
* Response payload body is 314159 bytes in size. |
||||
|
||||
Server Procedure: |
||||
1. Server sends a GOAWAY after receiving the first UnaryCall. |
||||
|
||||
Server asserts: |
||||
* Two different connections were used from the client. |
||||
|
||||
### rst_after_header |
||||
|
||||
This test verifies that the client fails correctly when the server sends a |
||||
RST_STREAM immediately after sending headers to the client. |
||||
|
||||
Procedure: |
||||
1. Client sends UnaryCall with: |
||||
|
||||
``` |
||||
{ |
||||
response_size: 314159 |
||||
payload:{ |
||||
body: 271828 bytes of zeros |
||||
} |
||||
} |
||||
``` |
||||
|
||||
Client asserts: |
||||
* Call was not successful. |
||||
|
||||
Server Procedure: |
||||
1. Server sends a RST_STREAM with error code 0 after sending headers to the client. |
||||
|
||||
*At the moment the error code and message returned are not standardized throughout all |
||||
languages. Those checks will be added once all client languages behave the same way. [#9142](https://github.com/grpc/grpc/issues/9142) is in flight.* |
||||
|
||||
### rst_during_data |
||||
|
||||
This test verifies that the client fails "correctly" when the server sends a |
||||
RST_STREAM halfway through sending data to the client. |
||||
|
||||
Procedure: |
||||
1. Client sends UnaryCall with: |
||||
|
||||
``` |
||||
{ |
||||
response_size: 314159 |
||||
payload:{ |
||||
body: 271828 bytes of zeros |
||||
} |
||||
} |
||||
``` |
||||
|
||||
Client asserts: |
||||
* Call was not successful. |
||||
|
||||
Server Procedure: |
||||
1. Server sends a RST_STREAM with error code 0 after sending half of |
||||
the requested data to the client. |
||||
|
||||
### rst_after_data |
||||
|
||||
This test verifies that the client fails "correctly" when the server sends a |
||||
RST_STREAM after sending all of the data to the client. |
||||
|
||||
Procedure: |
||||
1. Client sends UnaryCall with: |
||||
|
||||
``` |
||||
{ |
||||
response_size: 314159 |
||||
payload:{ |
||||
body: 271828 bytes of zeros |
||||
} |
||||
} |
||||
``` |
||||
|
||||
Client asserts: |
||||
* Call was not successful. |
||||
|
||||
Server Procedure: |
||||
1. Server sends a RST_STREAM with error code 0 after sending all of the |
||||
data to the client. |
||||
|
||||
*Certain client languages allow the data to be accessed even though a RST_STREAM |
||||
was encountered. Once all client languages behave this way, checks will be added on |
||||
the incoming data.* |
||||
|
||||
### ping |
||||
|
||||
This test verifies that the client correctly acknowledges all pings it gets from the |
||||
server. |
||||
|
||||
Procedure: |
||||
1. Client sends UnaryCall with: |
||||
|
||||
``` |
||||
{ |
||||
response_size: 314159 |
||||
payload:{ |
||||
body: 271828 bytes of zeros |
||||
} |
||||
} |
||||
``` |
||||
|
||||
Client asserts: |
||||
* call was successful. |
||||
* response payload body is 314159 bytes in size. |
||||
|
||||
Server Procedure: |
||||
1. Server tracks the number of outstanding pings (i.e. +1 when it sends a ping, and -1 |
||||
when it receives an ack from the client). |
||||
2. Server sends pings before and after sending headers, also before and after sending data. |
||||
|
||||
Server Asserts: |
||||
* Number of outstanding pings is 0 when the connection is lost. |
||||
|
||||
### max_streams |
||||
|
||||
This test verifies that the client observes the MAX_CONCURRENT_STREAMS limit set by the server. |
||||
|
||||
Client Procedure: |
||||
1. Client sends initial UnaryCall to allow the server to update its MAX_CONCURRENT_STREAMS settings. |
||||
2. Client concurrently sends 10 UnaryCalls. |
||||
|
||||
Client Asserts: |
||||
* All UnaryCalls were successful, and had the correct type and payload size. |
||||
|
||||
Server Procedure: |
||||
1. Sets MAX_CONCURRENT_STREAMS to one after the connection is made. |
||||
|
||||
*The assertion that the MAX_CONCURRENT_STREAMS limit is upheld occurs in the http2 library we used.* |
@ -0,0 +1,147 @@ |
||||
Service Config in gRPC |
||||
====================== |
||||
|
||||
# Objective |
||||
|
||||
The service config is a mechanism that allows service owners to publish |
||||
parameters to be automatically used by all clients of their service. |
||||
|
||||
# Format |
||||
|
||||
The service config is a JSON string of the following form: |
||||
|
||||
``` |
||||
{ |
||||
# Load balancing policy name. |
||||
# Supported values are 'round_robin' and 'grpclb'. |
||||
# Optional; if unset, the default behavior is pick the first available |
||||
# backend. |
||||
# Note that if the resolver returns only balancer addresses and no |
||||
# backend addresses, gRPC will always use the 'grpclb' policy, |
||||
# regardless of what this field is set to. |
||||
'loadBalancingPolicy': string, |
||||
|
||||
# Per-method configuration. Optional. |
||||
'methodConfig': [ |
||||
{ |
||||
# The names of the methods to which this method config applies. There |
||||
# must be at least one name. Each name entry must be unique across the |
||||
# entire service config. If the 'method' field is empty, then this |
||||
# method config specifies the defaults for all methods for the specified |
||||
# service. |
||||
# |
||||
# For example, let's say that the service config contains the following |
||||
# method config entries: |
||||
# |
||||
# 'methodConfig': [ |
||||
# { 'name': [ { 'service': 'MyService' } ] ... }, |
||||
# { 'name': [ { 'service': 'MyService', 'method': 'Foo' } ] ... } |
||||
# ] |
||||
# |
||||
# For a request for MyService/Foo, we will use the second entry, because |
||||
# it exactly matches the service and method name. |
||||
# For a request for MyService/Bar, we will use the first entry, because |
||||
# it provides the default for all methods of MyService. |
||||
'name': [ |
||||
{ |
||||
# RPC service name. Required. |
||||
# If using gRPC with protobuf as the IDL, then this will be of |
||||
# the form "pkg.service_name", where "pkg" is the package name |
||||
# defined in the proto file. |
||||
'service': string, |
||||
|
||||
# RPC method name. Optional (see above). |
||||
'method': string, |
||||
} |
||||
], |
||||
|
||||
# Whether RPCs sent to this method should wait until the connection is |
||||
# ready by default. If false, the RPC will abort immediately if there |
||||
# is a transient failure connecting to the server. Otherwise, gRPC will |
||||
# attempt to connect until the deadline is exceeded. |
||||
# |
||||
# The value specified via the gRPC client API will override the value |
||||
# set here. However, note that setting the value in the client API will |
||||
# also affect transient errors encountered during name resolution, |
||||
# which cannot be caught by the value here, since the service config |
||||
# is obtained by the gRPC client via name resolution. |
||||
'waitForReady': bool, |
||||
|
||||
# The default timeout in seconds for RPCs sent to this method. This can |
||||
# be overridden in code. If no reply is received in the specified amount |
||||
# of time, the request is aborted and a deadline-exceeded error status |
||||
# is returned to the caller. |
||||
# |
||||
# The actual deadline used will be the minimum of the value specified |
||||
# here and the value set by the application via the gRPC client API. |
||||
# If either one is not set, then the other will be used. |
||||
# If neither is set, then the request has no deadline. |
||||
# |
||||
# The format of the value is that of the 'Duration' type defined here: |
||||
# https://developers.google.com/protocol-buffers/docs/proto3#json |
||||
'timeout': string, |
||||
|
||||
# The maximum allowed payload size for an individual request or object |
||||
# in a stream (client->server) in bytes. The size which is measured is |
||||
# the serialized, uncompressed payload in bytes. This applies both |
||||
# to streaming and non-streaming requests. |
||||
# |
||||
# The actual value used is the minimum of the value specified here and |
||||
# the value set by the application via the gRPC client API. |
||||
# If either one is not set, then the other will be used. |
||||
# If neither is set, then the built-in default is used. |
||||
# |
||||
# If a client attempts to send an object larger than this value, it |
||||
# will not be sent and the client will see an error. |
||||
# Note that 0 is a valid value, meaning that the request message must |
||||
# be empty. |
||||
# |
||||
# The format of the value is that of the 'uint64' type defined here: |
||||
# https://developers.google.com/protocol-buffers/docs/proto3#json |
||||
'maxRequestMessageBytes': string, |
||||
|
||||
# The maximum allowed payload size for an individual response or object |
||||
# in a stream (server->client) in bytes. The size which is measured is |
||||
# the serialized, uncompressed payload in bytes. This applies both |
||||
# to streaming and non-streaming requests. |
||||
# |
||||
# The actual value used is the minimum of the value specified here and |
||||
# the value set by the application via the gRPC client API. |
||||
# If either one is not set, then the other will be used. |
||||
# If neither is set, then the built-in default is used. |
||||
# |
||||
# If a server attempts to send an object larger than this value, it |
||||
# will not be sent, and the client will see an error. |
||||
# Note that 0 is a valid value, meaning that the response message must |
||||
# be empty. |
||||
# |
||||
# The format of the value is that of the 'uint64' type defined here: |
||||
# https://developers.google.com/protocol-buffers/docs/proto3#json |
||||
'maxResponseMessageBytes': string |
||||
} |
||||
] |
||||
} |
||||
``` |
||||
|
||||
Note that new per-method parameters may be added in the future as new |
||||
functionality is introduced. |
||||
|
||||
# Architecture |
||||
|
||||
A service config is associated with a server name. The [name |
||||
resolver](naming.md) plugin, when asked to resolve a particular server |
||||
name, will return both the resolved addresses and the service config. |
||||
|
||||
TODO(roth): Design how the service config will be encoded in DNS. |
||||
|
||||
# APIs |
||||
|
||||
The service config is used in the following APIs: |
||||
|
||||
- In the resolver API, used by resolver plugins to return the service |
||||
config to the gRPC client. |
||||
- In the gRPC client API, where users can query the channel to obtain |
||||
the service config associated with the channel (for debugging |
||||
purposes). |
||||
- In the gRPC client API, where users can set the service config |
||||
explicitly. This is intended for use in unit tests. |
@ -0,0 +1,42 @@ |
||||
# Copyright 2017, 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. |
||||
|
||||
cc_binary( |
||||
name = "greeter_client", |
||||
srcs = ["greeter_client.cc"], |
||||
deps = ["//examples/protos:helloworld"], |
||||
defines = ["BAZEL_BUILD"], |
||||
) |
||||
|
||||
cc_binary( |
||||
name = "greeter_server", |
||||
srcs = ["greeter_server.cc"], |
||||
deps = ["//examples/protos:helloworld"], |
||||
defines = ["BAZEL_BUILD"], |
||||
) |
@ -0,0 +1,52 @@ |
||||
# Copyright 2017, 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. |
||||
|
||||
package(default_visibility = ["//visibility:public"]) |
||||
|
||||
load("//bazel:grpc_build_system.bzl", "grpc_proto_library") |
||||
|
||||
grpc_proto_library( |
||||
name = "auth_sample", |
||||
srcs = ["auth_sample.proto"], |
||||
) |
||||
|
||||
grpc_proto_library( |
||||
name = "hellostreamingworld", |
||||
srcs = ["hellostreamingworld.proto"], |
||||
) |
||||
|
||||
grpc_proto_library( |
||||
name = "helloworld", |
||||
srcs = ["helloworld.proto"], |
||||
) |
||||
|
||||
grpc_proto_library( |
||||
name = "route_guide", |
||||
srcs = ["route_guide.proto"], |
||||
) |
@ -0,0 +1,47 @@ |
||||
import grpc |
||||
from grpc.framework.common import cardinality |
||||
from grpc.framework.interfaces.face import utilities as face_utilities |
||||
|
||||
import helloworld_pb2 as helloworld__pb2 |
||||
|
||||
|
||||
class GreeterStub(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.SayHello = channel.unary_unary( |
||||
'/helloworld.Greeter/SayHello', |
||||
request_serializer=helloworld__pb2.HelloRequest.SerializeToString, |
||||
response_deserializer=helloworld__pb2.HelloReply.FromString, |
||||
) |
||||
|
||||
|
||||
class GreeterServicer(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def SayHello(self, request, context): |
||||
"""Sends a greeting |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'SayHello': grpc.unary_unary_rpc_method_handler( |
||||
servicer.SayHello, |
||||
request_deserializer=helloworld__pb2.HelloRequest.FromString, |
||||
response_serializer=helloworld__pb2.HelloReply.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'helloworld.Greeter', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -0,0 +1,47 @@ |
||||
import grpc |
||||
from grpc.framework.common import cardinality |
||||
from grpc.framework.interfaces.face import utilities as face_utilities |
||||
|
||||
import helloworld_pb2 as helloworld__pb2 |
||||
|
||||
|
||||
class GreeterStub(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.SayHello = channel.unary_unary( |
||||
'/helloworld.Greeter/SayHello', |
||||
request_serializer=helloworld__pb2.HelloRequest.SerializeToString, |
||||
response_deserializer=helloworld__pb2.HelloReply.FromString, |
||||
) |
||||
|
||||
|
||||
class GreeterServicer(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def SayHello(self, request, context): |
||||
"""Sends a greeting |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'SayHello': grpc.unary_unary_rpc_method_handler( |
||||
servicer.SayHello, |
||||
request_deserializer=helloworld__pb2.HelloRequest.FromString, |
||||
response_serializer=helloworld__pb2.HelloReply.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'helloworld.Greeter', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -0,0 +1,114 @@ |
||||
import grpc |
||||
from grpc.framework.common import cardinality |
||||
from grpc.framework.interfaces.face import utilities as face_utilities |
||||
|
||||
import route_guide_pb2 as route__guide__pb2 |
||||
|
||||
|
||||
class RouteGuideStub(object): |
||||
"""Interface exported by the server. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.GetFeature = channel.unary_unary( |
||||
'/routeguide.RouteGuide/GetFeature', |
||||
request_serializer=route__guide__pb2.Point.SerializeToString, |
||||
response_deserializer=route__guide__pb2.Feature.FromString, |
||||
) |
||||
self.ListFeatures = channel.unary_stream( |
||||
'/routeguide.RouteGuide/ListFeatures', |
||||
request_serializer=route__guide__pb2.Rectangle.SerializeToString, |
||||
response_deserializer=route__guide__pb2.Feature.FromString, |
||||
) |
||||
self.RecordRoute = channel.stream_unary( |
||||
'/routeguide.RouteGuide/RecordRoute', |
||||
request_serializer=route__guide__pb2.Point.SerializeToString, |
||||
response_deserializer=route__guide__pb2.RouteSummary.FromString, |
||||
) |
||||
self.RouteChat = channel.stream_stream( |
||||
'/routeguide.RouteGuide/RouteChat', |
||||
request_serializer=route__guide__pb2.RouteNote.SerializeToString, |
||||
response_deserializer=route__guide__pb2.RouteNote.FromString, |
||||
) |
||||
|
||||
|
||||
class RouteGuideServicer(object): |
||||
"""Interface exported by the server. |
||||
""" |
||||
|
||||
def GetFeature(self, request, context): |
||||
"""A simple RPC. |
||||
|
||||
Obtains the feature at a given position. |
||||
|
||||
A feature with an empty name is returned if there's no feature at the given |
||||
position. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def ListFeatures(self, request, context): |
||||
"""A server-to-client streaming RPC. |
||||
|
||||
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. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def RecordRoute(self, request_iterator, context): |
||||
"""A client-to-server streaming RPC. |
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a |
||||
RouteSummary when traversal is completed. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def RouteChat(self, request_iterator, context): |
||||
"""A Bidirectional streaming RPC. |
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed, |
||||
while receiving other RouteNotes (e.g. from other users). |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_RouteGuideServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'GetFeature': grpc.unary_unary_rpc_method_handler( |
||||
servicer.GetFeature, |
||||
request_deserializer=route__guide__pb2.Point.FromString, |
||||
response_serializer=route__guide__pb2.Feature.SerializeToString, |
||||
), |
||||
'ListFeatures': grpc.unary_stream_rpc_method_handler( |
||||
servicer.ListFeatures, |
||||
request_deserializer=route__guide__pb2.Rectangle.FromString, |
||||
response_serializer=route__guide__pb2.Feature.SerializeToString, |
||||
), |
||||
'RecordRoute': grpc.stream_unary_rpc_method_handler( |
||||
servicer.RecordRoute, |
||||
request_deserializer=route__guide__pb2.Point.FromString, |
||||
response_serializer=route__guide__pb2.RouteSummary.SerializeToString, |
||||
), |
||||
'RouteChat': grpc.stream_stream_rpc_method_handler( |
||||
servicer.RouteChat, |
||||
request_deserializer=route__guide__pb2.RouteNote.FromString, |
||||
response_serializer=route__guide__pb2.RouteNote.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'routeguide.RouteGuide', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -0,0 +1,114 @@ |
||||
import grpc |
||||
from grpc.framework.common import cardinality |
||||
from grpc.framework.interfaces.face import utilities as face_utilities |
||||
|
||||
import route_guide_pb2 as route__guide__pb2 |
||||
|
||||
|
||||
class RouteGuideStub(object): |
||||
"""Interface exported by the server. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.GetFeature = channel.unary_unary( |
||||
'/routeguide.RouteGuide/GetFeature', |
||||
request_serializer=route__guide__pb2.Point.SerializeToString, |
||||
response_deserializer=route__guide__pb2.Feature.FromString, |
||||
) |
||||
self.ListFeatures = channel.unary_stream( |
||||
'/routeguide.RouteGuide/ListFeatures', |
||||
request_serializer=route__guide__pb2.Rectangle.SerializeToString, |
||||
response_deserializer=route__guide__pb2.Feature.FromString, |
||||
) |
||||
self.RecordRoute = channel.stream_unary( |
||||
'/routeguide.RouteGuide/RecordRoute', |
||||
request_serializer=route__guide__pb2.Point.SerializeToString, |
||||
response_deserializer=route__guide__pb2.RouteSummary.FromString, |
||||
) |
||||
self.RouteChat = channel.stream_stream( |
||||
'/routeguide.RouteGuide/RouteChat', |
||||
request_serializer=route__guide__pb2.RouteNote.SerializeToString, |
||||
response_deserializer=route__guide__pb2.RouteNote.FromString, |
||||
) |
||||
|
||||
|
||||
class RouteGuideServicer(object): |
||||
"""Interface exported by the server. |
||||
""" |
||||
|
||||
def GetFeature(self, request, context): |
||||
"""A simple RPC. |
||||
|
||||
Obtains the feature at a given position. |
||||
|
||||
A feature with an empty name is returned if there's no feature at the given |
||||
position. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def ListFeatures(self, request, context): |
||||
"""A server-to-client streaming RPC. |
||||
|
||||
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. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def RecordRoute(self, request_iterator, context): |
||||
"""A client-to-server streaming RPC. |
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a |
||||
RouteSummary when traversal is completed. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def RouteChat(self, request_iterator, context): |
||||
"""A Bidirectional streaming RPC. |
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed, |
||||
while receiving other RouteNotes (e.g. from other users). |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_RouteGuideServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'GetFeature': grpc.unary_unary_rpc_method_handler( |
||||
servicer.GetFeature, |
||||
request_deserializer=route__guide__pb2.Point.FromString, |
||||
response_serializer=route__guide__pb2.Feature.SerializeToString, |
||||
), |
||||
'ListFeatures': grpc.unary_stream_rpc_method_handler( |
||||
servicer.ListFeatures, |
||||
request_deserializer=route__guide__pb2.Rectangle.FromString, |
||||
response_serializer=route__guide__pb2.Feature.SerializeToString, |
||||
), |
||||
'RecordRoute': grpc.stream_unary_rpc_method_handler( |
||||
servicer.RecordRoute, |
||||
request_deserializer=route__guide__pb2.Point.FromString, |
||||
response_serializer=route__guide__pb2.RouteSummary.SerializeToString, |
||||
), |
||||
'RouteChat': grpc.stream_stream_rpc_method_handler( |
||||
servicer.RouteChat, |
||||
request_deserializer=route__guide__pb2.RouteNote.FromString, |
||||
response_serializer=route__guide__pb2.RouteNote.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'routeguide.RouteGuide', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -0,0 +1,84 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, 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. |
||||
* |
||||
*/ |
||||
#ifndef GRPC_IMPL_CODEGEN_GPR_SLICE_H |
||||
#define GRPC_IMPL_CODEGEN_GPR_SLICE_H |
||||
|
||||
/* WARNING: Please do not use this header. This was added as a temporary measure
|
||||
* to not break some of the external projects that depend on gpr_slice_* |
||||
* functions. We are actively working on moving all the gpr_slice_* references |
||||
* to grpc_slice_* and this file will be removed |
||||
* */ |
||||
|
||||
/* TODO (sreek) - Allowed by default but will be very soon turned off */ |
||||
#define GRPC_ALLOW_GPR_SLICE_FUNCTIONS 1 |
||||
|
||||
#ifdef GRPC_ALLOW_GPR_SLICE_FUNCTIONS |
||||
|
||||
#define gpr_slice_refcount grpc_slice_refcount |
||||
#define gpr_slice grpc_slice |
||||
#define gpr_slice_buffer grpc_slice_buffer |
||||
|
||||
#define gpr_slice_ref grpc_slice_ref |
||||
#define gpr_slice_unref grpc_slice_unref |
||||
#define gpr_slice_new grpc_slice_new |
||||
#define gpr_slice_new_with_user_data grpc_slice_new_with_user_data |
||||
#define gpr_slice_new_with_len grpc_slice_new_with_len |
||||
#define gpr_slice_malloc grpc_slice_malloc |
||||
#define gpr_slice_from_copied_string grpc_slice_from_copied_string |
||||
#define gpr_slice_from_copied_buffer grpc_slice_from_copied_buffer |
||||
#define gpr_slice_from_static_string grpc_slice_from_static_string |
||||
#define gpr_slice_sub grpc_slice_sub |
||||
#define gpr_slice_sub_no_ref grpc_slice_sub_no_ref |
||||
#define gpr_slice_split_tail grpc_slice_split_tail |
||||
#define gpr_slice_split_head grpc_slice_split_head |
||||
#define gpr_slice_cmp grpc_slice_cmp |
||||
#define gpr_slice_str_cmp grpc_slice_str_cmp |
||||
|
||||
#define gpr_slice_buffer grpc_slice_buffer |
||||
#define gpr_slice_buffer_init grpc_slice_buffer_init |
||||
#define gpr_slice_buffer_destroy grpc_slice_buffer_destroy |
||||
#define gpr_slice_buffer_add grpc_slice_buffer_add |
||||
#define gpr_slice_buffer_add_indexed grpc_slice_buffer_add_indexed |
||||
#define gpr_slice_buffer_addn grpc_slice_buffer_addn |
||||
#define gpr_slice_buffer_tiny_add grpc_slice_buffer_tiny_add |
||||
#define gpr_slice_buffer_pop grpc_slice_buffer_pop |
||||
#define gpr_slice_buffer_reset_and_unref grpc_slice_buffer_reset_and_unref |
||||
#define gpr_slice_buffer_swap grpc_slice_buffer_swap |
||||
#define gpr_slice_buffer_move_into grpc_slice_buffer_move_into |
||||
#define gpr_slice_buffer_trim_end grpc_slice_buffer_trim_end |
||||
#define gpr_slice_buffer_move_first grpc_slice_buffer_move_first |
||||
#define gpr_slice_buffer_take_first grpc_slice_buffer_take_first |
||||
|
||||
#endif /* GRPC_ALLOW_GPR_SLICE_FUNCTIONS */ |
||||
|
||||
#endif /* GRPC_IMPL_CODEGEN_GPR_SLICE_H */ |
@ -0,0 +1,5 @@ |
||||
Optional plugins for gRPC Core: Modules in this directory extend gRPC Core in |
||||
useful ways. All optional code belongs here. |
||||
|
||||
NOTE: The movement of code between lib and ext is an ongoing effort, so this |
||||
directory currently contains too much of the core library. |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue