mirror of https://github.com/grpc/grpc.git
commit
b44e089d29
393 changed files with 34433 additions and 15178 deletions
File diff suppressed because it is too large
Load Diff
@ -1,9 +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 = "@submodule_protobuf//:well_known_protos", |
||||
srcs = "well_known_protos_list", |
||||
deps = [], |
||||
proto_only = True, |
||||
) |
||||
|
@ -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 |
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,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,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 */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,214 @@ |
||||
/* |
||||
* |
||||
* 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. |
||||
* |
||||
*/ |
||||
|
||||
#import <XCTest/XCTest.h> |
||||
#import <sys/socket.h> |
||||
#import <netinet/in.h> |
||||
|
||||
#import <Cronet/Cronet.h> |
||||
#import <grpc/support/host_port.h> |
||||
#import <grpc/grpc_cronet.h> |
||||
#import <grpc/grpc.h> |
||||
#import "test/core/end2end/cq_verifier.h" |
||||
#import "test/core/util/port.h" |
||||
|
||||
#import <grpc/support/alloc.h> |
||||
#import <grpc/support/log.h> |
||||
|
||||
#import "src/core/lib/channel/channel_args.h" |
||||
#import "src/core/lib/support/env.h" |
||||
#import "src/core/lib/support/string.h" |
||||
#import "src/core/lib/support/tmpfile.h" |
||||
#import "test/core/util/test_config.h" |
||||
|
||||
static void drain_cq(grpc_completion_queue *cq) { |
||||
grpc_event ev; |
||||
do { |
||||
ev = grpc_completion_queue_next(cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL); |
||||
} while (ev.type != GRPC_QUEUE_SHUTDOWN); |
||||
} |
||||
|
||||
|
||||
@interface CronetUnitTests : XCTestCase |
||||
|
||||
@end |
||||
|
||||
@implementation CronetUnitTests |
||||
|
||||
+ (void)setUp { |
||||
[super setUp]; |
||||
|
||||
/*** FILE *roots_file; |
||||
size_t roots_size = strlen(test_root_cert);*/ |
||||
|
||||
char *argv[] = {"CoreCronetEnd2EndTests"}; |
||||
grpc_test_init(1, argv); |
||||
|
||||
grpc_init(); |
||||
|
||||
[Cronet setHttp2Enabled:YES]; |
||||
NSURL *url = [[[NSFileManager defaultManager] |
||||
URLsForDirectory:NSDocumentDirectory |
||||
inDomains:NSUserDomainMask] lastObject]; |
||||
NSLog(@"Documents directory: %@", url); |
||||
[Cronet start]; |
||||
[Cronet startNetLogToFile:@"Documents/cronet_netlog.json" logBytes:YES]; |
||||
} |
||||
|
||||
+ (void)tearDown { |
||||
grpc_shutdown(); |
||||
|
||||
[super tearDown]; |
||||
} |
||||
|
||||
- (void)testInternalError { |
||||
grpc_call *c; |
||||
grpc_slice request_payload_slice = |
||||
grpc_slice_from_copied_string("hello world"); |
||||
grpc_byte_buffer *request_payload = |
||||
grpc_raw_byte_buffer_create(&request_payload_slice, 1); |
||||
gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5); |
||||
grpc_metadata meta_c[2] = { |
||||
{"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, |
||||
{"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; |
||||
|
||||
int port = grpc_pick_unused_port_or_die(); |
||||
char *addr; |
||||
gpr_join_host_port(&addr, "127.0.0.1", port); |
||||
grpc_completion_queue *cq = grpc_completion_queue_create(NULL); |
||||
cronet_engine *cronetEngine = [Cronet getGlobalEngine]; |
||||
grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, |
||||
NULL, NULL); |
||||
|
||||
cq_verifier *cqv = cq_verifier_create(cq); |
||||
grpc_op ops[6]; |
||||
grpc_op *op; |
||||
grpc_metadata_array initial_metadata_recv; |
||||
grpc_metadata_array trailing_metadata_recv; |
||||
grpc_metadata_array request_metadata_recv; |
||||
grpc_byte_buffer *response_payload_recv = NULL; |
||||
grpc_call_details call_details; |
||||
grpc_status_code status; |
||||
grpc_call_error error; |
||||
char *details = NULL; |
||||
size_t details_capacity = 0; |
||||
|
||||
c = grpc_channel_create_call( |
||||
client, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", |
||||
NULL, deadline, NULL); |
||||
GPR_ASSERT(c); |
||||
|
||||
grpc_metadata_array_init(&initial_metadata_recv); |
||||
grpc_metadata_array_init(&trailing_metadata_recv); |
||||
grpc_metadata_array_init(&request_metadata_recv); |
||||
grpc_call_details_init(&call_details); |
||||
|
||||
memset(ops, 0, sizeof(ops)); |
||||
op = ops; |
||||
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
||||
op->data.send_initial_metadata.count = 2; |
||||
op->data.send_initial_metadata.metadata = meta_c; |
||||
op->flags = 0; |
||||
op->reserved = NULL; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_MESSAGE; |
||||
op->data.send_message = request_payload; |
||||
op->flags = 0; |
||||
op->reserved = NULL; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; |
||||
op->flags = 0; |
||||
op->reserved = NULL; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_INITIAL_METADATA; |
||||
op->data.recv_initial_metadata = &initial_metadata_recv; |
||||
op->flags = 0; |
||||
op->reserved = NULL; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_MESSAGE; |
||||
op->data.recv_message = &response_payload_recv; |
||||
op->flags = 0; |
||||
op->reserved = NULL; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; |
||||
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; |
||||
op->data.recv_status_on_client.status = &status; |
||||
op->data.recv_status_on_client.status_details = &details; |
||||
op->data.recv_status_on_client.status_details_capacity = &details_capacity; |
||||
op->flags = 0; |
||||
op->reserved = NULL; |
||||
op++; |
||||
error = grpc_call_start_batch(c, ops, (size_t)(op - ops), (void*)1, NULL); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ |
||||
int sl = socket(AF_INET, SOCK_STREAM, 0); |
||||
GPR_ASSERT(sl >= 0); |
||||
struct sockaddr_in s_addr; |
||||
memset(&s_addr, 0, sizeof(s_addr)); |
||||
s_addr.sin_family = AF_INET; |
||||
s_addr.sin_addr.s_addr = htonl(INADDR_ANY); |
||||
s_addr.sin_port = htons(port); |
||||
bind(sl, (struct sockaddr*)&s_addr, sizeof(s_addr)); |
||||
listen(sl, 5); |
||||
int s = accept(sl, NULL, NULL); |
||||
sleep(1); |
||||
close(s); |
||||
close(sl); |
||||
}); |
||||
|
||||
CQ_EXPECT_COMPLETION(cqv, (void*)1, 1); |
||||
cq_verify(cqv); |
||||
|
||||
GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); |
||||
|
||||
gpr_free(details); |
||||
grpc_metadata_array_destroy(&initial_metadata_recv); |
||||
grpc_metadata_array_destroy(&trailing_metadata_recv); |
||||
grpc_metadata_array_destroy(&request_metadata_recv); |
||||
grpc_call_details_destroy(&call_details); |
||||
|
||||
grpc_call_destroy(c); |
||||
|
||||
cq_verifier_destroy(cqv); |
||||
|
||||
grpc_byte_buffer_destroy(request_payload); |
||||
grpc_byte_buffer_destroy(response_payload_recv); |
||||
|
||||
grpc_channel_destroy(client); |
||||
grpc_completion_queue_shutdown(cq); |
||||
drain_cq(cq); |
||||
grpc_completion_queue_destroy(cq); |
||||
} |
||||
|
||||
@end |
@ -0,0 +1,24 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>en</string> |
||||
<key>CFBundleExecutable</key> |
||||
<string>$(EXECUTABLE_NAME)</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleName</key> |
||||
<string>$(PRODUCT_NAME)</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>BNDL</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>1.0</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>CFBundleVersion</key> |
||||
<string>1</string> |
||||
</dict> |
||||
</plist> |
@ -0,0 +1,56 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<Scheme |
||||
LastUpgradeVersion = "0730" |
||||
version = "1.3"> |
||||
<BuildAction |
||||
parallelizeBuildables = "YES" |
||||
buildImplicitDependencies = "YES"> |
||||
</BuildAction> |
||||
<TestAction |
||||
buildConfiguration = "Debug" |
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
||||
shouldUseLaunchSchemeArgsEnv = "YES"> |
||||
<Testables> |
||||
<TestableReference |
||||
skipped = "NO"> |
||||
<BuildableReference |
||||
BuildableIdentifier = "primary" |
||||
BlueprintIdentifier = "5EAD6D231E27047400002378" |
||||
BuildableName = "CronetUnitTests.xctest" |
||||
BlueprintName = "CronetUnitTests" |
||||
ReferencedContainer = "container:Tests.xcodeproj"> |
||||
</BuildableReference> |
||||
</TestableReference> |
||||
</Testables> |
||||
<AdditionalOptions> |
||||
</AdditionalOptions> |
||||
</TestAction> |
||||
<LaunchAction |
||||
buildConfiguration = "Debug" |
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
||||
launchStyle = "0" |
||||
useCustomWorkingDirectory = "NO" |
||||
ignoresPersistentStateOnLaunch = "NO" |
||||
debugDocumentVersioning = "YES" |
||||
debugServiceExtension = "internal" |
||||
allowLocationSimulation = "YES"> |
||||
<AdditionalOptions> |
||||
</AdditionalOptions> |
||||
</LaunchAction> |
||||
<ProfileAction |
||||
buildConfiguration = "Release" |
||||
shouldUseLaunchSchemeArgsEnv = "YES" |
||||
savedToolIdentifier = "" |
||||
useCustomWorkingDirectory = "NO" |
||||
debugDocumentVersioning = "YES"> |
||||
</ProfileAction> |
||||
<AnalyzeAction |
||||
buildConfiguration = "Debug"> |
||||
</AnalyzeAction> |
||||
<ArchiveAction |
||||
buildConfiguration = "Release" |
||||
revealArchiveInOrganizer = "YES"> |
||||
</ArchiveAction> |
||||
</Scheme> |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue