grpc 1.17.1 → 1.18.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +1228 -988
- data/etc/roots.pem +242 -30
- data/include/grpc/grpc.h +2 -1
- data/include/grpc/grpc_security_constants.h +3 -3
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +2 -0
- data/include/grpc/impl/codegen/compression_types.h +2 -1
- data/include/grpc/impl/codegen/grpc_types.h +1 -1
- data/include/grpc/impl/codegen/port_platform.h +9 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +163 -882
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -4
- data/src/core/ext/filters/client_channel/health/health_check_client.h +2 -3
- data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +8 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +176 -216
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +20 -23
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +49 -52
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +13 -35
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +31 -30
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +69 -225
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +20 -23
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +2 -84
- data/src/core/ext/filters/client_channel/request_routing.cc +936 -0
- data/src/core/ext/filters/client_channel/request_routing.h +177 -0
- data/src/core/ext/filters/client_channel/resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +37 -26
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +30 -18
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +119 -100
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +8 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +5 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +12 -14
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +5 -9
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -2
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +17 -17
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +45 -52
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +13 -17
- data/src/core/ext/filters/client_channel/server_address.cc +103 -0
- data/src/core/ext/filters/client_channel/server_address.h +108 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +10 -8
- data/src/core/ext/filters/client_channel/subchannel.h +9 -6
- data/src/core/ext/filters/client_channel/subchannel_index.cc +20 -27
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +3 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +8 -9
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +1 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +8 -11
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +24 -54
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -1
- data/src/core/ext/transport/chttp2/transport/context_list.cc +67 -0
- data/src/core/ext/transport/chttp2/transport/context_list.h +53 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +38 -11
- data/src/core/ext/transport/chttp2/transport/writing.cc +5 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -1
- data/src/core/lib/channel/channelz.cc +19 -18
- data/src/core/lib/channel/channelz.h +7 -1
- data/src/core/lib/channel/channelz_registry.cc +3 -2
- data/src/core/lib/debug/trace.cc +3 -0
- data/src/core/lib/debug/trace.h +5 -3
- data/src/core/lib/gpr/sync_posix.cc +96 -4
- data/src/core/lib/gprpp/inlined_vector.h +25 -19
- data/src/core/lib/gprpp/memory.h +2 -11
- data/src/core/lib/gprpp/orphanable.h +18 -82
- data/src/core/lib/gprpp/ref_counted.h +75 -84
- data/src/core/lib/gprpp/ref_counted_ptr.h +22 -17
- data/src/core/lib/http/httpcli_security_connector.cc +101 -94
- data/src/core/lib/http/parser.h +5 -5
- data/src/core/lib/iomgr/buffer_list.cc +16 -5
- data/src/core/lib/iomgr/buffer_list.h +10 -3
- data/src/core/lib/iomgr/call_combiner.cc +50 -2
- data/src/core/lib/iomgr/call_combiner.h +29 -2
- data/src/core/lib/iomgr/dynamic_annotations.h +67 -0
- data/src/core/lib/iomgr/endpoint.cc +4 -0
- data/src/core/lib/iomgr/endpoint.h +3 -0
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +4 -0
- data/src/core/lib/iomgr/ev_epollex_linux.cc +4 -0
- data/src/core/lib/iomgr/ev_poll_posix.cc +4 -0
- data/src/core/lib/iomgr/ev_posix.cc +15 -7
- data/src/core/lib/iomgr/ev_posix.h +10 -0
- data/src/core/lib/iomgr/exec_ctx.cc +13 -0
- data/src/core/lib/iomgr/fork_posix.cc +1 -1
- data/src/core/lib/iomgr/internal_errqueue.cc +36 -3
- data/src/core/lib/iomgr/internal_errqueue.h +7 -1
- data/src/core/lib/iomgr/iomgr.cc +7 -0
- data/src/core/lib/iomgr/iomgr.h +4 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +3 -1
- data/src/core/lib/iomgr/iomgr_internal.cc +4 -0
- data/src/core/lib/iomgr/iomgr_internal.h +4 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +6 -1
- data/src/core/lib/iomgr/iomgr_windows.cc +4 -1
- data/src/core/lib/iomgr/port.h +1 -2
- data/src/core/lib/iomgr/resource_quota.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils.cc +1 -0
- data/src/core/lib/iomgr/tcp_custom.cc +4 -1
- data/src/core/lib/iomgr/tcp_posix.cc +95 -35
- data/src/core/lib/iomgr/tcp_windows.cc +4 -1
- data/src/core/lib/iomgr/timer_manager.cc +6 -0
- data/src/core/lib/security/context/security_context.cc +75 -108
- data/src/core/lib/security/context/security_context.h +59 -35
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +36 -48
- data/src/core/lib/security/credentials/alts/alts_credentials.h +37 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +97 -157
- data/src/core/lib/security/credentials/composite/composite_credentials.h +60 -24
- data/src/core/lib/security/credentials/credentials.cc +18 -142
- data/src/core/lib/security/credentials/credentials.h +119 -95
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +46 -71
- data/src/core/lib/security/credentials/fake/fake_credentials.h +23 -5
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +144 -51
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +28 -5
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +27 -35
- data/src/core/lib/security/credentials/iam/iam_credentials.h +18 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +60 -69
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +29 -10
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -0
- data/src/core/lib/security/credentials/local/local_credentials.cc +19 -32
- data/src/core/lib/security/credentials/local/local_credentials.h +32 -11
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +130 -149
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +74 -29
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +59 -77
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +40 -17
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +66 -83
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +58 -15
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +152 -177
- data/src/core/lib/security/security_connector/alts/alts_security_connector.h +12 -10
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +210 -215
- data/src/core/lib/security/security_connector/fake/fake_security_connector.h +9 -6
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +176 -169
- data/src/core/lib/security/security_connector/local/local_security_connector.h +10 -9
- data/src/core/lib/security/security_connector/security_connector.cc +41 -124
- data/src/core/lib/security/security_connector/security_connector.h +102 -105
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +348 -370
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +14 -12
- data/src/core/lib/security/security_connector/ssl_utils.cc +13 -9
- data/src/core/lib/security/security_connector/ssl_utils.h +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +50 -50
- data/src/core/lib/security/transport/secure_endpoint.cc +7 -1
- data/src/core/lib/security/transport/security_handshaker.cc +82 -66
- data/src/core/lib/security/transport/server_auth_filter.cc +15 -13
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/server.cc +13 -11
- data/src/core/lib/surface/server.h +6 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/metadata.cc +1 -0
- data/src/core/lib/transport/static_metadata.cc +228 -221
- data/src/core/lib/transport/static_metadata.h +75 -71
- data/src/core/lib/transport/transport.cc +2 -1
- data/src/core/lib/transport/transport.h +5 -1
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +9 -2
- data/src/core/tsi/ssl_transport_security.cc +35 -24
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +61 -0
- data/src/ruby/lib/grpc/generic/service.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +2 -3
- data/src/ruby/spec/generic/rpc_server_spec.rb +22 -0
- data/src/ruby/spec/support/services.rb +1 -0
- metadata +37 -32
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +0 -163
@@ -29,16 +29,17 @@ struct grpc_ares_request {
|
|
29
29
|
static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
|
30
30
|
const char* dns_server, const char* name, const char* default_port,
|
31
31
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
32
|
-
|
33
|
-
|
32
|
+
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs,
|
33
|
+
bool check_grpclb, char** service_config_json, int query_timeout_ms,
|
34
|
+
grpc_combiner* combiner) {
|
34
35
|
return NULL;
|
35
36
|
}
|
36
37
|
|
37
38
|
grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
|
38
39
|
const char* dns_server, const char* name, const char* default_port,
|
39
40
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
40
|
-
|
41
|
-
int query_timeout_ms,
|
41
|
+
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs,
|
42
|
+
bool check_grpclb, char** service_config_json, int query_timeout_ms,
|
42
43
|
grpc_combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
|
43
44
|
|
44
45
|
static void grpc_cancel_ares_request_locked_impl(grpc_ares_request* r) {}
|
@@ -27,7 +27,8 @@
|
|
27
27
|
bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); }
|
28
28
|
|
29
29
|
bool grpc_ares_maybe_resolve_localhost_manually_locked(
|
30
|
-
const char* name, const char* default_port,
|
30
|
+
const char* name, const char* default_port,
|
31
|
+
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs) {
|
31
32
|
return false;
|
32
33
|
}
|
33
34
|
|
@@ -23,9 +23,9 @@
|
|
23
23
|
|
24
24
|
#include <grpc/support/string_util.h>
|
25
25
|
|
26
|
-
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
27
26
|
#include "src/core/ext/filters/client_channel/parse_address.h"
|
28
27
|
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
|
28
|
+
#include "src/core/ext/filters/client_channel/server_address.h"
|
29
29
|
#include "src/core/lib/gpr/host_port.h"
|
30
30
|
#include "src/core/lib/gpr/string.h"
|
31
31
|
#include "src/core/lib/iomgr/socket_windows.h"
|
@@ -33,8 +33,9 @@
|
|
33
33
|
bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); }
|
34
34
|
|
35
35
|
static bool inner_maybe_resolve_localhost_manually_locked(
|
36
|
-
const char* name, const char* default_port,
|
37
|
-
|
36
|
+
const char* name, const char* default_port,
|
37
|
+
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs, char** host,
|
38
|
+
char** port) {
|
38
39
|
gpr_split_host_port(name, host, port);
|
39
40
|
if (*host == nullptr) {
|
40
41
|
gpr_log(GPR_ERROR,
|
@@ -55,7 +56,7 @@ static bool inner_maybe_resolve_localhost_manually_locked(
|
|
55
56
|
}
|
56
57
|
if (gpr_stricmp(*host, "localhost") == 0) {
|
57
58
|
GPR_ASSERT(*addrs == nullptr);
|
58
|
-
*addrs =
|
59
|
+
*addrs = grpc_core::MakeUnique<grpc_core::ServerAddressList>();
|
59
60
|
uint16_t numeric_port = grpc_strhtons(*port);
|
60
61
|
// Append the ipv6 loopback address.
|
61
62
|
struct sockaddr_in6 ipv6_loopback_addr;
|
@@ -63,10 +64,8 @@ static bool inner_maybe_resolve_localhost_manually_locked(
|
|
63
64
|
((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1;
|
64
65
|
ipv6_loopback_addr.sin6_family = AF_INET6;
|
65
66
|
ipv6_loopback_addr.sin6_port = numeric_port;
|
66
|
-
|
67
|
-
|
68
|
-
false /* is_balancer */, nullptr /* balancer_name */,
|
69
|
-
nullptr /* user_data */);
|
67
|
+
(*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr),
|
68
|
+
nullptr /* args */);
|
70
69
|
// Append the ipv4 loopback address.
|
71
70
|
struct sockaddr_in ipv4_loopback_addr;
|
72
71
|
memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr));
|
@@ -74,19 +73,18 @@ static bool inner_maybe_resolve_localhost_manually_locked(
|
|
74
73
|
((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01;
|
75
74
|
ipv4_loopback_addr.sin_family = AF_INET;
|
76
75
|
ipv4_loopback_addr.sin_port = numeric_port;
|
77
|
-
|
78
|
-
|
79
|
-
false /* is_balancer */, nullptr /* balancer_name */,
|
80
|
-
nullptr /* user_data */);
|
76
|
+
(*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr),
|
77
|
+
nullptr /* args */);
|
81
78
|
// Let the address sorter figure out which one should be tried first.
|
82
|
-
grpc_cares_wrapper_address_sorting_sort(
|
79
|
+
grpc_cares_wrapper_address_sorting_sort(addrs->get());
|
83
80
|
return true;
|
84
81
|
}
|
85
82
|
return false;
|
86
83
|
}
|
87
84
|
|
88
85
|
bool grpc_ares_maybe_resolve_localhost_manually_locked(
|
89
|
-
const char* name, const char* default_port,
|
86
|
+
const char* name, const char* default_port,
|
87
|
+
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs) {
|
90
88
|
char* host = nullptr;
|
91
89
|
char* port = nullptr;
|
92
90
|
bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port,
|
@@ -26,8 +26,8 @@
|
|
26
26
|
#include <grpc/support/string_util.h>
|
27
27
|
#include <grpc/support/time.h>
|
28
28
|
|
29
|
-
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
30
29
|
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
30
|
+
#include "src/core/ext/filters/client_channel/server_address.h"
|
31
31
|
#include "src/core/lib/backoff/backoff.h"
|
32
32
|
#include "src/core/lib/channel/channel_args.h"
|
33
33
|
#include "src/core/lib/gpr/env.h"
|
@@ -198,18 +198,14 @@ void NativeDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
|
|
198
198
|
grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
|
199
199
|
grpc_slice_from_copied_string(r->name_to_resolve_));
|
200
200
|
if (r->addresses_ != nullptr) {
|
201
|
-
|
202
|
-
r->addresses_->naddrs, nullptr /* user_data_vtable */);
|
201
|
+
ServerAddressList addresses;
|
203
202
|
for (size_t i = 0; i < r->addresses_->naddrs; ++i) {
|
204
|
-
|
205
|
-
|
206
|
-
r->addresses_->addrs[i].len, false /* is_balancer */,
|
207
|
-
nullptr /* balancer_name */, nullptr /* user_data */);
|
203
|
+
addresses.emplace_back(&r->addresses_->addrs[i].addr,
|
204
|
+
r->addresses_->addrs[i].len, nullptr /* args */);
|
208
205
|
}
|
209
|
-
grpc_arg new_arg =
|
206
|
+
grpc_arg new_arg = CreateServerAddressListChannelArg(&addresses);
|
210
207
|
result = grpc_channel_args_copy_and_add(r->channel_args_, &new_arg, 1);
|
211
208
|
grpc_resolved_addresses_destroy(r->addresses_);
|
212
|
-
grpc_lb_addresses_destroy(addresses);
|
213
209
|
// Reset backoff state so that we start from the beginning when the
|
214
210
|
// next request gets triggered.
|
215
211
|
r->backoff_.Reset();
|
@@ -28,12 +28,13 @@
|
|
28
28
|
#include <grpc/support/alloc.h>
|
29
29
|
#include <grpc/support/string_util.h>
|
30
30
|
|
31
|
-
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
32
31
|
#include "src/core/ext/filters/client_channel/parse_address.h"
|
33
32
|
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
33
|
+
#include "src/core/ext/filters/client_channel/server_address.h"
|
34
34
|
#include "src/core/lib/channel/channel_args.h"
|
35
35
|
#include "src/core/lib/gpr/host_port.h"
|
36
36
|
#include "src/core/lib/gpr/string.h"
|
37
|
+
#include "src/core/lib/gpr/useful.h"
|
37
38
|
#include "src/core/lib/iomgr/closure.h"
|
38
39
|
#include "src/core/lib/iomgr/combiner.h"
|
39
40
|
#include "src/core/lib/iomgr/resolve_address.h"
|
@@ -19,10 +19,9 @@
|
|
19
19
|
|
20
20
|
#include <grpc/support/port_platform.h>
|
21
21
|
|
22
|
-
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
23
22
|
#include "src/core/lib/channel/channel_args.h"
|
24
23
|
#include "src/core/lib/gprpp/ref_counted.h"
|
25
|
-
#include "src/core/lib/
|
24
|
+
#include "src/core/lib/iomgr/error.h"
|
26
25
|
|
27
26
|
#define GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR \
|
28
27
|
"grpc.fake_resolver.response_generator"
|
@@ -26,9 +26,9 @@
|
|
26
26
|
#include <grpc/support/alloc.h>
|
27
27
|
#include <grpc/support/string_util.h>
|
28
28
|
|
29
|
-
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
30
29
|
#include "src/core/ext/filters/client_channel/parse_address.h"
|
31
30
|
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
31
|
+
#include "src/core/ext/filters/client_channel/server_address.h"
|
32
32
|
#include "src/core/lib/channel/channel_args.h"
|
33
33
|
#include "src/core/lib/gpr/host_port.h"
|
34
34
|
#include "src/core/lib/gpr/string.h"
|
@@ -45,7 +45,8 @@ namespace {
|
|
45
45
|
class SockaddrResolver : public Resolver {
|
46
46
|
public:
|
47
47
|
/// Takes ownership of \a addresses.
|
48
|
-
SockaddrResolver(const ResolverArgs& args,
|
48
|
+
SockaddrResolver(const ResolverArgs& args,
|
49
|
+
UniquePtr<ServerAddressList> addresses);
|
49
50
|
|
50
51
|
void NextLocked(grpc_channel_args** result,
|
51
52
|
grpc_closure* on_complete) override;
|
@@ -58,7 +59,7 @@ class SockaddrResolver : public Resolver {
|
|
58
59
|
void MaybeFinishNextLocked();
|
59
60
|
|
60
61
|
/// the addresses that we've "resolved"
|
61
|
-
|
62
|
+
UniquePtr<ServerAddressList> addresses_;
|
62
63
|
/// channel args
|
63
64
|
grpc_channel_args* channel_args_ = nullptr;
|
64
65
|
/// have we published?
|
@@ -70,13 +71,12 @@ class SockaddrResolver : public Resolver {
|
|
70
71
|
};
|
71
72
|
|
72
73
|
SockaddrResolver::SockaddrResolver(const ResolverArgs& args,
|
73
|
-
|
74
|
+
UniquePtr<ServerAddressList> addresses)
|
74
75
|
: Resolver(args.combiner),
|
75
|
-
addresses_(addresses),
|
76
|
+
addresses_(std::move(addresses)),
|
76
77
|
channel_args_(grpc_channel_args_copy(args.args)) {}
|
77
78
|
|
78
79
|
SockaddrResolver::~SockaddrResolver() {
|
79
|
-
grpc_lb_addresses_destroy(addresses_);
|
80
80
|
grpc_channel_args_destroy(channel_args_);
|
81
81
|
}
|
82
82
|
|
@@ -100,7 +100,7 @@ void SockaddrResolver::ShutdownLocked() {
|
|
100
100
|
void SockaddrResolver::MaybeFinishNextLocked() {
|
101
101
|
if (next_completion_ != nullptr && !published_) {
|
102
102
|
published_ = true;
|
103
|
-
grpc_arg arg =
|
103
|
+
grpc_arg arg = CreateServerAddressListChannelArg(addresses_.get());
|
104
104
|
*target_result_ = grpc_channel_args_copy_and_add(channel_args_, &arg, 1);
|
105
105
|
GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_NONE);
|
106
106
|
next_completion_ = nullptr;
|
@@ -127,27 +127,27 @@ OrphanablePtr<Resolver> CreateSockaddrResolver(
|
|
127
127
|
grpc_slice_buffer path_parts;
|
128
128
|
grpc_slice_buffer_init(&path_parts);
|
129
129
|
grpc_slice_split(path_slice, ",", &path_parts);
|
130
|
-
|
131
|
-
path_parts.count, nullptr /* user_data_vtable */);
|
130
|
+
auto addresses = MakeUnique<ServerAddressList>();
|
132
131
|
bool errors_found = false;
|
133
|
-
for (size_t i = 0; i <
|
132
|
+
for (size_t i = 0; i < path_parts.count; i++) {
|
134
133
|
grpc_uri ith_uri = *args.uri;
|
135
|
-
char
|
136
|
-
ith_uri.path = part_str;
|
137
|
-
|
134
|
+
UniquePtr<char> part_str(grpc_slice_to_c_string(path_parts.slices[i]));
|
135
|
+
ith_uri.path = part_str.get();
|
136
|
+
grpc_resolved_address addr;
|
137
|
+
if (!parse(&ith_uri, &addr)) {
|
138
138
|
errors_found = true; /* GPR_TRUE */
|
139
|
+
break;
|
139
140
|
}
|
140
|
-
|
141
|
-
if (errors_found) break;
|
141
|
+
addresses->emplace_back(addr, nullptr /* args */);
|
142
142
|
}
|
143
143
|
grpc_slice_buffer_destroy_internal(&path_parts);
|
144
144
|
grpc_slice_unref_internal(path_slice);
|
145
145
|
if (errors_found) {
|
146
|
-
grpc_lb_addresses_destroy(addresses);
|
147
146
|
return OrphanablePtr<Resolver>(nullptr);
|
148
147
|
}
|
149
148
|
// Instantiate resolver.
|
150
|
-
return OrphanablePtr<Resolver>(
|
149
|
+
return OrphanablePtr<Resolver>(
|
150
|
+
New<SockaddrResolver>(args, std::move(addresses)));
|
151
151
|
}
|
152
152
|
|
153
153
|
class IPv4ResolverFactory : public ResolverFactory {
|
@@ -30,9 +30,11 @@
|
|
30
30
|
|
31
31
|
#include "src/core/ext/filters/client_channel/client_channel.h"
|
32
32
|
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
33
|
+
#include "src/core/ext/filters/client_channel/server_address.h"
|
33
34
|
#include "src/core/lib/channel/status_util.h"
|
34
35
|
#include "src/core/lib/gpr/string.h"
|
35
36
|
#include "src/core/lib/gprpp/memory.h"
|
37
|
+
#include "src/core/lib/uri/uri_parser.h"
|
36
38
|
|
37
39
|
// As per the retry design, we do not allow more than 5 retry attempts.
|
38
40
|
#define MAX_MAX_RETRY_ATTEMPTS 5
|
@@ -40,38 +42,17 @@
|
|
40
42
|
namespace grpc_core {
|
41
43
|
namespace internal {
|
42
44
|
|
43
|
-
namespace {
|
44
|
-
|
45
|
-
// Converts string format from JSON to proto.
|
46
|
-
grpc_core::UniquePtr<char> ConvertCamelToSnake(const char* camel) {
|
47
|
-
const size_t size = strlen(camel);
|
48
|
-
char* snake = static_cast<char*>(gpr_malloc(size * 2));
|
49
|
-
size_t j = 0;
|
50
|
-
for (size_t i = 0; i < size; ++i) {
|
51
|
-
if (isupper(camel[i])) {
|
52
|
-
snake[j++] = '_';
|
53
|
-
snake[j++] = tolower(camel[i]);
|
54
|
-
} else {
|
55
|
-
snake[j++] = camel[i];
|
56
|
-
}
|
57
|
-
}
|
58
|
-
snake[j] = '\0';
|
59
|
-
return grpc_core::UniquePtr<char>(snake);
|
60
|
-
}
|
61
|
-
|
62
|
-
} // namespace
|
63
|
-
|
64
45
|
ProcessedResolverResult::ProcessedResolverResult(
|
65
|
-
const grpc_channel_args
|
46
|
+
const grpc_channel_args& resolver_result, bool parse_retry) {
|
66
47
|
ProcessServiceConfig(resolver_result, parse_retry);
|
67
48
|
// If no LB config was found above, just find the LB policy name then.
|
68
|
-
if (
|
49
|
+
if (lb_policy_name_ == nullptr) ProcessLbPolicyName(resolver_result);
|
69
50
|
}
|
70
51
|
|
71
52
|
void ProcessedResolverResult::ProcessServiceConfig(
|
72
|
-
const grpc_channel_args
|
53
|
+
const grpc_channel_args& resolver_result, bool parse_retry) {
|
73
54
|
const grpc_arg* channel_arg =
|
74
|
-
grpc_channel_args_find(resolver_result, GRPC_ARG_SERVICE_CONFIG);
|
55
|
+
grpc_channel_args_find(&resolver_result, GRPC_ARG_SERVICE_CONFIG);
|
75
56
|
const char* service_config_json = grpc_channel_arg_get_string(channel_arg);
|
76
57
|
if (service_config_json != nullptr) {
|
77
58
|
service_config_json_.reset(gpr_strdup(service_config_json));
|
@@ -79,7 +60,7 @@ void ProcessedResolverResult::ProcessServiceConfig(
|
|
79
60
|
if (service_config_ != nullptr) {
|
80
61
|
if (parse_retry) {
|
81
62
|
channel_arg =
|
82
|
-
grpc_channel_args_find(resolver_result, GRPC_ARG_SERVER_URI);
|
63
|
+
grpc_channel_args_find(&resolver_result, GRPC_ARG_SERVER_URI);
|
83
64
|
const char* server_uri = grpc_channel_arg_get_string(channel_arg);
|
84
65
|
GPR_ASSERT(server_uri != nullptr);
|
85
66
|
grpc_uri* uri = grpc_uri_parse(server_uri, true);
|
@@ -97,42 +78,56 @@ void ProcessedResolverResult::ProcessServiceConfig(
|
|
97
78
|
}
|
98
79
|
|
99
80
|
void ProcessedResolverResult::ProcessLbPolicyName(
|
100
|
-
const grpc_channel_args
|
101
|
-
const char* lb_policy_name = nullptr;
|
81
|
+
const grpc_channel_args& resolver_result) {
|
102
82
|
// Prefer the LB policy name found in the service config. Note that this is
|
103
83
|
// checking the deprecated loadBalancingPolicy field, rather than the new
|
104
84
|
// loadBalancingConfig field.
|
105
85
|
if (service_config_ != nullptr) {
|
106
|
-
|
86
|
+
lb_policy_name_.reset(
|
87
|
+
gpr_strdup(service_config_->GetLoadBalancingPolicyName()));
|
88
|
+
// Convert to lower-case.
|
89
|
+
if (lb_policy_name_ != nullptr) {
|
90
|
+
char* lb_policy_name = lb_policy_name_.get();
|
91
|
+
for (size_t i = 0; i < strlen(lb_policy_name); ++i) {
|
92
|
+
lb_policy_name[i] = tolower(lb_policy_name[i]);
|
93
|
+
}
|
94
|
+
}
|
107
95
|
}
|
108
96
|
// Otherwise, find the LB policy name set by the client API.
|
109
|
-
if (
|
97
|
+
if (lb_policy_name_ == nullptr) {
|
110
98
|
const grpc_arg* channel_arg =
|
111
|
-
grpc_channel_args_find(resolver_result, GRPC_ARG_LB_POLICY_NAME);
|
112
|
-
|
99
|
+
grpc_channel_args_find(&resolver_result, GRPC_ARG_LB_POLICY_NAME);
|
100
|
+
lb_policy_name_.reset(gpr_strdup(grpc_channel_arg_get_string(channel_arg)));
|
113
101
|
}
|
114
102
|
// Special case: If at least one balancer address is present, we use
|
115
103
|
// the grpclb policy, regardless of what the resolver has returned.
|
116
|
-
const
|
117
|
-
|
118
|
-
if (
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
if (
|
123
|
-
|
104
|
+
const ServerAddressList* addresses =
|
105
|
+
FindServerAddressListChannelArg(&resolver_result);
|
106
|
+
if (addresses != nullptr) {
|
107
|
+
bool found_balancer_address = false;
|
108
|
+
for (size_t i = 0; i < addresses->size(); ++i) {
|
109
|
+
const ServerAddress& address = (*addresses)[i];
|
110
|
+
if (address.IsBalancer()) {
|
111
|
+
found_balancer_address = true;
|
112
|
+
break;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
if (found_balancer_address) {
|
116
|
+
if (lb_policy_name_ != nullptr &&
|
117
|
+
strcmp(lb_policy_name_.get(), "grpclb") != 0) {
|
124
118
|
gpr_log(GPR_INFO,
|
125
119
|
"resolver requested LB policy %s but provided at least one "
|
126
120
|
"balancer address -- forcing use of grpclb LB policy",
|
127
|
-
|
121
|
+
lb_policy_name_.get());
|
128
122
|
}
|
129
|
-
|
123
|
+
lb_policy_name_.reset(gpr_strdup("grpclb"));
|
130
124
|
}
|
131
125
|
}
|
132
126
|
// Use pick_first if nothing was specified and we didn't select grpclb
|
133
127
|
// above.
|
134
|
-
if (
|
135
|
-
|
128
|
+
if (lb_policy_name_ == nullptr) {
|
129
|
+
lb_policy_name_.reset(gpr_strdup("pick_first"));
|
130
|
+
}
|
136
131
|
}
|
137
132
|
|
138
133
|
void ProcessedResolverResult::ParseServiceConfig(
|
@@ -175,15 +170,13 @@ void ProcessedResolverResult::ParseLbConfigFromServiceConfig(
|
|
175
170
|
if (policy_content != nullptr) return; // Violate "oneof" type.
|
176
171
|
policy_content = field;
|
177
172
|
}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
173
|
+
// If we support this policy, then select it.
|
174
|
+
if (grpc_core::LoadBalancingPolicyRegistry::LoadBalancingPolicyExists(
|
175
|
+
policy_content->key)) {
|
176
|
+
lb_policy_name_.reset(gpr_strdup(policy_content->key));
|
177
|
+
lb_policy_config_ = policy_content->child;
|
178
|
+
return;
|
183
179
|
}
|
184
|
-
lb_policy_name_ = std::move(lb_policy_name);
|
185
|
-
lb_policy_config_ = policy_content->child;
|
186
|
-
return;
|
187
180
|
}
|
188
181
|
}
|
189
182
|
|
@@ -36,8 +36,7 @@ namespace internal {
|
|
36
36
|
class ClientChannelMethodParams;
|
37
37
|
|
38
38
|
// A table mapping from a method name to its method parameters.
|
39
|
-
typedef
|
40
|
-
grpc_core::RefCountedPtr<ClientChannelMethodParams>>
|
39
|
+
typedef SliceHashTable<RefCountedPtr<ClientChannelMethodParams>>
|
41
40
|
ClientChannelMethodParamsTable;
|
42
41
|
|
43
42
|
// A container of processed fields from the resolver result. Simplifies the
|
@@ -47,33 +46,30 @@ class ProcessedResolverResult {
|
|
47
46
|
// Processes the resolver result and populates the relative members
|
48
47
|
// for later consumption. Tries to parse retry parameters only if parse_retry
|
49
48
|
// is true.
|
50
|
-
ProcessedResolverResult(const grpc_channel_args
|
49
|
+
ProcessedResolverResult(const grpc_channel_args& resolver_result,
|
51
50
|
bool parse_retry);
|
52
51
|
|
53
52
|
// Getters. Any managed object's ownership is transferred.
|
54
|
-
|
53
|
+
UniquePtr<char> service_config_json() {
|
55
54
|
return std::move(service_config_json_);
|
56
55
|
}
|
57
|
-
|
56
|
+
RefCountedPtr<ServerRetryThrottleData> retry_throttle_data() {
|
58
57
|
return std::move(retry_throttle_data_);
|
59
58
|
}
|
60
|
-
|
61
|
-
method_params_table() {
|
59
|
+
RefCountedPtr<ClientChannelMethodParamsTable> method_params_table() {
|
62
60
|
return std::move(method_params_table_);
|
63
61
|
}
|
64
|
-
|
65
|
-
return std::move(lb_policy_name_);
|
66
|
-
}
|
62
|
+
UniquePtr<char> lb_policy_name() { return std::move(lb_policy_name_); }
|
67
63
|
grpc_json* lb_policy_config() { return lb_policy_config_; }
|
68
64
|
|
69
65
|
private:
|
70
66
|
// Finds the service config; extracts LB config and (maybe) retry throttle
|
71
67
|
// params from it.
|
72
|
-
void ProcessServiceConfig(const grpc_channel_args
|
68
|
+
void ProcessServiceConfig(const grpc_channel_args& resolver_result,
|
73
69
|
bool parse_retry);
|
74
70
|
|
75
71
|
// Finds the LB policy name (when no LB config was found).
|
76
|
-
void ProcessLbPolicyName(const grpc_channel_args
|
72
|
+
void ProcessLbPolicyName(const grpc_channel_args& resolver_result);
|
77
73
|
|
78
74
|
// Parses the service config. Intended to be used by
|
79
75
|
// ServiceConfig::ParseGlobalParams.
|
@@ -85,16 +81,16 @@ class ProcessedResolverResult {
|
|
85
81
|
void ParseRetryThrottleParamsFromServiceConfig(const grpc_json* field);
|
86
82
|
|
87
83
|
// Service config.
|
88
|
-
|
89
|
-
|
84
|
+
UniquePtr<char> service_config_json_;
|
85
|
+
UniquePtr<grpc_core::ServiceConfig> service_config_;
|
90
86
|
// LB policy.
|
91
87
|
grpc_json* lb_policy_config_ = nullptr;
|
92
|
-
|
88
|
+
UniquePtr<char> lb_policy_name_;
|
93
89
|
// Retry throttle data.
|
94
90
|
char* server_name_ = nullptr;
|
95
|
-
|
91
|
+
RefCountedPtr<ServerRetryThrottleData> retry_throttle_data_;
|
96
92
|
// Method params table.
|
97
|
-
|
93
|
+
RefCountedPtr<ClientChannelMethodParamsTable> method_params_table_;
|
98
94
|
};
|
99
95
|
|
100
96
|
// The parameters of a method.
|