grpc 1.20.0 → 1.21.0
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 +500 -29
- data/etc/roots.pem +146 -0
- data/include/grpc/grpc_security.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +10 -7
- data/include/grpc/impl/codegen/port_platform.h +11 -1
- data/include/grpc/impl/codegen/slice.h +1 -21
- data/include/grpc/impl/codegen/status.h +2 -1
- data/include/grpc/slice.h +1 -1
- data/src/core/ext/filters/client_channel/backup_poller.cc +19 -13
- data/src/core/ext/filters/client_channel/backup_poller.h +3 -0
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +2084 -1673
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +2 -3
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +54 -49
- data/src/core/ext/filters/client_channel/health/health_check_client.h +20 -9
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -2
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +3 -30
- data/src/core/ext/filters/client_channel/lb_policy.h +16 -25
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +106 -81
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +8 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -2
- 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 +57 -49
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +47 -41
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +24 -20
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +989 -284
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +105 -2
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +9 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +79 -36
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +84 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +179 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +15 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +80 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +7 -13
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +39 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +0 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +2 -64
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +29 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +367 -232
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +55 -76
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +50 -39
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +18 -12
- data/src/core/ext/filters/client_channel/service_config.cc +247 -27
- data/src/core/ext/filters/client_channel/service_config.h +119 -166
- data/src/core/ext/filters/client_channel/subchannel.cc +46 -84
- data/src/core/ext/filters/client_channel/subchannel.h +7 -7
- data/src/core/ext/filters/deadline/deadline_filter.cc +3 -4
- data/src/core/ext/filters/deadline/deadline_filter.h +3 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +7 -5
- data/src/core/ext/filters/http/client/http_client_filter.h +1 -1
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -3
- data/src/core/ext/filters/http/server/http_server_filter.cc +18 -12
- data/src/core/ext/filters/message_size/message_size_filter.cc +118 -76
- data/src/core/ext/filters/message_size/message_size_filter.h +33 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.h +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +9 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +93 -60
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +8 -2
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +3 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +35 -23
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +61 -27
- data/src/core/ext/transport/inproc/inproc_transport.cc +18 -18
- data/src/core/lib/channel/channel_args.cc +0 -101
- data/src/core/lib/channel/channel_args.h +0 -37
- data/src/core/lib/channel/channel_stack.h +9 -5
- data/src/core/lib/channel/channelz_registry.cc +1 -1
- data/src/core/lib/channel/connected_channel.cc +2 -2
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/handshaker.cc +4 -4
- data/src/core/lib/channel/handshaker.h +1 -1
- data/src/core/lib/compression/compression_args.cc +127 -0
- data/src/core/lib/compression/compression_args.h +55 -0
- data/src/core/lib/debug/trace.cc +13 -7
- data/src/core/lib/debug/trace.h +12 -0
- data/src/core/lib/gpr/arena.h +13 -9
- data/src/core/lib/gpr/env.h +2 -5
- data/src/core/lib/gpr/env_linux.cc +6 -1
- data/src/core/lib/gpr/env_posix.cc +5 -0
- data/src/core/lib/gpr/env_windows.cc +7 -5
- data/src/core/lib/gpr/log.cc +9 -13
- data/src/core/lib/gpr/string.cc +12 -6
- data/src/core/lib/gpr/string.h +4 -2
- data/src/core/lib/gpr/time_posix.cc +13 -0
- data/src/core/lib/gprpp/arena.cc +103 -0
- data/src/core/lib/gprpp/arena.h +121 -0
- data/src/core/lib/gprpp/fork.cc +12 -29
- data/src/core/lib/gprpp/global_config.h +87 -0
- data/src/core/lib/gprpp/global_config_custom.h +29 -0
- data/src/core/lib/gprpp/global_config_env.cc +135 -0
- data/src/core/lib/gprpp/global_config_env.h +131 -0
- data/src/core/lib/gprpp/global_config_generic.h +44 -0
- data/src/core/lib/gprpp/map.h +419 -0
- data/src/core/lib/gprpp/optional.h +1 -0
- data/src/core/lib/gprpp/orphanable.h +2 -2
- data/src/core/lib/gprpp/{mutex_lock.h → pair.h} +15 -19
- data/src/core/lib/gprpp/ref_counted.h +18 -2
- data/src/core/lib/gprpp/sync.h +126 -0
- data/src/core/lib/http/parser.cc +1 -1
- data/src/core/lib/iomgr/call_combiner.cc +84 -90
- data/src/core/lib/iomgr/call_combiner.h +75 -82
- data/src/core/lib/iomgr/cfstream_handle.cc +202 -0
- data/src/core/lib/iomgr/cfstream_handle.h +82 -0
- data/src/core/lib/iomgr/combiner.h +1 -1
- data/src/core/lib/iomgr/endpoint_cfstream.cc +375 -0
- data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/error.h +23 -0
- data/src/core/lib/iomgr/error_cfstream.cc +52 -0
- data/src/core/lib/iomgr/error_cfstream.h +31 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +34 -27
- data/src/core/lib/iomgr/ev_epollex_linux.cc +33 -33
- data/src/core/lib/iomgr/ev_poll_posix.cc +7 -7
- data/src/core/lib/iomgr/ev_posix.cc +15 -13
- data/src/core/lib/iomgr/ev_posix.h +4 -1
- data/src/core/lib/iomgr/executor.cc +13 -9
- data/src/core/lib/iomgr/fork_posix.cc +0 -1
- data/src/core/lib/iomgr/internal_errqueue.cc +1 -1
- data/src/core/lib/iomgr/iomgr.cc +6 -5
- data/src/core/lib/iomgr/iomgr_custom.cc +3 -0
- data/src/core/lib/iomgr/iomgr_custom.h +2 -0
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +93 -0
- data/src/core/lib/iomgr/iomgr_windows.cc +1 -0
- data/src/core/lib/iomgr/lockfree_event.cc +3 -3
- data/src/core/lib/iomgr/port.h +11 -0
- data/src/core/lib/iomgr/resource_quota.cc +40 -37
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +6 -2
- data/src/core/lib/iomgr/socket_windows.cc +19 -0
- data/src/core/lib/iomgr/socket_windows.h +8 -0
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +216 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_client_windows.cc +1 -1
- data/src/core/lib/iomgr/tcp_custom.cc +9 -9
- data/src/core/lib/iomgr/tcp_posix.cc +41 -41
- data/src/core/lib/iomgr/tcp_server_custom.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_posix.cc +14 -1
- data/src/core/lib/iomgr/tcp_server_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_windows.cc +7 -9
- data/src/core/lib/iomgr/timer_generic.cc +16 -16
- data/src/core/lib/iomgr/timer_manager.cc +12 -11
- data/src/core/lib/profiling/basic_timers.cc +10 -4
- data/src/core/lib/security/context/security_context.cc +6 -7
- data/src/core/lib/security/context/security_context.h +3 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +7 -7
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +7 -5
- data/src/core/lib/security/security_connector/security_connector.cc +0 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/ssl_utils.cc +30 -26
- data/src/core/lib/security/security_connector/ssl_utils.h +5 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +7 -11
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
- data/src/core/lib/security/transport/server_auth_filter.cc +2 -3
- data/src/core/lib/slice/slice.cc +99 -116
- data/src/core/lib/slice/slice_buffer.cc +5 -0
- data/src/core/lib/slice/slice_intern.cc +38 -95
- data/src/core/lib/slice/slice_internal.h +200 -2
- data/src/core/lib/surface/api_trace.h +1 -1
- data/src/core/lib/surface/call.cc +41 -35
- data/src/core/lib/surface/call.h +7 -2
- data/src/core/lib/surface/call_details.cc +0 -1
- data/src/core/lib/surface/completion_queue.cc +36 -27
- data/src/core/lib/surface/init.cc +3 -4
- data/src/core/lib/surface/lame_client.cc +1 -1
- data/src/core/lib/surface/server.cc +18 -25
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/bdp_estimator.cc +3 -3
- data/src/core/lib/transport/bdp_estimator.h +2 -2
- data/src/core/lib/transport/connectivity_state.cc +10 -40
- data/src/core/lib/transport/connectivity_state.h +0 -8
- data/src/core/lib/transport/error_utils.cc +12 -0
- data/src/core/lib/transport/metadata.cc +206 -278
- data/src/core/lib/transport/metadata.h +205 -10
- data/src/core/lib/transport/static_metadata.cc +108 -116
- data/src/core/lib/transport/static_metadata.h +1 -2
- data/src/core/lib/transport/status_metadata.cc +3 -3
- data/src/core/lib/transport/transport.cc +29 -66
- data/src/core/lib/transport/transport.h +36 -8
- data/src/core/lib/transport/transport_impl.h +1 -1
- data/src/core/tsi/fake_transport_security.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -1
- data/src/ruby/lib/grpc/errors.rb +22 -3
- data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/errors_spec.rb +141 -0
- metadata +57 -33
- data/src/core/lib/gpr/arena.cc +0 -192
@@ -22,10 +22,12 @@
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
24
|
#include "src/core/ext/filters/client_channel/lb_policy.h"
|
25
|
+
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
25
26
|
#include "src/core/ext/filters/client_channel/resolver.h"
|
26
27
|
#include "src/core/ext/filters/client_channel/retry_throttle.h"
|
27
28
|
#include "src/core/ext/filters/client_channel/service_config.h"
|
28
29
|
#include "src/core/lib/channel/status_util.h"
|
30
|
+
#include "src/core/lib/gprpp/optional.h"
|
29
31
|
#include "src/core/lib/gprpp/ref_counted.h"
|
30
32
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
31
33
|
#include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis
|
@@ -35,76 +37,48 @@
|
|
35
37
|
namespace grpc_core {
|
36
38
|
namespace internal {
|
37
39
|
|
38
|
-
class
|
39
|
-
|
40
|
-
// A table mapping from a method name to its method parameters.
|
41
|
-
typedef SliceHashTable<RefCountedPtr<ClientChannelMethodParams>>
|
42
|
-
ClientChannelMethodParamsTable;
|
43
|
-
|
44
|
-
// A container of processed fields from the resolver result. Simplifies the
|
45
|
-
// usage of resolver result.
|
46
|
-
class ProcessedResolverResult {
|
40
|
+
class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig {
|
47
41
|
public:
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
struct RetryThrottling {
|
43
|
+
intptr_t max_milli_tokens = 0;
|
44
|
+
intptr_t milli_token_ratio = 0;
|
45
|
+
};
|
46
|
+
|
47
|
+
ClientChannelGlobalParsedObject(
|
48
|
+
RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config,
|
49
|
+
UniquePtr<char> parsed_deprecated_lb_policy,
|
50
|
+
const Optional<RetryThrottling>& retry_throttling,
|
51
|
+
const char* health_check_service_name)
|
52
|
+
: parsed_lb_config_(std::move(parsed_lb_config)),
|
53
|
+
parsed_deprecated_lb_policy_(std::move(parsed_deprecated_lb_policy)),
|
54
|
+
retry_throttling_(retry_throttling),
|
55
|
+
health_check_service_name_(health_check_service_name) {}
|
56
|
+
|
57
|
+
Optional<RetryThrottling> retry_throttling() const {
|
58
|
+
return retry_throttling_;
|
56
59
|
}
|
57
|
-
|
58
|
-
|
60
|
+
|
61
|
+
RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config() const {
|
62
|
+
return parsed_lb_config_;
|
59
63
|
}
|
60
|
-
|
61
|
-
|
64
|
+
|
65
|
+
const char* parsed_deprecated_lb_policy() const {
|
66
|
+
return parsed_deprecated_lb_policy_.get();
|
62
67
|
}
|
63
|
-
|
64
|
-
|
65
|
-
return
|
68
|
+
|
69
|
+
const char* health_check_service_name() const {
|
70
|
+
return health_check_service_name_;
|
66
71
|
}
|
67
72
|
|
68
73
|
private:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
// Finds the LB policy name (when no LB config was found).
|
75
|
-
void ProcessLbPolicyName(const Resolver::Result& resolver_result);
|
76
|
-
|
77
|
-
// Parses the service config. Intended to be used by
|
78
|
-
// ServiceConfig::ParseGlobalParams.
|
79
|
-
static void ParseServiceConfig(const grpc_json* field,
|
80
|
-
ProcessedResolverResult* parsing_state);
|
81
|
-
// Parses the LB config from service config.
|
82
|
-
void ParseLbConfigFromServiceConfig(const grpc_json* field);
|
83
|
-
// Parses the retry throttle parameters from service config.
|
84
|
-
void ParseRetryThrottleParamsFromServiceConfig(const grpc_json* field);
|
85
|
-
|
86
|
-
// Service config.
|
87
|
-
UniquePtr<char> service_config_json_;
|
88
|
-
RefCountedPtr<ServiceConfig> service_config_;
|
89
|
-
// LB policy.
|
90
|
-
UniquePtr<char> lb_policy_name_;
|
91
|
-
RefCountedPtr<LoadBalancingPolicy::Config> lb_policy_config_;
|
92
|
-
// Retry throttle data.
|
93
|
-
char* server_name_ = nullptr;
|
94
|
-
RefCountedPtr<ServerRetryThrottleData> retry_throttle_data_;
|
95
|
-
// Method params table.
|
96
|
-
RefCountedPtr<ClientChannelMethodParamsTable> method_params_table_;
|
74
|
+
RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config_;
|
75
|
+
UniquePtr<char> parsed_deprecated_lb_policy_;
|
76
|
+
Optional<RetryThrottling> retry_throttling_;
|
77
|
+
const char* health_check_service_name_;
|
97
78
|
};
|
98
79
|
|
99
|
-
|
100
|
-
class ClientChannelMethodParams : public RefCounted<ClientChannelMethodParams> {
|
80
|
+
class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig {
|
101
81
|
public:
|
102
|
-
enum WaitForReady {
|
103
|
-
WAIT_FOR_READY_UNSET = 0,
|
104
|
-
WAIT_FOR_READY_FALSE,
|
105
|
-
WAIT_FOR_READY_TRUE
|
106
|
-
};
|
107
|
-
|
108
82
|
struct RetryPolicy {
|
109
83
|
int max_attempts = 0;
|
110
84
|
grpc_millis initial_backoff = 0;
|
@@ -113,30 +87,35 @@ class ClientChannelMethodParams : public RefCounted<ClientChannelMethodParams> {
|
|
113
87
|
StatusCodeSet retryable_status_codes;
|
114
88
|
};
|
115
89
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
90
|
+
ClientChannelMethodParsedObject(grpc_millis timeout,
|
91
|
+
const Optional<bool>& wait_for_ready,
|
92
|
+
UniquePtr<RetryPolicy> retry_policy)
|
93
|
+
: timeout_(timeout),
|
94
|
+
wait_for_ready_(wait_for_ready),
|
95
|
+
retry_policy_(std::move(retry_policy)) {}
|
120
96
|
|
121
97
|
grpc_millis timeout() const { return timeout_; }
|
122
|
-
|
98
|
+
|
99
|
+
Optional<bool> wait_for_ready() const { return wait_for_ready_; }
|
100
|
+
|
123
101
|
const RetryPolicy* retry_policy() const { return retry_policy_.get(); }
|
124
102
|
|
125
103
|
private:
|
126
|
-
|
127
|
-
|
128
|
-
|
104
|
+
grpc_millis timeout_ = 0;
|
105
|
+
Optional<bool> wait_for_ready_;
|
106
|
+
UniquePtr<RetryPolicy> retry_policy_;
|
107
|
+
};
|
129
108
|
|
130
|
-
|
131
|
-
|
132
|
-
|
109
|
+
class ClientChannelServiceConfigParser : public ServiceConfig::Parser {
|
110
|
+
public:
|
111
|
+
UniquePtr<ServiceConfig::ParsedConfig> ParseGlobalParams(
|
112
|
+
const grpc_json* json, grpc_error** error) override;
|
133
113
|
|
134
|
-
|
135
|
-
|
114
|
+
UniquePtr<ServiceConfig::ParsedConfig> ParsePerMethodParams(
|
115
|
+
const grpc_json* json, grpc_error** error) override;
|
136
116
|
|
137
|
-
|
138
|
-
|
139
|
-
UniquePtr<RetryPolicy> retry_policy_;
|
117
|
+
static size_t ParserIndex();
|
118
|
+
static void Register();
|
140
119
|
};
|
141
120
|
|
142
121
|
} // namespace internal
|
@@ -48,7 +48,7 @@
|
|
48
48
|
#include "src/core/lib/gpr/string.h"
|
49
49
|
#include "src/core/lib/gprpp/inlined_vector.h"
|
50
50
|
#include "src/core/lib/gprpp/manual_constructor.h"
|
51
|
-
#include "src/core/lib/gprpp/
|
51
|
+
#include "src/core/lib/gprpp/sync.h"
|
52
52
|
#include "src/core/lib/iomgr/combiner.h"
|
53
53
|
#include "src/core/lib/iomgr/iomgr.h"
|
54
54
|
#include "src/core/lib/iomgr/polling_entity.h"
|
@@ -77,7 +77,7 @@ class ResolvingLoadBalancingPolicy::ResolverResultHandler
|
|
77
77
|
: parent_(std::move(parent)) {}
|
78
78
|
|
79
79
|
~ResolverResultHandler() {
|
80
|
-
if (parent_->tracer_
|
80
|
+
if (GRPC_TRACE_FLAG_ENABLED(*(parent_->tracer_))) {
|
81
81
|
gpr_log(GPR_INFO, "resolving_lb=%p: resolver shutdown complete",
|
82
82
|
parent_.get());
|
83
83
|
}
|
@@ -119,27 +119,20 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
|
|
119
119
|
return parent_->channel_control_helper()->CreateChannel(target, args);
|
120
120
|
}
|
121
121
|
|
122
|
-
void UpdateState(grpc_connectivity_state state,
|
122
|
+
void UpdateState(grpc_connectivity_state state,
|
123
123
|
UniquePtr<SubchannelPicker> picker) override {
|
124
|
-
if (parent_->resolver_ == nullptr)
|
125
|
-
// shutting down.
|
126
|
-
GRPC_ERROR_UNREF(state_error);
|
127
|
-
return;
|
128
|
-
}
|
124
|
+
if (parent_->resolver_ == nullptr) return; // Shutting down.
|
129
125
|
// If this request is from the pending child policy, ignore it until
|
130
126
|
// it reports READY, at which point we swap it into place.
|
131
127
|
if (CalledByPendingChild()) {
|
132
|
-
if (parent_->tracer_
|
128
|
+
if (GRPC_TRACE_FLAG_ENABLED(*(parent_->tracer_))) {
|
133
129
|
gpr_log(GPR_INFO,
|
134
130
|
"resolving_lb=%p helper=%p: pending child policy %p reports "
|
135
131
|
"state=%s",
|
136
132
|
parent_.get(), this, child_,
|
137
133
|
grpc_connectivity_state_name(state));
|
138
134
|
}
|
139
|
-
if (state != GRPC_CHANNEL_READY)
|
140
|
-
GRPC_ERROR_UNREF(state_error);
|
141
|
-
return;
|
142
|
-
}
|
135
|
+
if (state != GRPC_CHANNEL_READY) return;
|
143
136
|
grpc_pollset_set_del_pollset_set(
|
144
137
|
parent_->lb_policy_->interested_parties(),
|
145
138
|
parent_->interested_parties());
|
@@ -147,11 +140,9 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
|
|
147
140
|
parent_->lb_policy_ = std::move(parent_->pending_lb_policy_);
|
148
141
|
} else if (!CalledByCurrentChild()) {
|
149
142
|
// This request is from an outdated child, so ignore it.
|
150
|
-
GRPC_ERROR_UNREF(state_error);
|
151
143
|
return;
|
152
144
|
}
|
153
|
-
parent_->channel_control_helper()->UpdateState(state,
|
154
|
-
std::move(picker));
|
145
|
+
parent_->channel_control_helper()->UpdateState(state, std::move(picker));
|
155
146
|
}
|
156
147
|
|
157
148
|
void RequestReresolution() override {
|
@@ -160,7 +151,7 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
|
|
160
151
|
if (parent_->pending_lb_policy_ != nullptr && !CalledByPendingChild()) {
|
161
152
|
return;
|
162
153
|
}
|
163
|
-
if (parent_->tracer_
|
154
|
+
if (GRPC_TRACE_FLAG_ENABLED(*(parent_->tracer_))) {
|
164
155
|
gpr_log(GPR_INFO, "resolving_lb=%p: started name re-resolving",
|
165
156
|
parent_.get());
|
166
157
|
}
|
@@ -192,7 +183,8 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
|
|
192
183
|
|
193
184
|
ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy(
|
194
185
|
Args args, TraceFlag* tracer, UniquePtr<char> target_uri,
|
195
|
-
UniquePtr<char> child_policy_name,
|
186
|
+
UniquePtr<char> child_policy_name,
|
187
|
+
RefCountedPtr<ParsedLoadBalancingConfig> child_lb_config,
|
196
188
|
grpc_error** error)
|
197
189
|
: LoadBalancingPolicy(std::move(args)),
|
198
190
|
tracer_(tracer),
|
@@ -234,8 +226,7 @@ grpc_error* ResolvingLoadBalancingPolicy::Init(const grpc_channel_args& args) {
|
|
234
226
|
}
|
235
227
|
// Return our picker to the channel.
|
236
228
|
channel_control_helper()->UpdateState(
|
237
|
-
GRPC_CHANNEL_IDLE,
|
238
|
-
UniquePtr<SubchannelPicker>(New<QueuePicker>(Ref())));
|
229
|
+
GRPC_CHANNEL_IDLE, UniquePtr<SubchannelPicker>(New<QueuePicker>(Ref())));
|
239
230
|
return GRPC_ERROR_NONE;
|
240
231
|
}
|
241
232
|
|
@@ -250,7 +241,7 @@ void ResolvingLoadBalancingPolicy::ShutdownLocked() {
|
|
250
241
|
resolver_.reset();
|
251
242
|
MutexLock lock(&lb_policy_mu_);
|
252
243
|
if (lb_policy_ != nullptr) {
|
253
|
-
if (tracer_
|
244
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
254
245
|
gpr_log(GPR_INFO, "resolving_lb=%p: shutting down lb_policy=%p", this,
|
255
246
|
lb_policy_.get());
|
256
247
|
}
|
@@ -259,7 +250,7 @@ void ResolvingLoadBalancingPolicy::ShutdownLocked() {
|
|
259
250
|
lb_policy_.reset();
|
260
251
|
}
|
261
252
|
if (pending_lb_policy_ != nullptr) {
|
262
|
-
if (tracer_
|
253
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
263
254
|
gpr_log(GPR_INFO, "resolving_lb=%p: shutting down pending lb_policy=%p",
|
264
255
|
this, pending_lb_policy_.get());
|
265
256
|
}
|
@@ -307,13 +298,13 @@ void ResolvingLoadBalancingPolicy::FillChildRefsForChannelz(
|
|
307
298
|
}
|
308
299
|
|
309
300
|
void ResolvingLoadBalancingPolicy::StartResolvingLocked() {
|
310
|
-
if (tracer_
|
301
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
311
302
|
gpr_log(GPR_INFO, "resolving_lb=%p: starting name resolution", this);
|
312
303
|
}
|
313
304
|
GPR_ASSERT(!started_resolving_);
|
314
305
|
started_resolving_ = true;
|
315
306
|
channel_control_helper()->UpdateState(
|
316
|
-
GRPC_CHANNEL_CONNECTING,
|
307
|
+
GRPC_CHANNEL_CONNECTING,
|
317
308
|
UniquePtr<SubchannelPicker>(New<QueuePicker>(Ref())));
|
318
309
|
resolver_->StartLocked();
|
319
310
|
}
|
@@ -323,7 +314,7 @@ void ResolvingLoadBalancingPolicy::OnResolverError(grpc_error* error) {
|
|
323
314
|
GRPC_ERROR_UNREF(error);
|
324
315
|
return;
|
325
316
|
}
|
326
|
-
if (tracer_
|
317
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
327
318
|
gpr_log(GPR_INFO, "resolving_lb=%p: resolver transient failure: %s", this,
|
328
319
|
grpc_error_string(error));
|
329
320
|
}
|
@@ -334,14 +325,15 @@ void ResolvingLoadBalancingPolicy::OnResolverError(grpc_error* error) {
|
|
334
325
|
grpc_error* state_error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
335
326
|
"Resolver transient failure", &error, 1);
|
336
327
|
channel_control_helper()->UpdateState(
|
337
|
-
GRPC_CHANNEL_TRANSIENT_FAILURE,
|
328
|
+
GRPC_CHANNEL_TRANSIENT_FAILURE,
|
338
329
|
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(state_error)));
|
339
330
|
}
|
340
331
|
GRPC_ERROR_UNREF(error);
|
341
332
|
}
|
342
333
|
|
343
334
|
void ResolvingLoadBalancingPolicy::CreateOrUpdateLbPolicyLocked(
|
344
|
-
const char* lb_policy_name,
|
335
|
+
const char* lb_policy_name,
|
336
|
+
RefCountedPtr<ParsedLoadBalancingConfig> lb_policy_config,
|
345
337
|
Resolver::Result result, TraceStringVector* trace_strings) {
|
346
338
|
// If the child policy name changes, we need to create a new child
|
347
339
|
// policy. When this happens, we leave child_policy_ as-is and store
|
@@ -406,7 +398,7 @@ void ResolvingLoadBalancingPolicy::CreateOrUpdateLbPolicyLocked(
|
|
406
398
|
// Cases 1, 2b, and 3b: create a new child policy.
|
407
399
|
// If lb_policy_ is null, we set it (case 1), else we set
|
408
400
|
// pending_lb_policy_ (cases 2b and 3b).
|
409
|
-
if (tracer_
|
401
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
410
402
|
gpr_log(GPR_INFO, "resolving_lb=%p: Creating new %schild policy %s", this,
|
411
403
|
lb_policy_ == nullptr ? "" : "pending ", lb_policy_name);
|
412
404
|
}
|
@@ -427,7 +419,7 @@ void ResolvingLoadBalancingPolicy::CreateOrUpdateLbPolicyLocked(
|
|
427
419
|
}
|
428
420
|
GPR_ASSERT(policy_to_update != nullptr);
|
429
421
|
// Update the policy.
|
430
|
-
if (tracer_
|
422
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
431
423
|
gpr_log(GPR_INFO, "resolving_lb=%p: Updating %schild policy %p", this,
|
432
424
|
policy_to_update == pending_lb_policy_.get() ? "pending " : "",
|
433
425
|
policy_to_update);
|
@@ -466,7 +458,7 @@ ResolvingLoadBalancingPolicy::CreateLbPolicyLocked(
|
|
466
458
|
return nullptr;
|
467
459
|
}
|
468
460
|
helper->set_child(lb_policy.get());
|
469
|
-
if (tracer_
|
461
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
470
462
|
gpr_log(GPR_INFO, "resolving_lb=%p: created new LB policy \"%s\" (%p)",
|
471
463
|
this, lb_policy_name, lb_policy.get());
|
472
464
|
}
|
@@ -522,7 +514,7 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked(
|
|
522
514
|
Resolver::Result result) {
|
523
515
|
// Handle race conditions.
|
524
516
|
if (resolver_ == nullptr) return;
|
525
|
-
if (tracer_
|
517
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
526
518
|
gpr_log(GPR_INFO, "resolving_lb=%p: got resolver result", this);
|
527
519
|
}
|
528
520
|
// We only want to trace the address resolution in the follow cases:
|
@@ -538,20 +530,34 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked(
|
|
538
530
|
const bool resolution_contains_addresses = result.addresses.size() > 0;
|
539
531
|
// Process the resolver result.
|
540
532
|
const char* lb_policy_name = nullptr;
|
541
|
-
RefCountedPtr<
|
533
|
+
RefCountedPtr<ParsedLoadBalancingConfig> lb_policy_config;
|
542
534
|
bool service_config_changed = false;
|
535
|
+
char* service_config_error_string = nullptr;
|
543
536
|
if (process_resolver_result_ != nullptr) {
|
544
|
-
|
545
|
-
|
546
|
-
|
537
|
+
grpc_error* service_config_error = GRPC_ERROR_NONE;
|
538
|
+
service_config_changed = process_resolver_result_(
|
539
|
+
process_resolver_result_user_data_, result, &lb_policy_name,
|
540
|
+
&lb_policy_config, &service_config_error);
|
541
|
+
if (service_config_error != GRPC_ERROR_NONE) {
|
542
|
+
service_config_error_string =
|
543
|
+
gpr_strdup(grpc_error_string(service_config_error));
|
544
|
+
if (lb_policy_name == nullptr) {
|
545
|
+
// Use an empty lb_policy_name as an indicator that we received an
|
546
|
+
// invalid service config and we don't have a fallback service config.
|
547
|
+
OnResolverError(service_config_error);
|
548
|
+
} else {
|
549
|
+
GRPC_ERROR_UNREF(service_config_error);
|
550
|
+
}
|
551
|
+
}
|
547
552
|
} else {
|
548
553
|
lb_policy_name = child_policy_name_.get();
|
549
554
|
lb_policy_config = child_lb_config_;
|
550
555
|
}
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
556
|
+
if (lb_policy_name != nullptr) {
|
557
|
+
// Create or update LB policy, as needed.
|
558
|
+
CreateOrUpdateLbPolicyLocked(lb_policy_name, lb_policy_config,
|
559
|
+
std::move(result), &trace_strings);
|
560
|
+
}
|
555
561
|
// Add channel trace event.
|
556
562
|
if (channelz_node() != nullptr) {
|
557
563
|
if (service_config_changed) {
|
@@ -559,10 +565,15 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked(
|
|
559
565
|
// config in the trace, at the risk of bloating the trace logs.
|
560
566
|
trace_strings.push_back(gpr_strdup("Service config changed"));
|
561
567
|
}
|
568
|
+
if (service_config_error_string != nullptr) {
|
569
|
+
trace_strings.push_back(service_config_error_string);
|
570
|
+
service_config_error_string = nullptr;
|
571
|
+
}
|
562
572
|
MaybeAddTraceMessagesForAddressChangesLocked(resolution_contains_addresses,
|
563
573
|
&trace_strings);
|
564
574
|
ConcatenateAndAddChannelTraceLocked(&trace_strings);
|
565
575
|
}
|
576
|
+
gpr_free(service_config_error_string);
|
566
577
|
}
|
567
578
|
|
568
579
|
} // namespace grpc_core
|
@@ -23,6 +23,7 @@
|
|
23
23
|
|
24
24
|
#include "src/core/ext/filters/client_channel/client_channel_channelz.h"
|
25
25
|
#include "src/core/ext/filters/client_channel/lb_policy.h"
|
26
|
+
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
26
27
|
#include "src/core/ext/filters/client_channel/resolver.h"
|
27
28
|
#include "src/core/lib/channel/channel_args.h"
|
28
29
|
#include "src/core/lib/channel/channel_stack.h"
|
@@ -53,20 +54,25 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
|
|
53
54
|
public:
|
54
55
|
// If error is set when this returns, then construction failed, and
|
55
56
|
// the caller may not use the new object.
|
56
|
-
ResolvingLoadBalancingPolicy(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
ResolvingLoadBalancingPolicy(
|
58
|
+
Args args, TraceFlag* tracer, UniquePtr<char> target_uri,
|
59
|
+
UniquePtr<char> child_policy_name,
|
60
|
+
RefCountedPtr<ParsedLoadBalancingConfig> child_lb_config,
|
61
|
+
grpc_error** error);
|
61
62
|
|
62
63
|
// Private ctor, to be used by client_channel only!
|
63
64
|
//
|
64
65
|
// Synchronous callback that takes the resolver result and sets
|
65
66
|
// lb_policy_name and lb_policy_config to point to the right data.
|
66
67
|
// Returns true if the service config has changed since the last result.
|
68
|
+
// If the returned service_config_error is not none and lb_policy_name is
|
69
|
+
// empty, it means that we don't have a valid service config to use, and we
|
70
|
+
// should set the channel to be in TRANSIENT_FAILURE.
|
67
71
|
typedef bool (*ProcessResolverResultCallback)(
|
68
|
-
void* user_data, Resolver::Result
|
69
|
-
|
72
|
+
void* user_data, const Resolver::Result& result,
|
73
|
+
const char** lb_policy_name,
|
74
|
+
RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config,
|
75
|
+
grpc_error** service_config_error);
|
70
76
|
// If error is set when this returns, then construction failed, and
|
71
77
|
// the caller may not use the new object.
|
72
78
|
ResolvingLoadBalancingPolicy(
|
@@ -102,10 +108,10 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
|
|
102
108
|
|
103
109
|
void StartResolvingLocked();
|
104
110
|
void OnResolverError(grpc_error* error);
|
105
|
-
void CreateOrUpdateLbPolicyLocked(
|
106
|
-
|
107
|
-
|
108
|
-
|
111
|
+
void CreateOrUpdateLbPolicyLocked(
|
112
|
+
const char* lb_policy_name,
|
113
|
+
RefCountedPtr<ParsedLoadBalancingConfig> lb_policy_config,
|
114
|
+
Resolver::Result result, TraceStringVector* trace_strings);
|
109
115
|
OrphanablePtr<LoadBalancingPolicy> CreateLbPolicyLocked(
|
110
116
|
const char* lb_policy_name, const grpc_channel_args& args,
|
111
117
|
TraceStringVector* trace_strings);
|
@@ -121,7 +127,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
|
|
121
127
|
ProcessResolverResultCallback process_resolver_result_ = nullptr;
|
122
128
|
void* process_resolver_result_user_data_ = nullptr;
|
123
129
|
UniquePtr<char> child_policy_name_;
|
124
|
-
RefCountedPtr<
|
130
|
+
RefCountedPtr<ParsedLoadBalancingConfig> child_lb_config_;
|
125
131
|
|
126
132
|
// Resolver and associated state.
|
127
133
|
OrphanablePtr<Resolver> resolver_;
|