grpc 1.1.2 → 1.2.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +1257 -404
- data/etc/roots.pem +189 -102
- data/include/grpc/census.h +7 -7
- data/include/grpc/compression.h +4 -4
- data/include/grpc/grpc.h +13 -7
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +26 -9
- data/include/grpc/impl/codegen/grpc_types.h +39 -30
- data/include/grpc/impl/codegen/slice.h +24 -6
- data/include/grpc/impl/codegen/sync.h +8 -0
- data/include/grpc/load_reporting.h +63 -0
- data/include/grpc/slice.h +37 -1
- data/include/grpc/slice_buffer.h +7 -0
- data/include/grpc/support/alloc.h +3 -0
- data/include/grpc/support/useful.h +3 -0
- data/src/core/ext/census/gen/census.pb.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.c +9 -36
- data/src/core/ext/census/gen/trace_context.pb.h +20 -26
- data/src/core/ext/census/grpc_filter.c +3 -5
- data/src/core/ext/census/trace_context.c +1 -1
- data/src/core/ext/census/trace_context.h +3 -0
- data/src/core/ext/census/trace_label.h +61 -0
- data/src/core/ext/census/trace_propagation.h +63 -0
- data/src/core/ext/census/trace_status.h +45 -0
- data/src/core/ext/census/trace_string.h +50 -0
- data/src/core/ext/census/tracing.c +31 -11
- data/src/core/ext/census/tracing.h +124 -0
- data/src/core/ext/client_channel/client_channel.c +456 -368
- data/src/core/ext/client_channel/client_channel.h +4 -0
- data/src/core/ext/client_channel/client_channel_plugin.c +6 -1
- data/src/core/ext/client_channel/connector.c +3 -3
- data/src/core/ext/client_channel/connector.h +4 -3
- data/src/core/ext/client_channel/http_connect_handshaker.c +62 -72
- data/src/core/ext/client_channel/http_connect_handshaker.h +7 -10
- data/src/core/ext/client_channel/http_proxy.c +125 -0
- data/src/core/ext/client_channel/http_proxy.h +39 -0
- data/src/core/ext/client_channel/lb_policy.c +56 -35
- data/src/core/ext/client_channel/lb_policy.h +46 -39
- data/src/core/ext/client_channel/lb_policy_factory.h +1 -0
- data/src/core/ext/client_channel/parse_address.c +32 -6
- data/src/core/ext/client_channel/proxy_mapper.c +63 -0
- data/src/core/ext/client_channel/proxy_mapper.h +89 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.c +133 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.h +59 -0
- data/src/core/ext/client_channel/resolver.c +16 -9
- data/src/core/ext/client_channel/resolver.h +23 -12
- data/src/core/ext/client_channel/resolver_factory.h +1 -0
- data/src/core/ext/client_channel/resolver_registry.c +15 -11
- data/src/core/ext/client_channel/resolver_registry.h +5 -3
- data/src/core/ext/client_channel/subchannel.c +44 -27
- data/src/core/ext/client_channel/subchannel.h +6 -2
- data/src/core/ext/client_channel/uri_parser.c +26 -14
- data/src/core/ext/client_channel/uri_parser.h +3 -1
- data/src/core/ext/lb_policy/grpclb/grpclb.c +220 -209
- data/src/core/ext/lb_policy/grpclb/grpclb_channel.h +56 -0
- data/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c +107 -0
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +3 -6
- data/src/core/ext/lb_policy/pick_first/pick_first.c +71 -116
- data/src/core/ext/lb_policy/round_robin/round_robin.c +52 -67
- data/src/core/ext/load_reporting/load_reporting.c +20 -0
- data/src/core/ext/load_reporting/load_reporting.h +1 -16
- data/src/core/ext/load_reporting/load_reporting_filter.c +28 -54
- data/src/core/ext/resolver/dns/native/dns_resolver.c +31 -45
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +20 -29
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +11 -8
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +11 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +143 -46
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +12 -50
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +1 -2
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +0 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +606 -374
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +17 -5
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +9 -13
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +12 -11
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +5 -6
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +100 -53
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +126 -70
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +13 -7
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +22 -19
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +6 -6
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +23 -11
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +169 -42
- data/src/core/ext/transport/chttp2/transport/parsing.c +98 -41
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +29 -14
- data/src/core/ext/transport/chttp2/transport/writing.c +137 -15
- data/src/core/lib/channel/channel_stack.c +14 -44
- data/src/core/lib/channel/channel_stack.h +10 -17
- data/src/core/lib/channel/channel_stack_builder.c +2 -3
- data/src/core/lib/channel/compress_filter.c +54 -46
- data/src/core/lib/channel/connected_channel.c +4 -4
- data/src/core/lib/channel/connected_channel.h +5 -0
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/deadline_filter.c +61 -61
- data/src/core/lib/channel/deadline_filter.h +8 -5
- data/src/core/lib/channel/handshaker.c +47 -7
- data/src/core/lib/channel/handshaker.h +21 -3
- data/src/core/lib/channel/http_client_filter.c +149 -99
- data/src/core/lib/channel/http_server_filter.c +163 -147
- data/src/core/lib/channel/message_size_filter.c +15 -10
- data/src/core/lib/compression/algorithm_metadata.h +4 -4
- data/src/core/lib/compression/compression.c +17 -23
- data/src/core/lib/http/httpcli.c +3 -2
- data/src/core/lib/http/httpcli.h +2 -1
- data/src/core/lib/http/httpcli_security_connector.c +2 -3
- data/src/core/lib/http/parser.c +2 -2
- data/src/core/lib/iomgr/closure.c +6 -3
- data/src/core/lib/iomgr/closure.h +4 -2
- data/src/core/lib/iomgr/combiner.c +35 -5
- data/src/core/lib/iomgr/combiner.h +21 -2
- data/src/core/lib/iomgr/endpoint.c +3 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/error.c +60 -94
- data/src/core/lib/iomgr/error.h +7 -10
- data/src/core/lib/iomgr/error_internal.h +54 -0
- data/src/core/lib/iomgr/ev_epoll_linux.c +253 -109
- data/src/core/lib/iomgr/ev_poll_posix.c +61 -29
- data/src/core/lib/iomgr/ev_posix.c +7 -8
- data/src/core/lib/iomgr/ev_posix.h +4 -4
- data/src/core/lib/iomgr/exec_ctx.c +11 -6
- data/src/core/lib/iomgr/exec_ctx.h +11 -14
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/load_file.c +1 -1
- data/src/core/lib/iomgr/network_status_tracker.c +5 -81
- data/src/core/lib/iomgr/pollset.h +1 -3
- data/src/core/lib/iomgr/pollset_set.h +2 -1
- data/src/core/lib/iomgr/pollset_set_uv.c +2 -1
- data/src/core/lib/iomgr/pollset_set_windows.c +2 -1
- data/src/core/lib/iomgr/pollset_uv.c +25 -11
- data/src/core/lib/iomgr/pollset_windows.c +0 -11
- data/src/core/lib/iomgr/resolve_address_uv.c +50 -2
- data/src/core/lib/iomgr/resource_quota.c +41 -11
- data/src/core/lib/iomgr/resource_quota.h +6 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +33 -17
- data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +2 -3
- data/src/core/lib/iomgr/tcp_client_uv.c +1 -3
- data/src/core/lib/iomgr/tcp_client_windows.c +21 -6
- data/src/core/lib/iomgr/tcp_posix.c +4 -5
- data/src/core/lib/iomgr/tcp_server_posix.c +269 -94
- data/src/core/lib/iomgr/tcp_server_windows.c +1 -1
- data/src/core/lib/iomgr/tcp_uv.c +11 -5
- data/src/core/lib/iomgr/tcp_windows.c +20 -7
- data/src/core/lib/iomgr/timer_generic.c +15 -22
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_uv.c +10 -6
- data/src/core/lib/iomgr/timer_uv.h +1 -1
- data/src/core/lib/iomgr/udp_server.c +45 -6
- data/src/core/lib/iomgr/udp_server.h +7 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +11 -1
- data/src/core/lib/json/json.c +1 -2
- data/src/core/lib/profiling/basic_timers.c +17 -3
- data/src/core/lib/security/context/security_context.c +3 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -8
- data/src/core/lib/security/credentials/credentials.c +48 -2
- data/src/core/lib/security/credentials/credentials.h +13 -0
- data/src/core/lib/security/credentials/credentials_metadata.c +1 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.c +6 -8
- data/src/core/lib/security/credentials/fake/fake_credentials.h +15 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +3 -3
- data/src/core/lib/security/credentials/iam/iam_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +5 -8
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +3 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +15 -13
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +2 -4
- data/src/core/lib/security/transport/client_auth_filter.c +72 -47
- data/src/core/lib/security/transport/lb_targets_info.c +70 -0
- data/src/core/lib/security/transport/lb_targets_info.h +47 -0
- data/src/core/lib/security/transport/secure_endpoint.c +3 -3
- data/src/core/lib/security/transport/security_connector.c +125 -28
- data/src/core/lib/security/transport/security_connector.h +4 -3
- data/src/core/lib/security/transport/security_handshaker.c +13 -9
- data/src/core/lib/security/transport/server_auth_filter.c +31 -40
- data/src/core/lib/security/util/b64.c +1 -1
- data/src/core/lib/slice/slice.c +110 -20
- data/src/core/lib/slice/slice_buffer.c +92 -39
- data/src/core/lib/{transport/mdstr_hash_table.c → slice/slice_hash_table.c} +40 -33
- data/src/core/lib/{transport/mdstr_hash_table.h → slice/slice_hash_table.h} +21 -21
- data/src/core/lib/slice/slice_intern.c +346 -0
- data/src/core/lib/slice/slice_internal.h +15 -0
- data/src/core/lib/slice/slice_string_helpers.c +5 -0
- data/src/core/lib/slice/slice_string_helpers.h +5 -0
- data/src/core/lib/support/alloc.c +26 -1
- data/src/core/lib/support/cmdline.c +2 -4
- data/src/core/lib/support/cpu_posix.c +2 -7
- data/src/core/lib/support/histogram.c +1 -2
- data/src/core/lib/support/log_posix.c +8 -4
- data/src/core/lib/support/spinlock.h +52 -0
- data/src/core/lib/support/subprocess_posix.c +1 -2
- data/src/core/lib/support/sync.c +7 -1
- data/src/core/lib/support/sync_posix.c +9 -0
- data/src/core/lib/support/time_windows.c +7 -1
- data/src/core/lib/surface/call.c +647 -629
- data/src/core/lib/surface/call.h +4 -1
- data/src/core/lib/surface/call_details.c +8 -2
- data/src/core/lib/surface/call_log_batch.c +17 -6
- data/src/core/lib/surface/channel.c +49 -59
- data/src/core/lib/surface/channel.h +5 -6
- data/src/core/lib/surface/completion_queue.c +16 -45
- data/src/core/lib/surface/completion_queue.h +0 -3
- data/src/core/lib/surface/init.c +6 -2
- data/src/core/lib/surface/init_secure.c +1 -1
- data/src/core/lib/surface/lame_client.c +14 -4
- data/src/core/lib/surface/server.c +79 -82
- data/src/core/lib/surface/validate_metadata.c +46 -15
- data/src/core/lib/surface/validate_metadata.h +43 -0
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.c +104 -0
- data/src/core/lib/transport/bdp_estimator.h +76 -0
- data/src/core/lib/transport/connectivity_state.c +33 -13
- data/src/core/lib/transport/connectivity_state.h +15 -5
- data/src/core/lib/transport/error_utils.c +124 -0
- data/src/core/lib/transport/error_utils.h +56 -0
- data/src/core/{ext/transport/chttp2 → lib}/transport/http2_errors.h +18 -18
- data/src/core/lib/transport/metadata.c +259 -503
- data/src/core/lib/transport/metadata.h +69 -68
- data/src/core/lib/transport/metadata_batch.c +183 -63
- data/src/core/lib/transport/metadata_batch.h +50 -26
- data/src/core/lib/transport/pid_controller.c +28 -8
- data/src/core/lib/transport/pid_controller.h +15 -2
- data/src/core/lib/transport/service_config.c +21 -18
- data/src/core/lib/transport/service_config.h +5 -5
- data/src/core/lib/transport/static_metadata.c +753 -112
- data/src/core/lib/transport/static_metadata.h +403 -264
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.c +18 -20
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.h +9 -10
- data/src/core/lib/transport/timeout_encoding.c +11 -9
- data/src/core/lib/transport/timeout_encoding.h +3 -1
- data/src/core/lib/transport/transport.c +47 -87
- data/src/core/lib/transport/transport.h +20 -25
- data/src/core/lib/transport/transport_op_string.c +7 -19
- data/src/core/lib/tsi/fake_transport_security.c +2 -4
- data/src/core/lib/tsi/ssl_transport_security.c +7 -16
- data/src/core/lib/tsi/transport_security.c +2 -4
- data/src/ruby/ext/grpc/extconf.rb +4 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +7 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +3 -0
- data/src/ruby/ext/grpc/rb_call.c +47 -46
- data/src/ruby/ext/grpc/rb_channel.c +21 -6
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +59 -8
- data/src/ruby/ext/grpc/rb_server.c +6 -4
- data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +33 -9
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright 2017, Google Inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions are
|
|
8
|
+
* met:
|
|
9
|
+
*
|
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
14
|
+
* in the documentation and/or other materials provided with the
|
|
15
|
+
* distribution.
|
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
|
18
|
+
* this software without specific prior written permission.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
#ifndef GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_H
|
|
35
|
+
#define GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_H
|
|
36
|
+
|
|
37
|
+
#include <stdbool.h>
|
|
38
|
+
|
|
39
|
+
#include <grpc/impl/codegen/grpc_types.h>
|
|
40
|
+
|
|
41
|
+
#include "src/core/lib/iomgr/resolve_address.h"
|
|
42
|
+
|
|
43
|
+
typedef struct grpc_proxy_mapper grpc_proxy_mapper;
|
|
44
|
+
|
|
45
|
+
typedef struct {
|
|
46
|
+
/// Determines the proxy name to resolve for \a server_uri.
|
|
47
|
+
/// If no proxy is needed, returns false.
|
|
48
|
+
/// Otherwise, sets \a name_to_resolve, optionally sets \a new_args,
|
|
49
|
+
/// and returns true.
|
|
50
|
+
bool (*map_name)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
|
|
51
|
+
const char* server_uri, const grpc_channel_args* args,
|
|
52
|
+
char** name_to_resolve, grpc_channel_args** new_args);
|
|
53
|
+
/// Determines the proxy address to use to contact \a address.
|
|
54
|
+
/// If no proxy is needed, returns false.
|
|
55
|
+
/// Otherwise, sets \a new_address, optionally sets \a new_args, and
|
|
56
|
+
/// returns true.
|
|
57
|
+
bool (*map_address)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
|
|
58
|
+
const grpc_resolved_address* address,
|
|
59
|
+
const grpc_channel_args* args,
|
|
60
|
+
grpc_resolved_address** new_address,
|
|
61
|
+
grpc_channel_args** new_args);
|
|
62
|
+
/// Destroys \a mapper.
|
|
63
|
+
void (*destroy)(grpc_proxy_mapper* mapper);
|
|
64
|
+
} grpc_proxy_mapper_vtable;
|
|
65
|
+
|
|
66
|
+
struct grpc_proxy_mapper {
|
|
67
|
+
const grpc_proxy_mapper_vtable* vtable;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
|
|
71
|
+
grpc_proxy_mapper* mapper);
|
|
72
|
+
|
|
73
|
+
bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
|
|
74
|
+
grpc_proxy_mapper* mapper,
|
|
75
|
+
const char* server_uri,
|
|
76
|
+
const grpc_channel_args* args,
|
|
77
|
+
char** name_to_resolve,
|
|
78
|
+
grpc_channel_args** new_args);
|
|
79
|
+
|
|
80
|
+
bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
|
|
81
|
+
grpc_proxy_mapper* mapper,
|
|
82
|
+
const grpc_resolved_address* address,
|
|
83
|
+
const grpc_channel_args* args,
|
|
84
|
+
grpc_resolved_address** new_address,
|
|
85
|
+
grpc_channel_args** new_args);
|
|
86
|
+
|
|
87
|
+
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper);
|
|
88
|
+
|
|
89
|
+
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_H */
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright 2017, Google Inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions are
|
|
8
|
+
* met:
|
|
9
|
+
*
|
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
14
|
+
* in the documentation and/or other materials provided with the
|
|
15
|
+
* distribution.
|
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
|
18
|
+
* this software without specific prior written permission.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
#include "src/core/ext/client_channel/proxy_mapper_registry.h"
|
|
35
|
+
|
|
36
|
+
#include <string.h>
|
|
37
|
+
|
|
38
|
+
#include <grpc/support/alloc.h>
|
|
39
|
+
|
|
40
|
+
//
|
|
41
|
+
// grpc_proxy_mapper_list
|
|
42
|
+
//
|
|
43
|
+
|
|
44
|
+
typedef struct {
|
|
45
|
+
grpc_proxy_mapper** list;
|
|
46
|
+
size_t num_mappers;
|
|
47
|
+
} grpc_proxy_mapper_list;
|
|
48
|
+
|
|
49
|
+
static void grpc_proxy_mapper_list_register(grpc_proxy_mapper_list* list,
|
|
50
|
+
bool at_start,
|
|
51
|
+
grpc_proxy_mapper* mapper) {
|
|
52
|
+
list->list = gpr_realloc(
|
|
53
|
+
list->list, (list->num_mappers + 1) * sizeof(grpc_proxy_mapper*));
|
|
54
|
+
if (at_start) {
|
|
55
|
+
memmove(list->list + 1, list->list,
|
|
56
|
+
sizeof(grpc_proxy_mapper*) * list->num_mappers);
|
|
57
|
+
list->list[0] = mapper;
|
|
58
|
+
} else {
|
|
59
|
+
list->list[list->num_mappers] = mapper;
|
|
60
|
+
}
|
|
61
|
+
++list->num_mappers;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static bool grpc_proxy_mapper_list_map_name(grpc_exec_ctx* exec_ctx,
|
|
65
|
+
grpc_proxy_mapper_list* list,
|
|
66
|
+
const char* server_uri,
|
|
67
|
+
const grpc_channel_args* args,
|
|
68
|
+
char** name_to_resolve,
|
|
69
|
+
grpc_channel_args** new_args) {
|
|
70
|
+
for (size_t i = 0; i < list->num_mappers; ++i) {
|
|
71
|
+
if (grpc_proxy_mapper_map_name(exec_ctx, list->list[i], server_uri, args,
|
|
72
|
+
name_to_resolve, new_args)) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static bool grpc_proxy_mapper_list_map_address(
|
|
80
|
+
grpc_exec_ctx* exec_ctx, grpc_proxy_mapper_list* list,
|
|
81
|
+
const grpc_resolved_address* address, const grpc_channel_args* args,
|
|
82
|
+
grpc_resolved_address** new_address, grpc_channel_args** new_args) {
|
|
83
|
+
for (size_t i = 0; i < list->num_mappers; ++i) {
|
|
84
|
+
if (grpc_proxy_mapper_map_address(exec_ctx, list->list[i], address, args,
|
|
85
|
+
new_address, new_args)) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static void grpc_proxy_mapper_list_destroy(grpc_proxy_mapper_list* list) {
|
|
93
|
+
for (size_t i = 0; i < list->num_mappers; ++i) {
|
|
94
|
+
grpc_proxy_mapper_destroy(list->list[i]);
|
|
95
|
+
}
|
|
96
|
+
gpr_free(list->list);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//
|
|
100
|
+
// plugin
|
|
101
|
+
//
|
|
102
|
+
|
|
103
|
+
static grpc_proxy_mapper_list g_proxy_mapper_list;
|
|
104
|
+
|
|
105
|
+
void grpc_proxy_mapper_registry_init() {
|
|
106
|
+
memset(&g_proxy_mapper_list, 0, sizeof(g_proxy_mapper_list));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void grpc_proxy_mapper_registry_shutdown() {
|
|
110
|
+
grpc_proxy_mapper_list_destroy(&g_proxy_mapper_list);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper) {
|
|
114
|
+
grpc_proxy_mapper_list_register(&g_proxy_mapper_list, at_start, mapper);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
|
|
118
|
+
const char* server_uri,
|
|
119
|
+
const grpc_channel_args* args,
|
|
120
|
+
char** name_to_resolve,
|
|
121
|
+
grpc_channel_args** new_args) {
|
|
122
|
+
return grpc_proxy_mapper_list_map_name(exec_ctx, &g_proxy_mapper_list,
|
|
123
|
+
server_uri, args, name_to_resolve,
|
|
124
|
+
new_args);
|
|
125
|
+
}
|
|
126
|
+
bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
|
|
127
|
+
const grpc_resolved_address* address,
|
|
128
|
+
const grpc_channel_args* args,
|
|
129
|
+
grpc_resolved_address** new_address,
|
|
130
|
+
grpc_channel_args** new_args) {
|
|
131
|
+
return grpc_proxy_mapper_list_map_address(
|
|
132
|
+
exec_ctx, &g_proxy_mapper_list, address, args, new_address, new_args);
|
|
133
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright 2017, Google Inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions are
|
|
8
|
+
* met:
|
|
9
|
+
*
|
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
14
|
+
* in the documentation and/or other materials provided with the
|
|
15
|
+
* distribution.
|
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
|
18
|
+
* this software without specific prior written permission.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
#ifndef GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H
|
|
35
|
+
#define GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H
|
|
36
|
+
|
|
37
|
+
#include "src/core/ext/client_channel/proxy_mapper.h"
|
|
38
|
+
|
|
39
|
+
void grpc_proxy_mapper_registry_init();
|
|
40
|
+
void grpc_proxy_mapper_registry_shutdown();
|
|
41
|
+
|
|
42
|
+
/// Registers a new proxy mapper. Takes ownership.
|
|
43
|
+
/// If \a at_start is true, the new mapper will be at the beginning of
|
|
44
|
+
/// the list. Otherwise, it will be added to the end.
|
|
45
|
+
void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper);
|
|
46
|
+
|
|
47
|
+
bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
|
|
48
|
+
const char* server_uri,
|
|
49
|
+
const grpc_channel_args* args,
|
|
50
|
+
char** name_to_resolve,
|
|
51
|
+
grpc_channel_args** new_args);
|
|
52
|
+
|
|
53
|
+
bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
|
|
54
|
+
const grpc_resolved_address* address,
|
|
55
|
+
const grpc_channel_args* args,
|
|
56
|
+
grpc_resolved_address** new_address,
|
|
57
|
+
grpc_channel_args** new_args);
|
|
58
|
+
|
|
59
|
+
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */
|
|
@@ -32,10 +32,13 @@
|
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
#include "src/core/ext/client_channel/resolver.h"
|
|
35
|
+
#include "src/core/lib/iomgr/combiner.h"
|
|
35
36
|
|
|
36
37
|
void grpc_resolver_init(grpc_resolver *resolver,
|
|
37
|
-
const grpc_resolver_vtable *vtable
|
|
38
|
+
const grpc_resolver_vtable *vtable,
|
|
39
|
+
grpc_combiner *combiner) {
|
|
38
40
|
resolver->vtable = vtable;
|
|
41
|
+
resolver->combiner = GRPC_COMBINER_REF(combiner, "resolver");
|
|
39
42
|
gpr_ref_init(&resolver->refs, 1);
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -62,20 +65,24 @@ void grpc_resolver_unref(grpc_resolver *resolver,
|
|
|
62
65
|
void grpc_resolver_unref(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) {
|
|
63
66
|
#endif
|
|
64
67
|
if (gpr_unref(&resolver->refs)) {
|
|
68
|
+
grpc_combiner *combiner = resolver->combiner;
|
|
65
69
|
resolver->vtable->destroy(exec_ctx, resolver);
|
|
70
|
+
GRPC_COMBINER_UNREF(exec_ctx, combiner, "resolver");
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
void
|
|
70
|
-
|
|
74
|
+
void grpc_resolver_shutdown_locked(grpc_exec_ctx *exec_ctx,
|
|
75
|
+
grpc_resolver *resolver) {
|
|
76
|
+
resolver->vtable->shutdown_locked(exec_ctx, resolver);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
void
|
|
74
|
-
|
|
75
|
-
resolver->vtable->
|
|
79
|
+
void grpc_resolver_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
|
|
80
|
+
grpc_resolver *resolver) {
|
|
81
|
+
resolver->vtable->channel_saw_error_locked(exec_ctx, resolver);
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
void
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
void grpc_resolver_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
|
|
85
|
+
grpc_channel_args **result,
|
|
86
|
+
grpc_closure *on_complete) {
|
|
87
|
+
resolver->vtable->next_locked(exec_ctx, resolver, result, on_complete);
|
|
81
88
|
}
|
|
@@ -44,14 +44,16 @@ typedef struct grpc_resolver_vtable grpc_resolver_vtable;
|
|
|
44
44
|
struct grpc_resolver {
|
|
45
45
|
const grpc_resolver_vtable *vtable;
|
|
46
46
|
gpr_refcount refs;
|
|
47
|
+
grpc_combiner *combiner;
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
struct grpc_resolver_vtable {
|
|
50
51
|
void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
|
|
51
|
-
void (*
|
|
52
|
-
void (*
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
void (*shutdown_locked)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
|
|
53
|
+
void (*channel_saw_error_locked)(grpc_exec_ctx *exec_ctx,
|
|
54
|
+
grpc_resolver *resolver);
|
|
55
|
+
void (*next_locked)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
|
|
56
|
+
grpc_channel_args **result, grpc_closure *on_complete);
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
#ifdef GRPC_RESOLVER_REFCOUNT_DEBUG
|
|
@@ -70,21 +72,30 @@ void grpc_resolver_unref(grpc_exec_ctx *exec_ctx, grpc_resolver *policy);
|
|
|
70
72
|
#endif
|
|
71
73
|
|
|
72
74
|
void grpc_resolver_init(grpc_resolver *resolver,
|
|
73
|
-
const grpc_resolver_vtable *vtable
|
|
75
|
+
const grpc_resolver_vtable *vtable,
|
|
76
|
+
grpc_combiner *combiner);
|
|
74
77
|
|
|
75
|
-
void
|
|
78
|
+
void grpc_resolver_shutdown_locked(grpc_exec_ctx *exec_ctx,
|
|
79
|
+
grpc_resolver *resolver);
|
|
76
80
|
|
|
77
81
|
/** Notification that the channel has seen an error on some address.
|
|
78
|
-
Can be used as a hint that re-resolution is desirable soon.
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
Can be used as a hint that re-resolution is desirable soon.
|
|
83
|
+
|
|
84
|
+
Must be called from the combiner passed as a resolver_arg at construction
|
|
85
|
+
time.*/
|
|
86
|
+
void grpc_resolver_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
|
|
87
|
+
grpc_resolver *resolver);
|
|
81
88
|
|
|
82
89
|
/** Get the next result from the resolver. Expected to set \a *result with
|
|
83
90
|
new channel args and then schedule \a on_complete for execution.
|
|
84
91
|
|
|
85
92
|
If resolution is fatally broken, set \a *result to NULL and
|
|
86
|
-
schedule \a on_complete.
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
schedule \a on_complete.
|
|
94
|
+
|
|
95
|
+
Must be called from the combiner passed as a resolver_arg at construction
|
|
96
|
+
time.*/
|
|
97
|
+
void grpc_resolver_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
|
|
98
|
+
grpc_channel_args **result,
|
|
99
|
+
grpc_closure *on_complete);
|
|
89
100
|
|
|
90
101
|
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_RESOLVER_H */
|
|
@@ -108,22 +108,23 @@ static grpc_resolver_factory *lookup_factory_by_uri(grpc_uri *uri) {
|
|
|
108
108
|
return lookup_factory(uri->scheme);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
static grpc_resolver_factory *resolve_factory(
|
|
111
|
+
static grpc_resolver_factory *resolve_factory(grpc_exec_ctx *exec_ctx,
|
|
112
|
+
const char *target,
|
|
112
113
|
grpc_uri **uri,
|
|
113
114
|
char **canonical_target) {
|
|
114
115
|
grpc_resolver_factory *factory = NULL;
|
|
115
116
|
|
|
116
117
|
GPR_ASSERT(uri != NULL);
|
|
117
|
-
*uri = grpc_uri_parse(target, 1);
|
|
118
|
+
*uri = grpc_uri_parse(exec_ctx, target, 1);
|
|
118
119
|
factory = lookup_factory_by_uri(*uri);
|
|
119
120
|
if (factory == NULL) {
|
|
120
121
|
grpc_uri_destroy(*uri);
|
|
121
122
|
gpr_asprintf(canonical_target, "%s%s", g_default_resolver_prefix, target);
|
|
122
|
-
*uri = grpc_uri_parse(*canonical_target, 1);
|
|
123
|
+
*uri = grpc_uri_parse(exec_ctx, *canonical_target, 1);
|
|
123
124
|
factory = lookup_factory_by_uri(*uri);
|
|
124
125
|
if (factory == NULL) {
|
|
125
|
-
grpc_uri_destroy(grpc_uri_parse(target, 0));
|
|
126
|
-
grpc_uri_destroy(grpc_uri_parse(*canonical_target, 0));
|
|
126
|
+
grpc_uri_destroy(grpc_uri_parse(exec_ctx, target, 0));
|
|
127
|
+
grpc_uri_destroy(grpc_uri_parse(exec_ctx, *canonical_target, 0));
|
|
127
128
|
gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", target,
|
|
128
129
|
*canonical_target);
|
|
129
130
|
}
|
|
@@ -133,17 +134,19 @@ static grpc_resolver_factory *resolve_factory(const char *target,
|
|
|
133
134
|
|
|
134
135
|
grpc_resolver *grpc_resolver_create(grpc_exec_ctx *exec_ctx, const char *target,
|
|
135
136
|
const grpc_channel_args *args,
|
|
136
|
-
grpc_pollset_set *pollset_set
|
|
137
|
+
grpc_pollset_set *pollset_set,
|
|
138
|
+
grpc_combiner *combiner) {
|
|
137
139
|
grpc_uri *uri = NULL;
|
|
138
140
|
char *canonical_target = NULL;
|
|
139
141
|
grpc_resolver_factory *factory =
|
|
140
|
-
resolve_factory(target, &uri, &canonical_target);
|
|
142
|
+
resolve_factory(exec_ctx, target, &uri, &canonical_target);
|
|
141
143
|
grpc_resolver *resolver;
|
|
142
144
|
grpc_resolver_args resolver_args;
|
|
143
145
|
memset(&resolver_args, 0, sizeof(resolver_args));
|
|
144
146
|
resolver_args.uri = uri;
|
|
145
147
|
resolver_args.args = args;
|
|
146
148
|
resolver_args.pollset_set = pollset_set;
|
|
149
|
+
resolver_args.combiner = combiner;
|
|
147
150
|
resolver =
|
|
148
151
|
grpc_resolver_factory_create_resolver(exec_ctx, factory, &resolver_args);
|
|
149
152
|
grpc_uri_destroy(uri);
|
|
@@ -151,21 +154,22 @@ grpc_resolver *grpc_resolver_create(grpc_exec_ctx *exec_ctx, const char *target,
|
|
|
151
154
|
return resolver;
|
|
152
155
|
}
|
|
153
156
|
|
|
154
|
-
char *grpc_get_default_authority(const char *target) {
|
|
157
|
+
char *grpc_get_default_authority(grpc_exec_ctx *exec_ctx, const char *target) {
|
|
155
158
|
grpc_uri *uri = NULL;
|
|
156
159
|
char *canonical_target = NULL;
|
|
157
160
|
grpc_resolver_factory *factory =
|
|
158
|
-
resolve_factory(target, &uri, &canonical_target);
|
|
161
|
+
resolve_factory(exec_ctx, target, &uri, &canonical_target);
|
|
159
162
|
char *authority = grpc_resolver_factory_get_default_authority(factory, uri);
|
|
160
163
|
grpc_uri_destroy(uri);
|
|
161
164
|
gpr_free(canonical_target);
|
|
162
165
|
return authority;
|
|
163
166
|
}
|
|
164
167
|
|
|
165
|
-
char *grpc_resolver_factory_add_default_prefix_if_needed(
|
|
168
|
+
char *grpc_resolver_factory_add_default_prefix_if_needed(
|
|
169
|
+
grpc_exec_ctx *exec_ctx, const char *target) {
|
|
166
170
|
grpc_uri *uri = NULL;
|
|
167
171
|
char *canonical_target = NULL;
|
|
168
|
-
resolve_factory(target, &uri, &canonical_target);
|
|
172
|
+
resolve_factory(exec_ctx, target, &uri, &canonical_target);
|
|
169
173
|
grpc_uri_destroy(uri);
|
|
170
174
|
return canonical_target == NULL ? gpr_strdup(target) : canonical_target;
|
|
171
175
|
}
|