grpc 1.19.0 → 1.20.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 +4131 -7903
- data/include/grpc/grpc.h +11 -6
- data/include/grpc/grpc_security.h +51 -9
- data/include/grpc/impl/codegen/byte_buffer.h +13 -0
- data/include/grpc/impl/codegen/grpc_types.h +4 -0
- data/include/grpc/impl/codegen/port_platform.h +37 -6
- data/include/grpc/impl/codegen/sync_posix.h +18 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +560 -236
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +2 -2
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +22 -34
- data/src/core/ext/filters/client_channel/client_channel_factory.h +19 -38
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +7 -4
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy.cc +105 -28
- data/src/core/ext/filters/client_channel/lb_policy.h +259 -141
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +29 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +789 -803
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +2 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +7 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +8 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +127 -219
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +103 -282
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +4 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +709 -906
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +0 -43
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +8 -8
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -6
- data/src/core/ext/filters/client_channel/resolver.cc +54 -1
- data/src/core/ext/filters/client_channel/resolver.h +51 -22
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +34 -86
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +29 -41
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +32 -78
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +109 -72
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +13 -8
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +28 -63
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -1
- data/src/core/ext/filters/client_channel/resolver_registry.cc +5 -2
- data/src/core/ext/filters/client_channel/resolver_registry.h +5 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +69 -49
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +11 -8
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +568 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +141 -0
- data/src/core/ext/filters/client_channel/server_address.cc +0 -48
- data/src/core/ext/filters/client_channel/server_address.h +0 -10
- data/src/core/{lib/transport → ext/filters/client_channel}/service_config.cc +10 -5
- data/src/core/{lib/transport → ext/filters/client_channel}/service_config.h +16 -12
- data/src/core/ext/filters/client_channel/subchannel.cc +11 -16
- data/src/core/ext/filters/client_channel/subchannel.h +3 -0
- data/src/core/ext/filters/max_age/max_age_filter.cc +4 -1
- data/src/core/ext/filters/message_size/message_size_filter.cc +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +45 -45
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +133 -134
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +4 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +37 -29
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +9 -5
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +5 -4
- data/src/core/ext/transport/chttp2/transport/parsing.cc +9 -9
- data/src/core/ext/transport/chttp2/transport/writing.cc +1 -1
- data/src/core/ext/transport/inproc/inproc_transport.cc +8 -0
- data/src/core/lib/channel/channel_args.cc +2 -0
- data/src/core/lib/channel/channel_args.h +3 -0
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channel_trace.h +4 -4
- data/src/core/lib/channel/channelz.cc +32 -19
- data/src/core/lib/channel/channelz.h +4 -4
- data/src/core/lib/channel/channelz_registry.cc +1 -1
- data/src/core/lib/channel/context.h +0 -3
- data/src/core/lib/channel/handshaker_registry.cc +7 -3
- data/src/core/lib/compression/algorithm_metadata.h +3 -3
- data/src/core/lib/compression/compression.cc +1 -1
- data/src/core/lib/compression/compression_internal.cc +2 -2
- data/src/core/lib/compression/stream_compression_gzip.cc +1 -1
- data/src/core/lib/debug/trace.h +2 -1
- data/src/core/lib/gpr/cpu_posix.cc +5 -3
- data/src/core/lib/gpr/sync_posix.cc +65 -4
- data/src/core/lib/gprpp/atomic.h +75 -5
- data/src/core/lib/gprpp/fork.cc +0 -2
- data/src/core/lib/gprpp/orphanable.h +3 -2
- data/src/core/lib/gprpp/ref_counted.h +9 -11
- data/src/core/lib/gprpp/thd.h +42 -7
- data/src/core/lib/gprpp/thd_posix.cc +31 -13
- data/src/core/lib/gprpp/thd_windows.cc +47 -34
- data/src/core/lib/http/httpcli.cc +3 -2
- data/src/core/lib/http/httpcli_security_connector.cc +0 -1
- data/src/core/lib/http/parser.cc +2 -1
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/buffer_list.h +1 -1
- data/src/core/lib/iomgr/endpoint.cc +2 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/error.cc +9 -9
- data/src/core/lib/iomgr/error.h +4 -3
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +6 -0
- data/src/core/lib/iomgr/ev_epollex_linux.cc +14 -9
- data/src/core/lib/iomgr/ev_poll_posix.cc +7 -481
- data/src/core/lib/iomgr/ev_posix.cc +7 -3
- data/src/core/lib/iomgr/ev_posix.h +8 -0
- data/src/core/lib/iomgr/executor.cc +13 -0
- data/src/core/lib/iomgr/executor.h +2 -1
- data/src/core/lib/iomgr/internal_errqueue.cc +2 -4
- data/src/core/lib/iomgr/iomgr.cc +5 -0
- data/src/core/lib/iomgr/iomgr.h +7 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +9 -2
- data/src/core/lib/iomgr/iomgr_internal.cc +6 -0
- data/src/core/lib/iomgr/iomgr_internal.h +9 -1
- data/src/core/lib/iomgr/iomgr_posix.cc +10 -2
- data/src/core/lib/iomgr/iomgr_windows.cc +10 -2
- data/src/core/lib/iomgr/port.h +19 -0
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -4
- data/src/core/lib/iomgr/tcp_custom.cc +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +158 -54
- data/src/core/lib/iomgr/tcp_windows.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -19
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +10 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +3 -6
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +129 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.h +62 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +7 -2
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +28 -17
- data/src/core/lib/security/security_connector/ssl_utils.cc +134 -0
- data/src/core/lib/security/security_connector/ssl_utils.h +32 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +426 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +122 -0
- data/src/core/lib/security/transport/auth_filters.h +2 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +35 -39
- data/src/core/lib/security/transport/secure_endpoint.cc +2 -2
- data/src/core/lib/security/transport/security_handshaker.cc +4 -3
- data/src/core/lib/slice/percent_encoding.cc +3 -3
- data/src/core/lib/slice/percent_encoding.h +3 -3
- data/src/core/lib/slice/slice.cc +27 -30
- data/src/core/lib/slice/slice_hash_table.h +2 -2
- data/src/core/lib/slice/slice_intern.cc +1 -1
- data/src/core/lib/slice/slice_internal.h +14 -3
- data/src/core/lib/slice/slice_weak_hash_table.h +4 -4
- data/src/core/lib/surface/byte_buffer_reader.cc +17 -0
- data/src/core/lib/surface/call.cc +8 -3
- data/src/core/lib/surface/completion_queue.cc +134 -148
- data/src/core/lib/surface/init.cc +78 -30
- data/src/core/lib/surface/init.h +1 -0
- data/src/core/lib/surface/lame_client.cc +4 -6
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/metadata.cc +66 -33
- data/src/core/lib/transport/metadata_batch.cc +1 -1
- data/src/core/lib/transport/metadata_batch.h +1 -1
- data/src/core/lib/transport/timeout_encoding.cc +1 -1
- data/src/core/lib/transport/timeout_encoding.h +1 -1
- data/src/core/lib/transport/transport.h +4 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +4 -3
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +1 -5
- data/src/core/tsi/ssl_transport_security.h +24 -4
- data/src/ruby/bin/math_pb.rb +18 -16
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +13 -10
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +18 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +3 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +58 -56
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -0
- data/third_party/cares/cares/ares.h +12 -0
- data/third_party/cares/cares/ares_create_query.c +5 -1
- data/third_party/cares/cares/ares_data.c +74 -73
- data/third_party/cares/cares/ares_destroy.c +6 -1
- data/third_party/cares/cares/ares_gethostbyaddr.c +5 -5
- data/third_party/cares/cares/ares_gethostbyname.c +15 -4
- data/third_party/cares/cares/ares_getnameinfo.c +11 -0
- data/third_party/cares/cares/ares_init.c +274 -173
- data/third_party/cares/cares/ares_library_init.c +21 -3
- data/third_party/cares/cares/ares_options.c +6 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +7 -6
- data/third_party/cares/cares/ares_parse_ptr_reply.c +4 -2
- data/third_party/cares/cares/ares_platform.c +7 -0
- data/third_party/cares/cares/ares_private.h +19 -11
- data/third_party/cares/cares/ares_process.c +27 -2
- data/third_party/cares/cares/ares_rules.h +1 -1
- data/third_party/cares/cares/ares_search.c +7 -0
- data/third_party/cares/cares/ares_send.c +6 -0
- data/third_party/cares/cares/ares_strsplit.c +174 -0
- data/third_party/cares/cares/ares_strsplit.h +43 -0
- data/third_party/cares/cares/ares_version.h +4 -4
- data/third_party/cares/cares/config-win32.h +1 -1
- data/third_party/cares/cares/inet_ntop.c +2 -3
- data/third_party/cares/config_darwin/ares_config.h +3 -0
- data/third_party/cares/config_freebsd/ares_config.h +3 -0
- data/third_party/cares/config_linux/ares_config.h +3 -0
- data/third_party/cares/config_openbsd/ares_config.h +3 -0
- metadata +39 -37
- data/src/core/ext/filters/client_channel/request_routing.cc +0 -946
- data/src/core/ext/filters/client_channel/request_routing.h +0 -181
- data/src/core/lib/gprpp/atomic_with_atm.h +0 -57
- data/src/core/lib/gprpp/atomic_with_std.h +0 -35
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +0 -107
- data/src/core/lib/iomgr/wakeup_fd_cv.h +0 -69
@@ -19,6 +19,7 @@
|
|
19
19
|
|
20
20
|
#include <grpc/support/port_platform.h>
|
21
21
|
|
22
|
+
#include "src/core/ext/filters/client_channel/resolver.h"
|
22
23
|
#include "src/core/lib/channel/channel_args.h"
|
23
24
|
#include "src/core/lib/gprpp/ref_counted.h"
|
24
25
|
#include "src/core/lib/iomgr/error.h"
|
@@ -44,20 +45,22 @@ class FakeResolverResponseGenerator
|
|
44
45
|
FakeResolverResponseGenerator() {}
|
45
46
|
|
46
47
|
// Instructs the fake resolver associated with the response generator
|
47
|
-
// instance to trigger a new resolution with the specified
|
48
|
-
|
48
|
+
// instance to trigger a new resolution with the specified result. If the
|
49
|
+
// resolver is not available yet, delays response setting until it is. This
|
50
|
+
// can be called at most once before the resolver is available.
|
51
|
+
void SetResponse(Resolver::Result result);
|
49
52
|
|
50
53
|
// Sets the re-resolution response, which is returned by the fake resolver
|
51
54
|
// when re-resolution is requested (via \a RequestReresolutionLocked()).
|
52
55
|
// The new re-resolution response replaces any previous re-resolution
|
53
56
|
// response that may have been set by a previous call.
|
54
|
-
|
55
|
-
// resolver will not return anything when \a RequestReresolutionLocked()
|
56
|
-
// is called.
|
57
|
-
void SetReresolutionResponse(grpc_channel_args* response);
|
57
|
+
void SetReresolutionResponse(Resolver::Result result);
|
58
58
|
|
59
|
-
//
|
60
|
-
//
|
59
|
+
// Unsets the re-resolution response. After this, the fake resolver will
|
60
|
+
// not return anything when \a RequestReresolutionLocked() is called.
|
61
|
+
void UnsetReresolutionResponse();
|
62
|
+
|
63
|
+
// Tells the resolver to return a transient failure.
|
61
64
|
void SetFailure();
|
62
65
|
|
63
66
|
// Same as SetFailure(), but instead of returning the error
|
@@ -79,6 +82,8 @@ class FakeResolverResponseGenerator
|
|
79
82
|
static void SetFailureLocked(void* arg, grpc_error* error);
|
80
83
|
|
81
84
|
FakeResolver* resolver_ = nullptr; // Do not own.
|
85
|
+
Resolver::Result result_;
|
86
|
+
bool has_result_ = false;
|
82
87
|
};
|
83
88
|
|
84
89
|
} // namespace grpc_core
|
@@ -44,35 +44,21 @@ namespace {
|
|
44
44
|
|
45
45
|
class SockaddrResolver : public Resolver {
|
46
46
|
public:
|
47
|
-
|
48
|
-
SockaddrResolver(
|
49
|
-
UniquePtr<ServerAddressList> addresses);
|
47
|
+
SockaddrResolver(ServerAddressList addresses, ResolverArgs args);
|
48
|
+
~SockaddrResolver() override;
|
50
49
|
|
51
|
-
void
|
52
|
-
grpc_closure* on_complete) override;
|
50
|
+
void StartLocked() override;
|
53
51
|
|
54
|
-
void ShutdownLocked() override
|
52
|
+
void ShutdownLocked() override {}
|
55
53
|
|
56
54
|
private:
|
57
|
-
|
58
|
-
|
59
|
-
void MaybeFinishNextLocked();
|
60
|
-
|
61
|
-
/// the addresses that we've "resolved"
|
62
|
-
UniquePtr<ServerAddressList> addresses_;
|
63
|
-
/// channel args
|
64
|
-
grpc_channel_args* channel_args_ = nullptr;
|
65
|
-
/// have we published?
|
66
|
-
bool published_ = false;
|
67
|
-
/// pending next completion, or NULL
|
68
|
-
grpc_closure* next_completion_ = nullptr;
|
69
|
-
/// target result address for next completion
|
70
|
-
grpc_channel_args** target_result_ = nullptr;
|
55
|
+
ServerAddressList addresses_;
|
56
|
+
const grpc_channel_args* channel_args_ = nullptr;
|
71
57
|
};
|
72
58
|
|
73
|
-
SockaddrResolver::SockaddrResolver(
|
74
|
-
|
75
|
-
: Resolver(args.combiner),
|
59
|
+
SockaddrResolver::SockaddrResolver(ServerAddressList addresses,
|
60
|
+
ResolverArgs args)
|
61
|
+
: Resolver(args.combiner, std::move(args.result_handler)),
|
76
62
|
addresses_(std::move(addresses)),
|
77
63
|
channel_args_(grpc_channel_args_copy(args.args)) {}
|
78
64
|
|
@@ -80,31 +66,13 @@ SockaddrResolver::~SockaddrResolver() {
|
|
80
66
|
grpc_channel_args_destroy(channel_args_);
|
81
67
|
}
|
82
68
|
|
83
|
-
void SockaddrResolver::
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
void SockaddrResolver::ShutdownLocked() {
|
92
|
-
if (next_completion_ != nullptr) {
|
93
|
-
*target_result_ = nullptr;
|
94
|
-
GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
95
|
-
"Resolver Shutdown"));
|
96
|
-
next_completion_ = nullptr;
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
void SockaddrResolver::MaybeFinishNextLocked() {
|
101
|
-
if (next_completion_ != nullptr && !published_) {
|
102
|
-
published_ = true;
|
103
|
-
grpc_arg arg = CreateServerAddressListChannelArg(addresses_.get());
|
104
|
-
*target_result_ = grpc_channel_args_copy_and_add(channel_args_, &arg, 1);
|
105
|
-
GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_NONE);
|
106
|
-
next_completion_ = nullptr;
|
107
|
-
}
|
69
|
+
void SockaddrResolver::StartLocked() {
|
70
|
+
Result result;
|
71
|
+
result.addresses = std::move(addresses_);
|
72
|
+
// TODO(roth): Use std::move() once channel args is converted to C++.
|
73
|
+
result.args = channel_args_;
|
74
|
+
channel_args_ = nullptr;
|
75
|
+
result_handler()->ReturnResult(std::move(result));
|
108
76
|
}
|
109
77
|
|
110
78
|
//
|
@@ -114,12 +82,12 @@ void SockaddrResolver::MaybeFinishNextLocked() {
|
|
114
82
|
void DoNothing(void* ignored) {}
|
115
83
|
|
116
84
|
OrphanablePtr<Resolver> CreateSockaddrResolver(
|
117
|
-
|
85
|
+
ResolverArgs args,
|
118
86
|
bool parse(const grpc_uri* uri, grpc_resolved_address* dst)) {
|
119
87
|
if (0 != strcmp(args.uri->authority, "")) {
|
120
88
|
gpr_log(GPR_ERROR, "authority-based URIs not supported by the %s scheme",
|
121
89
|
args.uri->scheme);
|
122
|
-
return
|
90
|
+
return nullptr;
|
123
91
|
}
|
124
92
|
// Construct addresses.
|
125
93
|
grpc_slice path_slice =
|
@@ -127,7 +95,7 @@ OrphanablePtr<Resolver> CreateSockaddrResolver(
|
|
127
95
|
grpc_slice_buffer path_parts;
|
128
96
|
grpc_slice_buffer_init(&path_parts);
|
129
97
|
grpc_slice_split(path_slice, ",", &path_parts);
|
130
|
-
|
98
|
+
ServerAddressList addresses;
|
131
99
|
bool errors_found = false;
|
132
100
|
for (size_t i = 0; i < path_parts.count; i++) {
|
133
101
|
grpc_uri ith_uri = *args.uri;
|
@@ -135,10 +103,10 @@ OrphanablePtr<Resolver> CreateSockaddrResolver(
|
|
135
103
|
ith_uri.path = part_str.get();
|
136
104
|
grpc_resolved_address addr;
|
137
105
|
if (!parse(&ith_uri, &addr)) {
|
138
|
-
errors_found = true;
|
106
|
+
errors_found = true;
|
139
107
|
break;
|
140
108
|
}
|
141
|
-
addresses
|
109
|
+
addresses.emplace_back(addr, nullptr /* args */);
|
142
110
|
}
|
143
111
|
grpc_slice_buffer_destroy_internal(&path_parts);
|
144
112
|
grpc_slice_unref_internal(path_slice);
|
@@ -147,14 +115,13 @@ OrphanablePtr<Resolver> CreateSockaddrResolver(
|
|
147
115
|
}
|
148
116
|
// Instantiate resolver.
|
149
117
|
return OrphanablePtr<Resolver>(
|
150
|
-
New<SockaddrResolver>(
|
118
|
+
New<SockaddrResolver>(std::move(addresses), std::move(args)));
|
151
119
|
}
|
152
120
|
|
153
121
|
class IPv4ResolverFactory : public ResolverFactory {
|
154
122
|
public:
|
155
|
-
OrphanablePtr<Resolver> CreateResolver(
|
156
|
-
|
157
|
-
return CreateSockaddrResolver(args, grpc_parse_ipv4);
|
123
|
+
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
|
124
|
+
return CreateSockaddrResolver(std::move(args), grpc_parse_ipv4);
|
158
125
|
}
|
159
126
|
|
160
127
|
const char* scheme() const override { return "ipv4"; }
|
@@ -162,9 +129,8 @@ class IPv4ResolverFactory : public ResolverFactory {
|
|
162
129
|
|
163
130
|
class IPv6ResolverFactory : public ResolverFactory {
|
164
131
|
public:
|
165
|
-
OrphanablePtr<Resolver> CreateResolver(
|
166
|
-
|
167
|
-
return CreateSockaddrResolver(args, grpc_parse_ipv6);
|
132
|
+
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
|
133
|
+
return CreateSockaddrResolver(std::move(args), grpc_parse_ipv6);
|
168
134
|
}
|
169
135
|
|
170
136
|
const char* scheme() const override { return "ipv6"; }
|
@@ -173,9 +139,8 @@ class IPv6ResolverFactory : public ResolverFactory {
|
|
173
139
|
#ifdef GRPC_HAVE_UNIX_SOCKET
|
174
140
|
class UnixResolverFactory : public ResolverFactory {
|
175
141
|
public:
|
176
|
-
OrphanablePtr<Resolver> CreateResolver(
|
177
|
-
|
178
|
-
return CreateSockaddrResolver(args, grpc_parse_unix);
|
142
|
+
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
|
143
|
+
return CreateSockaddrResolver(std::move(args), grpc_parse_unix);
|
179
144
|
}
|
180
145
|
|
181
146
|
UniquePtr<char> GetDefaultAuthority(grpc_uri* uri) const override {
|
@@ -41,12 +41,14 @@ struct ResolverArgs {
|
|
41
41
|
grpc_pollset_set* pollset_set = nullptr;
|
42
42
|
/// The combiner under which all resolver calls will be run.
|
43
43
|
grpc_combiner* combiner = nullptr;
|
44
|
+
/// The result handler to be used by the resolver.
|
45
|
+
UniquePtr<Resolver::ResultHandler> result_handler;
|
44
46
|
};
|
45
47
|
|
46
48
|
class ResolverFactory {
|
47
49
|
public:
|
48
50
|
/// Returns a new resolver instance.
|
49
|
-
virtual OrphanablePtr<Resolver> CreateResolver(
|
51
|
+
virtual OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const
|
50
52
|
GRPC_ABSTRACT;
|
51
53
|
|
52
54
|
/// Returns a string representing the default authority to use for this
|
@@ -134,7 +134,8 @@ ResolverFactory* ResolverRegistry::LookupResolverFactory(const char* scheme) {
|
|
134
134
|
|
135
135
|
OrphanablePtr<Resolver> ResolverRegistry::CreateResolver(
|
136
136
|
const char* target, const grpc_channel_args* args,
|
137
|
-
grpc_pollset_set* pollset_set, grpc_combiner* combiner
|
137
|
+
grpc_pollset_set* pollset_set, grpc_combiner* combiner,
|
138
|
+
UniquePtr<Resolver::ResultHandler> result_handler) {
|
138
139
|
GPR_ASSERT(g_state != nullptr);
|
139
140
|
grpc_uri* uri = nullptr;
|
140
141
|
char* canonical_target = nullptr;
|
@@ -145,8 +146,10 @@ OrphanablePtr<Resolver> ResolverRegistry::CreateResolver(
|
|
145
146
|
resolver_args.args = args;
|
146
147
|
resolver_args.pollset_set = pollset_set;
|
147
148
|
resolver_args.combiner = combiner;
|
149
|
+
resolver_args.result_handler = std::move(result_handler);
|
148
150
|
OrphanablePtr<Resolver> resolver =
|
149
|
-
factory == nullptr ? nullptr
|
151
|
+
factory == nullptr ? nullptr
|
152
|
+
: factory->CreateResolver(std::move(resolver_args));
|
150
153
|
grpc_uri_destroy(uri);
|
151
154
|
gpr_free(canonical_target);
|
152
155
|
return resolver;
|
@@ -62,10 +62,11 @@ class ResolverRegistry {
|
|
62
62
|
/// \a args are the channel args to be included in resolver results.
|
63
63
|
/// \a pollset_set is used to drive I/O in the name resolution process.
|
64
64
|
/// \a combiner is the combiner under which all resolver calls will be run.
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
/// \a result_handler is used to return results from the resolver.
|
66
|
+
static OrphanablePtr<Resolver> CreateResolver(
|
67
|
+
const char* target, const grpc_channel_args* args,
|
68
|
+
grpc_pollset_set* pollset_set, grpc_combiner* combiner,
|
69
|
+
UniquePtr<Resolver::ResultHandler> result_handler);
|
69
70
|
|
70
71
|
/// Returns the default authority to pass from a client for \a target.
|
71
72
|
static UniquePtr<char> GetDefaultAuthority(const char* target);
|
@@ -31,6 +31,7 @@
|
|
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
33
|
#include "src/core/ext/filters/client_channel/server_address.h"
|
34
|
+
#include "src/core/lib/channel/channel_args.h"
|
34
35
|
#include "src/core/lib/channel/status_util.h"
|
35
36
|
#include "src/core/lib/gpr/string.h"
|
36
37
|
#include "src/core/lib/gprpp/memory.h"
|
@@ -43,42 +44,64 @@ namespace grpc_core {
|
|
43
44
|
namespace internal {
|
44
45
|
|
45
46
|
ProcessedResolverResult::ProcessedResolverResult(
|
46
|
-
|
47
|
-
|
47
|
+
Resolver::Result* resolver_result, bool parse_retry)
|
48
|
+
: service_config_(resolver_result->service_config) {
|
49
|
+
// If resolver did not return a service config, use the default
|
50
|
+
// specified via the client API.
|
51
|
+
if (service_config_ == nullptr) {
|
52
|
+
const char* service_config_json = grpc_channel_arg_get_string(
|
53
|
+
grpc_channel_args_find(resolver_result->args, GRPC_ARG_SERVICE_CONFIG));
|
54
|
+
if (service_config_json != nullptr) {
|
55
|
+
service_config_ = ServiceConfig::Create(service_config_json);
|
56
|
+
}
|
57
|
+
} else {
|
58
|
+
// Add the service config JSON to channel args so that it's
|
59
|
+
// accessible in the subchannel.
|
60
|
+
// TODO(roth): Consider whether there's a better way to pass the
|
61
|
+
// service config down into the subchannel stack, such as maybe via
|
62
|
+
// call context or metadata. This would avoid the problem of having
|
63
|
+
// to recreate all subchannels whenever the service config changes.
|
64
|
+
// It would also avoid the need to pass in the resolver result in
|
65
|
+
// mutable form, both here and in
|
66
|
+
// ResolvingLoadBalancingPolicy::ProcessResolverResultCallback().
|
67
|
+
grpc_arg arg = grpc_channel_arg_string_create(
|
68
|
+
const_cast<char*>(GRPC_ARG_SERVICE_CONFIG),
|
69
|
+
const_cast<char*>(service_config_->service_config_json()));
|
70
|
+
grpc_channel_args* new_args =
|
71
|
+
grpc_channel_args_copy_and_add(resolver_result->args, &arg, 1);
|
72
|
+
grpc_channel_args_destroy(resolver_result->args);
|
73
|
+
resolver_result->args = new_args;
|
74
|
+
}
|
75
|
+
// Process service config.
|
76
|
+
ProcessServiceConfig(*resolver_result, parse_retry);
|
48
77
|
// If no LB config was found above, just find the LB policy name then.
|
49
|
-
if (lb_policy_name_ == nullptr) ProcessLbPolicyName(resolver_result);
|
78
|
+
if (lb_policy_name_ == nullptr) ProcessLbPolicyName(*resolver_result);
|
50
79
|
}
|
51
80
|
|
52
81
|
void ProcessedResolverResult::ProcessServiceConfig(
|
53
|
-
const
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if (
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
service_config_->ParseGlobalParams(ParseServiceConfig, this);
|
70
|
-
grpc_uri_destroy(uri);
|
71
|
-
} else {
|
72
|
-
service_config_->ParseGlobalParams(ParseServiceConfig, this);
|
73
|
-
}
|
74
|
-
method_params_table_ = service_config_->CreateMethodConfigTable(
|
75
|
-
ClientChannelMethodParams::CreateFromJson);
|
76
|
-
}
|
82
|
+
const Resolver::Result& resolver_result, bool parse_retry) {
|
83
|
+
if (service_config_ == nullptr) return;
|
84
|
+
service_config_json_ =
|
85
|
+
UniquePtr<char>(gpr_strdup(service_config_->service_config_json()));
|
86
|
+
if (parse_retry) {
|
87
|
+
const grpc_arg* channel_arg =
|
88
|
+
grpc_channel_args_find(resolver_result.args, GRPC_ARG_SERVER_URI);
|
89
|
+
const char* server_uri = grpc_channel_arg_get_string(channel_arg);
|
90
|
+
GPR_ASSERT(server_uri != nullptr);
|
91
|
+
grpc_uri* uri = grpc_uri_parse(server_uri, true);
|
92
|
+
GPR_ASSERT(uri->path[0] != '\0');
|
93
|
+
server_name_ = uri->path[0] == '/' ? uri->path + 1 : uri->path;
|
94
|
+
service_config_->ParseGlobalParams(ParseServiceConfig, this);
|
95
|
+
grpc_uri_destroy(uri);
|
96
|
+
} else {
|
97
|
+
service_config_->ParseGlobalParams(ParseServiceConfig, this);
|
77
98
|
}
|
99
|
+
method_params_table_ = service_config_->CreateMethodConfigTable(
|
100
|
+
ClientChannelMethodParams::CreateFromJson);
|
78
101
|
}
|
79
102
|
|
80
103
|
void ProcessedResolverResult::ProcessLbPolicyName(
|
81
|
-
const
|
104
|
+
const Resolver::Result& resolver_result) {
|
82
105
|
// Prefer the LB policy name found in the service config. Note that this is
|
83
106
|
// checking the deprecated loadBalancingPolicy field, rather than the new
|
84
107
|
// loadBalancingConfig field.
|
@@ -96,32 +119,28 @@ void ProcessedResolverResult::ProcessLbPolicyName(
|
|
96
119
|
// Otherwise, find the LB policy name set by the client API.
|
97
120
|
if (lb_policy_name_ == nullptr) {
|
98
121
|
const grpc_arg* channel_arg =
|
99
|
-
grpc_channel_args_find(
|
122
|
+
grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME);
|
100
123
|
lb_policy_name_.reset(gpr_strdup(grpc_channel_arg_get_string(channel_arg)));
|
101
124
|
}
|
102
125
|
// Special case: If at least one balancer address is present, we use
|
103
126
|
// the grpclb policy, regardless of what the resolver has returned.
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
if (address.IsBalancer()) {
|
111
|
-
found_balancer_address = true;
|
112
|
-
break;
|
113
|
-
}
|
127
|
+
bool found_balancer_address = false;
|
128
|
+
for (size_t i = 0; i < resolver_result.addresses.size(); ++i) {
|
129
|
+
const ServerAddress& address = resolver_result.addresses[i];
|
130
|
+
if (address.IsBalancer()) {
|
131
|
+
found_balancer_address = true;
|
132
|
+
break;
|
114
133
|
}
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
lb_policy_name_.reset(gpr_strdup("grpclb"));
|
134
|
+
}
|
135
|
+
if (found_balancer_address) {
|
136
|
+
if (lb_policy_name_ != nullptr &&
|
137
|
+
strcmp(lb_policy_name_.get(), "grpclb") != 0) {
|
138
|
+
gpr_log(GPR_INFO,
|
139
|
+
"resolver requested LB policy %s but provided at least one "
|
140
|
+
"balancer address -- forcing use of grpclb LB policy",
|
141
|
+
lb_policy_name_.get());
|
124
142
|
}
|
143
|
+
lb_policy_name_.reset(gpr_strdup("grpclb"));
|
125
144
|
}
|
126
145
|
// Use pick_first if nothing was specified and we didn't select grpclb
|
127
146
|
// above.
|
@@ -148,7 +167,8 @@ void ProcessedResolverResult::ParseLbConfigFromServiceConfig(
|
|
148
167
|
LoadBalancingPolicy::ParseLoadBalancingConfig(field);
|
149
168
|
if (policy != nullptr) {
|
150
169
|
lb_policy_name_.reset(gpr_strdup(policy->key));
|
151
|
-
lb_policy_config_ =
|
170
|
+
lb_policy_config_ =
|
171
|
+
MakeRefCounted<LoadBalancingPolicy::Config>(policy, service_config_);
|
152
172
|
}
|
153
173
|
}
|
154
174
|
|
@@ -21,14 +21,16 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
+
#include "src/core/ext/filters/client_channel/lb_policy.h"
|
25
|
+
#include "src/core/ext/filters/client_channel/resolver.h"
|
24
26
|
#include "src/core/ext/filters/client_channel/retry_throttle.h"
|
27
|
+
#include "src/core/ext/filters/client_channel/service_config.h"
|
25
28
|
#include "src/core/lib/channel/status_util.h"
|
26
29
|
#include "src/core/lib/gprpp/ref_counted.h"
|
27
30
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
28
31
|
#include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis
|
29
32
|
#include "src/core/lib/json/json.h"
|
30
33
|
#include "src/core/lib/slice/slice_hash_table.h"
|
31
|
-
#include "src/core/lib/transport/service_config.h"
|
32
34
|
|
33
35
|
namespace grpc_core {
|
34
36
|
namespace internal {
|
@@ -46,8 +48,7 @@ class ProcessedResolverResult {
|
|
46
48
|
// Processes the resolver result and populates the relative members
|
47
49
|
// for later consumption. Tries to parse retry parameters only if parse_retry
|
48
50
|
// is true.
|
49
|
-
ProcessedResolverResult(
|
50
|
-
bool parse_retry);
|
51
|
+
ProcessedResolverResult(Resolver::Result* resolver_result, bool parse_retry);
|
51
52
|
|
52
53
|
// Getters. Any managed object's ownership is transferred.
|
53
54
|
UniquePtr<char> service_config_json() {
|
@@ -60,16 +61,18 @@ class ProcessedResolverResult {
|
|
60
61
|
return std::move(method_params_table_);
|
61
62
|
}
|
62
63
|
UniquePtr<char> lb_policy_name() { return std::move(lb_policy_name_); }
|
63
|
-
|
64
|
+
RefCountedPtr<LoadBalancingPolicy::Config> lb_policy_config() {
|
65
|
+
return std::move(lb_policy_config_);
|
66
|
+
}
|
64
67
|
|
65
68
|
private:
|
66
69
|
// Finds the service config; extracts LB config and (maybe) retry throttle
|
67
70
|
// params from it.
|
68
|
-
void ProcessServiceConfig(const
|
71
|
+
void ProcessServiceConfig(const Resolver::Result& resolver_result,
|
69
72
|
bool parse_retry);
|
70
73
|
|
71
74
|
// Finds the LB policy name (when no LB config was found).
|
72
|
-
void ProcessLbPolicyName(const
|
75
|
+
void ProcessLbPolicyName(const Resolver::Result& resolver_result);
|
73
76
|
|
74
77
|
// Parses the service config. Intended to be used by
|
75
78
|
// ServiceConfig::ParseGlobalParams.
|
@@ -82,10 +85,10 @@ class ProcessedResolverResult {
|
|
82
85
|
|
83
86
|
// Service config.
|
84
87
|
UniquePtr<char> service_config_json_;
|
85
|
-
|
88
|
+
RefCountedPtr<ServiceConfig> service_config_;
|
86
89
|
// LB policy.
|
87
|
-
grpc_json* lb_policy_config_ = nullptr;
|
88
90
|
UniquePtr<char> lb_policy_name_;
|
91
|
+
RefCountedPtr<LoadBalancingPolicy::Config> lb_policy_config_;
|
89
92
|
// Retry throttle data.
|
90
93
|
char* server_name_ = nullptr;
|
91
94
|
RefCountedPtr<ServerRetryThrottleData> retry_throttle_data_;
|