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
@@ -0,0 +1,43 @@
|
|
1
|
+
#ifndef HEADER_CARES_STRSPLIT_H
|
2
|
+
#define HEADER_CARES_STRSPLIT_H
|
3
|
+
|
4
|
+
/* Copyright (C) 2018 by John Schember <john@nachtimwald.com>
|
5
|
+
*
|
6
|
+
* Permission to use, copy, modify, and distribute this
|
7
|
+
* software and its documentation for any purpose and without
|
8
|
+
* fee is hereby granted, provided that the above copyright
|
9
|
+
* notice appear in all copies and that both that copyright
|
10
|
+
* notice and this permission notice appear in supporting
|
11
|
+
* documentation, and that the name of M.I.T. not be used in
|
12
|
+
* advertising or publicity pertaining to distribution of the
|
13
|
+
* software without specific, written prior permission.
|
14
|
+
* M.I.T. makes no representations about the suitability of
|
15
|
+
* this software for any purpose. It is provided "as is"
|
16
|
+
* without express or implied warranty.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "ares_setup.h"
|
20
|
+
|
21
|
+
/* Split a string on delem skipping empty elements.
|
22
|
+
*
|
23
|
+
* param in String to split.
|
24
|
+
* param delims String of characters to treat as a delimitor.
|
25
|
+
* Each character in the string is a delimitor so
|
26
|
+
* there can be multiple delimitors to split on.
|
27
|
+
* E.g. ", " will split on all comma's and spaces.
|
28
|
+
* param make_set Have the list be a Set where there are no
|
29
|
+
* duplicate entries. 1 for true, 0 or false.
|
30
|
+
* param num_elm Return parameter of the number of elements
|
31
|
+
* in the result array.
|
32
|
+
*
|
33
|
+
* returns an allocated array of allocated string elements.
|
34
|
+
*
|
35
|
+
*/
|
36
|
+
char **ares_strsplit(const char *in, const char *delms, int make_set, size_t *num_elm);
|
37
|
+
|
38
|
+
/* Frees the result returned from ares_strsplit(). */
|
39
|
+
void ares_strsplit_free(char **elms, size_t num_elm);
|
40
|
+
|
41
|
+
|
42
|
+
#endif /* HEADER_CARES_STRSPLIT_H */
|
43
|
+
|
@@ -3,15 +3,15 @@
|
|
3
3
|
#define ARES__VERSION_H
|
4
4
|
|
5
5
|
/* This is the global package copyright */
|
6
|
-
#define ARES_COPYRIGHT "2004 -
|
6
|
+
#define ARES_COPYRIGHT "2004 - 2017 Daniel Stenberg, <daniel@haxx.se>."
|
7
7
|
|
8
8
|
#define ARES_VERSION_MAJOR 1
|
9
|
-
#define ARES_VERSION_MINOR
|
10
|
-
#define ARES_VERSION_PATCH
|
9
|
+
#define ARES_VERSION_MINOR 14
|
10
|
+
#define ARES_VERSION_PATCH 0
|
11
11
|
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
|
12
12
|
(ARES_VERSION_MINOR<<8)|\
|
13
13
|
(ARES_VERSION_PATCH))
|
14
|
-
#define ARES_VERSION_STR "1.
|
14
|
+
#define ARES_VERSION_STR "1.14.0"
|
15
15
|
|
16
16
|
#if (ARES_VERSION >= 0x010700)
|
17
17
|
# define CARES_HAVE_ARES_LIBRARY_INIT 1
|
@@ -245,7 +245,7 @@
|
|
245
245
|
# define _CRT_NONSTDC_NO_DEPRECATE 1
|
246
246
|
#endif
|
247
247
|
|
248
|
-
/* Set the Target to Vista. However, any symbols required above Win2000
|
248
|
+
/* Set the Target to Vista. However, any symbols required above Win2000
|
249
249
|
* should be loaded via LoadLibrary() */
|
250
250
|
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
|
251
251
|
# define VS2008_MIN_TARGET 0x0600
|
@@ -54,7 +54,7 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size);
|
|
54
54
|
* On Windows we store the error in the thread errno, not
|
55
55
|
* in the winsock error code. This is to avoid loosing the
|
56
56
|
* actual last winsock error. So use macro ERRNO to fetch the
|
57
|
-
* errno this
|
57
|
+
* errno this function sets when returning NULL, not SOCKERRNO.
|
58
58
|
* author:
|
59
59
|
* Paul Vixie, 1996.
|
60
60
|
*/
|
@@ -180,8 +180,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
|
|
180
180
|
tp += sprintf(tp, "%x", words[i]);
|
181
181
|
}
|
182
182
|
/* Was it a trailing run of 0x00's? */
|
183
|
-
if (best.base != -1 && (best.base + best.len) ==
|
184
|
-
(NS_IN6ADDRSZ / NS_INT16SZ))
|
183
|
+
if (best.base != -1 && (best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ))
|
185
184
|
*tp++ = ':';
|
186
185
|
*tp++ = '\0';
|
187
186
|
|
@@ -333,6 +333,9 @@
|
|
333
333
|
/* Define to 1 if you have the ws2tcpip.h header file. */
|
334
334
|
/* #undef HAVE_WS2TCPIP_H */
|
335
335
|
|
336
|
+
/* Define if __system_property_get exists. */
|
337
|
+
/* #undef HAVE___SYSTEM_PROPERTY_GET */
|
338
|
+
|
336
339
|
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
337
340
|
/* #undef NEED_MALLOC_H */
|
338
341
|
|
@@ -338,6 +338,9 @@
|
|
338
338
|
/* Define to 1 if you have the ws2tcpip.h header file. */
|
339
339
|
/* #undef HAVE_WS2TCPIP_H */
|
340
340
|
|
341
|
+
/* Define if __system_property_get exists. */
|
342
|
+
/* #undef HAVE___SYSTEM_PROPERTY_GET */
|
343
|
+
|
341
344
|
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
342
345
|
#define LT_OBJDIR ".libs/"
|
343
346
|
|
@@ -338,6 +338,9 @@
|
|
338
338
|
/* Define to 1 if you have the ws2tcpip.h header file. */
|
339
339
|
/* #undef HAVE_WS2TCPIP_H */
|
340
340
|
|
341
|
+
/* Define if __system_property_get exists. */
|
342
|
+
/* #undef HAVE___SYSTEM_PROPERTY_GET */
|
343
|
+
|
341
344
|
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
342
345
|
/* #undef NEED_MALLOC_H */
|
343
346
|
|
@@ -338,6 +338,9 @@
|
|
338
338
|
/* Define to 1 if you have the ws2tcpip.h header file. */
|
339
339
|
/* #undef HAVE_WS2TCPIP_H */
|
340
340
|
|
341
|
+
/* Define if __system_property_get exists. */
|
342
|
+
/* #undef HAVE___SYSTEM_PROPERTY_GET */
|
343
|
+
|
341
344
|
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
342
345
|
#define LT_OBJDIR ".libs/"
|
343
346
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.20.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gRPC Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: src/ruby/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: googleapis-common-protos-types
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -327,8 +327,6 @@ files:
|
|
327
327
|
- src/core/ext/filters/client_channel/proxy_mapper.h
|
328
328
|
- src/core/ext/filters/client_channel/proxy_mapper_registry.cc
|
329
329
|
- src/core/ext/filters/client_channel/proxy_mapper_registry.h
|
330
|
-
- src/core/ext/filters/client_channel/request_routing.cc
|
331
|
-
- src/core/ext/filters/client_channel/request_routing.h
|
332
330
|
- src/core/ext/filters/client_channel/resolver.cc
|
333
331
|
- src/core/ext/filters/client_channel/resolver.h
|
334
332
|
- src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
|
@@ -350,10 +348,14 @@ files:
|
|
350
348
|
- src/core/ext/filters/client_channel/resolver_registry.h
|
351
349
|
- src/core/ext/filters/client_channel/resolver_result_parsing.cc
|
352
350
|
- src/core/ext/filters/client_channel/resolver_result_parsing.h
|
351
|
+
- src/core/ext/filters/client_channel/resolving_lb_policy.cc
|
352
|
+
- src/core/ext/filters/client_channel/resolving_lb_policy.h
|
353
353
|
- src/core/ext/filters/client_channel/retry_throttle.cc
|
354
354
|
- src/core/ext/filters/client_channel/retry_throttle.h
|
355
355
|
- src/core/ext/filters/client_channel/server_address.cc
|
356
356
|
- src/core/ext/filters/client_channel/server_address.h
|
357
|
+
- src/core/ext/filters/client_channel/service_config.cc
|
358
|
+
- src/core/ext/filters/client_channel/service_config.h
|
357
359
|
- src/core/ext/filters/client_channel/subchannel.cc
|
358
360
|
- src/core/ext/filters/client_channel/subchannel.h
|
359
361
|
- src/core/ext/filters/client_channel/subchannel_pool_interface.cc
|
@@ -534,8 +536,6 @@ files:
|
|
534
536
|
- src/core/lib/gpr/wrap_memcpy.cc
|
535
537
|
- src/core/lib/gprpp/abstract.h
|
536
538
|
- src/core/lib/gprpp/atomic.h
|
537
|
-
- src/core/lib/gprpp/atomic_with_atm.h
|
538
|
-
- src/core/lib/gprpp/atomic_with_std.h
|
539
539
|
- src/core/lib/gprpp/debug_location.h
|
540
540
|
- src/core/lib/gprpp/fork.cc
|
541
541
|
- src/core/lib/gprpp/fork.h
|
@@ -701,8 +701,6 @@ files:
|
|
701
701
|
- src/core/lib/iomgr/unix_sockets_posix.cc
|
702
702
|
- src/core/lib/iomgr/unix_sockets_posix.h
|
703
703
|
- src/core/lib/iomgr/unix_sockets_posix_noop.cc
|
704
|
-
- src/core/lib/iomgr/wakeup_fd_cv.cc
|
705
|
-
- src/core/lib/iomgr/wakeup_fd_cv.h
|
706
704
|
- src/core/lib/iomgr/wakeup_fd_eventfd.cc
|
707
705
|
- src/core/lib/iomgr/wakeup_fd_nospecial.cc
|
708
706
|
- src/core/lib/iomgr/wakeup_fd_pipe.cc
|
@@ -761,6 +759,8 @@ files:
|
|
761
759
|
- src/core/lib/security/credentials/ssl/ssl_credentials.h
|
762
760
|
- src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc
|
763
761
|
- src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h
|
762
|
+
- src/core/lib/security/credentials/tls/spiffe_credentials.cc
|
763
|
+
- src/core/lib/security/credentials/tls/spiffe_credentials.h
|
764
764
|
- src/core/lib/security/security_connector/alts/alts_security_connector.cc
|
765
765
|
- src/core/lib/security/security_connector/alts/alts_security_connector.h
|
766
766
|
- src/core/lib/security/security_connector/fake/fake_security_connector.cc
|
@@ -777,6 +777,8 @@ files:
|
|
777
777
|
- src/core/lib/security/security_connector/ssl/ssl_security_connector.h
|
778
778
|
- src/core/lib/security/security_connector/ssl_utils.cc
|
779
779
|
- src/core/lib/security/security_connector/ssl_utils.h
|
780
|
+
- src/core/lib/security/security_connector/tls/spiffe_security_connector.cc
|
781
|
+
- src/core/lib/security/security_connector/tls/spiffe_security_connector.h
|
780
782
|
- src/core/lib/security/transport/auth_filters.h
|
781
783
|
- src/core/lib/security/transport/client_auth_filter.cc
|
782
784
|
- src/core/lib/security/transport/secure_endpoint.cc
|
@@ -850,8 +852,6 @@ files:
|
|
850
852
|
- src/core/lib/transport/metadata_batch.h
|
851
853
|
- src/core/lib/transport/pid_controller.cc
|
852
854
|
- src/core/lib/transport/pid_controller.h
|
853
|
-
- src/core/lib/transport/service_config.cc
|
854
|
-
- src/core/lib/transport/service_config.h
|
855
855
|
- src/core/lib/transport/static_metadata.cc
|
856
856
|
- src/core/lib/transport/static_metadata.h
|
857
857
|
- src/core/lib/transport/status_conversion.cc
|
@@ -1524,6 +1524,8 @@ files:
|
|
1524
1524
|
- third_party/cares/cares/ares_strdup.c
|
1525
1525
|
- third_party/cares/cares/ares_strdup.h
|
1526
1526
|
- third_party/cares/cares/ares_strerror.c
|
1527
|
+
- third_party/cares/cares/ares_strsplit.c
|
1528
|
+
- third_party/cares/cares/ares_strsplit.h
|
1527
1529
|
- third_party/cares/cares/ares_timeout.c
|
1528
1530
|
- third_party/cares/cares/ares_version.c
|
1529
1531
|
- third_party/cares/cares/ares_version.h
|
@@ -1589,47 +1591,47 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1589
1591
|
version: 2.0.0
|
1590
1592
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1591
1593
|
requirements:
|
1592
|
-
- - "
|
1594
|
+
- - ">"
|
1593
1595
|
- !ruby/object:Gem::Version
|
1594
|
-
version:
|
1596
|
+
version: 1.3.1
|
1595
1597
|
requirements: []
|
1596
|
-
rubygems_version: 3.0.
|
1598
|
+
rubygems_version: 3.0.3
|
1597
1599
|
signing_key:
|
1598
1600
|
specification_version: 4
|
1599
1601
|
summary: GRPC system in Ruby
|
1600
1602
|
test_files:
|
1601
|
-
- src/ruby/spec/
|
1602
|
-
- src/ruby/spec/
|
1603
|
+
- src/ruby/spec/google_rpc_status_utils_spec.rb
|
1604
|
+
- src/ruby/spec/server_spec.rb
|
1605
|
+
- src/ruby/spec/server_credentials_spec.rb
|
1606
|
+
- src/ruby/spec/channel_spec.rb
|
1607
|
+
- src/ruby/spec/channel_credentials_spec.rb
|
1603
1608
|
- src/ruby/spec/client_auth_spec.rb
|
1604
|
-
- src/ruby/spec/
|
1605
|
-
- src/ruby/spec/pb/duplicate/codegen_spec.rb
|
1606
|
-
- src/ruby/spec/pb/health/checker_spec.rb
|
1607
|
-
- src/ruby/spec/pb/codegen/grpc/testing/package_options.proto
|
1608
|
-
- src/ruby/spec/pb/codegen/package_option_spec.rb
|
1609
|
+
- src/ruby/spec/error_sanity_spec.rb
|
1609
1610
|
- src/ruby/spec/spec_helper.rb
|
1610
1611
|
- src/ruby/spec/testdata/client.pem
|
1612
|
+
- src/ruby/spec/testdata/README
|
1611
1613
|
- src/ruby/spec/testdata/client.key
|
1612
1614
|
- src/ruby/spec/testdata/server1.key
|
1613
|
-
- src/ruby/spec/testdata/README
|
1614
1615
|
- src/ruby/spec/testdata/server1.pem
|
1615
1616
|
- src/ruby/spec/testdata/ca.pem
|
1616
|
-
- src/ruby/spec/
|
1617
|
+
- src/ruby/spec/support/services.rb
|
1618
|
+
- src/ruby/spec/support/helpers.rb
|
1619
|
+
- src/ruby/spec/compression_options_spec.rb
|
1620
|
+
- src/ruby/spec/generic/rpc_server_spec.rb
|
1621
|
+
- src/ruby/spec/generic/rpc_server_pool_spec.rb
|
1622
|
+
- src/ruby/spec/generic/server_interceptors_spec.rb
|
1617
1623
|
- src/ruby/spec/generic/interceptor_registry_spec.rb
|
1618
1624
|
- src/ruby/spec/generic/client_stub_spec.rb
|
1619
|
-
- src/ruby/spec/generic/
|
1620
|
-
- src/ruby/spec/generic/rpc_server_spec.rb
|
1625
|
+
- src/ruby/spec/generic/client_interceptors_spec.rb
|
1621
1626
|
- src/ruby/spec/generic/rpc_desc_spec.rb
|
1622
1627
|
- src/ruby/spec/generic/service_spec.rb
|
1623
|
-
- src/ruby/spec/generic/
|
1624
|
-
- src/ruby/spec/
|
1625
|
-
- src/ruby/spec/
|
1628
|
+
- src/ruby/spec/generic/active_call_spec.rb
|
1629
|
+
- src/ruby/spec/client_server_spec.rb
|
1630
|
+
- src/ruby/spec/channel_connection_spec.rb
|
1626
1631
|
- src/ruby/spec/call_spec.rb
|
1627
|
-
- src/ruby/spec/
|
1628
|
-
- src/ruby/spec/
|
1629
|
-
- src/ruby/spec/
|
1632
|
+
- src/ruby/spec/pb/duplicate/codegen_spec.rb
|
1633
|
+
- src/ruby/spec/pb/codegen/package_option_spec.rb
|
1634
|
+
- src/ruby/spec/pb/codegen/grpc/testing/package_options.proto
|
1635
|
+
- src/ruby/spec/pb/health/checker_spec.rb
|
1636
|
+
- src/ruby/spec/time_consts_spec.rb
|
1630
1637
|
- src/ruby/spec/call_credentials_spec.rb
|
1631
|
-
- src/ruby/spec/channel_connection_spec.rb
|
1632
|
-
- src/ruby/spec/compression_options_spec.rb
|
1633
|
-
- src/ruby/spec/server_spec.rb
|
1634
|
-
- src/ruby/spec/channel_spec.rb
|
1635
|
-
- src/ruby/spec/error_sanity_spec.rb
|
@@ -1,946 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2015 gRPC authors.
|
4
|
-
*
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
* you may not use this file except in compliance with the License.
|
7
|
-
* You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
|
19
|
-
#include <grpc/support/port_platform.h>
|
20
|
-
|
21
|
-
#include "src/core/ext/filters/client_channel/request_routing.h"
|
22
|
-
|
23
|
-
#include <inttypes.h>
|
24
|
-
#include <limits.h>
|
25
|
-
#include <stdbool.h>
|
26
|
-
#include <stdio.h>
|
27
|
-
#include <string.h>
|
28
|
-
|
29
|
-
#include <grpc/support/alloc.h>
|
30
|
-
#include <grpc/support/log.h>
|
31
|
-
#include <grpc/support/string_util.h>
|
32
|
-
#include <grpc/support/sync.h>
|
33
|
-
|
34
|
-
#include "src/core/ext/filters/client_channel/backup_poller.h"
|
35
|
-
#include "src/core/ext/filters/client_channel/global_subchannel_pool.h"
|
36
|
-
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
|
37
|
-
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
38
|
-
#include "src/core/ext/filters/client_channel/local_subchannel_pool.h"
|
39
|
-
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
|
40
|
-
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
41
|
-
#include "src/core/ext/filters/client_channel/retry_throttle.h"
|
42
|
-
#include "src/core/ext/filters/client_channel/server_address.h"
|
43
|
-
#include "src/core/ext/filters/client_channel/subchannel.h"
|
44
|
-
#include "src/core/ext/filters/deadline/deadline_filter.h"
|
45
|
-
#include "src/core/lib/backoff/backoff.h"
|
46
|
-
#include "src/core/lib/channel/channel_args.h"
|
47
|
-
#include "src/core/lib/channel/connected_channel.h"
|
48
|
-
#include "src/core/lib/channel/status_util.h"
|
49
|
-
#include "src/core/lib/gpr/string.h"
|
50
|
-
#include "src/core/lib/gprpp/inlined_vector.h"
|
51
|
-
#include "src/core/lib/gprpp/manual_constructor.h"
|
52
|
-
#include "src/core/lib/iomgr/combiner.h"
|
53
|
-
#include "src/core/lib/iomgr/iomgr.h"
|
54
|
-
#include "src/core/lib/iomgr/polling_entity.h"
|
55
|
-
#include "src/core/lib/profiling/timers.h"
|
56
|
-
#include "src/core/lib/slice/slice_internal.h"
|
57
|
-
#include "src/core/lib/slice/slice_string_helpers.h"
|
58
|
-
#include "src/core/lib/surface/channel.h"
|
59
|
-
#include "src/core/lib/transport/connectivity_state.h"
|
60
|
-
#include "src/core/lib/transport/error_utils.h"
|
61
|
-
#include "src/core/lib/transport/metadata.h"
|
62
|
-
#include "src/core/lib/transport/metadata_batch.h"
|
63
|
-
#include "src/core/lib/transport/service_config.h"
|
64
|
-
#include "src/core/lib/transport/static_metadata.h"
|
65
|
-
#include "src/core/lib/transport/status_metadata.h"
|
66
|
-
|
67
|
-
namespace grpc_core {
|
68
|
-
|
69
|
-
//
|
70
|
-
// RequestRouter::Request::ResolverResultWaiter
|
71
|
-
//
|
72
|
-
|
73
|
-
// Handles waiting for a resolver result.
|
74
|
-
// Used only for the first call on an idle channel.
|
75
|
-
class RequestRouter::Request::ResolverResultWaiter {
|
76
|
-
public:
|
77
|
-
explicit ResolverResultWaiter(Request* request)
|
78
|
-
: request_router_(request->request_router_),
|
79
|
-
request_(request),
|
80
|
-
tracer_enabled_(request_router_->tracer_->enabled()) {
|
81
|
-
if (tracer_enabled_) {
|
82
|
-
gpr_log(GPR_INFO,
|
83
|
-
"request_router=%p request=%p: deferring pick pending resolver "
|
84
|
-
"result",
|
85
|
-
request_router_, request);
|
86
|
-
}
|
87
|
-
// Add closure to be run when a resolver result is available.
|
88
|
-
GRPC_CLOSURE_INIT(&done_closure_, &DoneLocked, this,
|
89
|
-
grpc_combiner_scheduler(request_router_->combiner_));
|
90
|
-
AddToWaitingList();
|
91
|
-
// Set cancellation closure, so that we abort if the call is cancelled.
|
92
|
-
GRPC_CLOSURE_INIT(&cancel_closure_, &CancelLocked, this,
|
93
|
-
grpc_combiner_scheduler(request_router_->combiner_));
|
94
|
-
grpc_call_combiner_set_notify_on_cancel(request->call_combiner_,
|
95
|
-
&cancel_closure_);
|
96
|
-
}
|
97
|
-
|
98
|
-
private:
|
99
|
-
// Adds done_closure_ to
|
100
|
-
// request_router_->waiting_for_resolver_result_closures_.
|
101
|
-
void AddToWaitingList() {
|
102
|
-
grpc_closure_list_append(
|
103
|
-
&request_router_->waiting_for_resolver_result_closures_, &done_closure_,
|
104
|
-
GRPC_ERROR_NONE);
|
105
|
-
}
|
106
|
-
|
107
|
-
// Invoked when a resolver result is available.
|
108
|
-
static void DoneLocked(void* arg, grpc_error* error) {
|
109
|
-
ResolverResultWaiter* self = static_cast<ResolverResultWaiter*>(arg);
|
110
|
-
RequestRouter* request_router = self->request_router_;
|
111
|
-
// If CancelLocked() has already run, delete ourselves without doing
|
112
|
-
// anything. Note that the call stack may have already been destroyed,
|
113
|
-
// so it's not safe to access anything in state_.
|
114
|
-
if (GPR_UNLIKELY(self->finished_)) {
|
115
|
-
if (self->tracer_enabled_) {
|
116
|
-
gpr_log(GPR_INFO,
|
117
|
-
"request_router=%p: call cancelled before resolver result",
|
118
|
-
request_router);
|
119
|
-
}
|
120
|
-
Delete(self);
|
121
|
-
return;
|
122
|
-
}
|
123
|
-
// Otherwise, process the resolver result.
|
124
|
-
Request* request = self->request_;
|
125
|
-
if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) {
|
126
|
-
if (self->tracer_enabled_) {
|
127
|
-
gpr_log(GPR_INFO,
|
128
|
-
"request_router=%p request=%p: resolver failed to return data",
|
129
|
-
request_router, request);
|
130
|
-
}
|
131
|
-
GRPC_CLOSURE_RUN(request->on_route_done_, GRPC_ERROR_REF(error));
|
132
|
-
} else if (GPR_UNLIKELY(request_router->resolver_ == nullptr)) {
|
133
|
-
// Shutting down.
|
134
|
-
if (self->tracer_enabled_) {
|
135
|
-
gpr_log(GPR_INFO, "request_router=%p request=%p: resolver disconnected",
|
136
|
-
request_router, request);
|
137
|
-
}
|
138
|
-
GRPC_CLOSURE_RUN(request->on_route_done_,
|
139
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
|
140
|
-
} else if (GPR_UNLIKELY(request_router->lb_policy_ == nullptr)) {
|
141
|
-
// Transient resolver failure.
|
142
|
-
// If call has wait_for_ready=true, try again; otherwise, fail.
|
143
|
-
if (*request->pick_.initial_metadata_flags &
|
144
|
-
GRPC_INITIAL_METADATA_WAIT_FOR_READY) {
|
145
|
-
if (self->tracer_enabled_) {
|
146
|
-
gpr_log(GPR_INFO,
|
147
|
-
"request_router=%p request=%p: resolver returned but no LB "
|
148
|
-
"policy; wait_for_ready=true; trying again",
|
149
|
-
request_router, request);
|
150
|
-
}
|
151
|
-
// Re-add ourselves to the waiting list.
|
152
|
-
self->AddToWaitingList();
|
153
|
-
// Return early so that we don't set finished_ to true below.
|
154
|
-
return;
|
155
|
-
} else {
|
156
|
-
if (self->tracer_enabled_) {
|
157
|
-
gpr_log(GPR_INFO,
|
158
|
-
"request_router=%p request=%p: resolver returned but no LB "
|
159
|
-
"policy; wait_for_ready=false; failing",
|
160
|
-
request_router, request);
|
161
|
-
}
|
162
|
-
GRPC_CLOSURE_RUN(
|
163
|
-
request->on_route_done_,
|
164
|
-
grpc_error_set_int(
|
165
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Name resolution failure"),
|
166
|
-
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
|
167
|
-
}
|
168
|
-
} else {
|
169
|
-
if (self->tracer_enabled_) {
|
170
|
-
gpr_log(GPR_INFO,
|
171
|
-
"request_router=%p request=%p: resolver returned, doing LB "
|
172
|
-
"pick",
|
173
|
-
request_router, request);
|
174
|
-
}
|
175
|
-
request->ProcessServiceConfigAndStartLbPickLocked();
|
176
|
-
}
|
177
|
-
self->finished_ = true;
|
178
|
-
}
|
179
|
-
|
180
|
-
// Invoked when the call is cancelled.
|
181
|
-
// Note: This runs under the client_channel combiner, but will NOT be
|
182
|
-
// holding the call combiner.
|
183
|
-
static void CancelLocked(void* arg, grpc_error* error) {
|
184
|
-
ResolverResultWaiter* self = static_cast<ResolverResultWaiter*>(arg);
|
185
|
-
RequestRouter* request_router = self->request_router_;
|
186
|
-
// If DoneLocked() has already run, delete ourselves without doing anything.
|
187
|
-
if (self->finished_) {
|
188
|
-
Delete(self);
|
189
|
-
return;
|
190
|
-
}
|
191
|
-
Request* request = self->request_;
|
192
|
-
// If we are being cancelled, immediately invoke on_route_done_
|
193
|
-
// to propagate the error back to the caller.
|
194
|
-
if (error != GRPC_ERROR_NONE) {
|
195
|
-
if (self->tracer_enabled_) {
|
196
|
-
gpr_log(GPR_INFO,
|
197
|
-
"request_router=%p request=%p: cancelling call waiting for "
|
198
|
-
"name resolution",
|
199
|
-
request_router, request);
|
200
|
-
}
|
201
|
-
// Note: Although we are not in the call combiner here, we are
|
202
|
-
// basically stealing the call combiner from the pending pick, so
|
203
|
-
// it's safe to run on_route_done_ here -- we are essentially
|
204
|
-
// calling it here instead of calling it in DoneLocked().
|
205
|
-
GRPC_CLOSURE_RUN(request->on_route_done_,
|
206
|
-
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
207
|
-
"Pick cancelled", &error, 1));
|
208
|
-
}
|
209
|
-
self->finished_ = true;
|
210
|
-
}
|
211
|
-
|
212
|
-
RequestRouter* request_router_;
|
213
|
-
Request* request_;
|
214
|
-
const bool tracer_enabled_;
|
215
|
-
grpc_closure done_closure_;
|
216
|
-
grpc_closure cancel_closure_;
|
217
|
-
bool finished_ = false;
|
218
|
-
};
|
219
|
-
|
220
|
-
//
|
221
|
-
// RequestRouter::Request::AsyncPickCanceller
|
222
|
-
//
|
223
|
-
|
224
|
-
// Handles the call combiner cancellation callback for an async LB pick.
|
225
|
-
class RequestRouter::Request::AsyncPickCanceller {
|
226
|
-
public:
|
227
|
-
explicit AsyncPickCanceller(Request* request)
|
228
|
-
: request_router_(request->request_router_),
|
229
|
-
request_(request),
|
230
|
-
tracer_enabled_(request_router_->tracer_->enabled()) {
|
231
|
-
GRPC_CALL_STACK_REF(request->owning_call_, "pick_callback_cancel");
|
232
|
-
// Set cancellation closure, so that we abort if the call is cancelled.
|
233
|
-
GRPC_CLOSURE_INIT(&cancel_closure_, &CancelLocked, this,
|
234
|
-
grpc_combiner_scheduler(request_router_->combiner_));
|
235
|
-
grpc_call_combiner_set_notify_on_cancel(request->call_combiner_,
|
236
|
-
&cancel_closure_);
|
237
|
-
}
|
238
|
-
|
239
|
-
void MarkFinishedLocked() {
|
240
|
-
finished_ = true;
|
241
|
-
GRPC_CALL_STACK_UNREF(request_->owning_call_, "pick_callback_cancel");
|
242
|
-
}
|
243
|
-
|
244
|
-
private:
|
245
|
-
// Invoked when the call is cancelled.
|
246
|
-
// Note: This runs under the client_channel combiner, but will NOT be
|
247
|
-
// holding the call combiner.
|
248
|
-
static void CancelLocked(void* arg, grpc_error* error) {
|
249
|
-
AsyncPickCanceller* self = static_cast<AsyncPickCanceller*>(arg);
|
250
|
-
Request* request = self->request_;
|
251
|
-
RequestRouter* request_router = self->request_router_;
|
252
|
-
if (!self->finished_) {
|
253
|
-
// Note: request_router->lb_policy_ may have changed since we started our
|
254
|
-
// pick, in which case we will be cancelling the pick on a policy other
|
255
|
-
// than the one we started it on. However, this will just be a no-op.
|
256
|
-
if (error != GRPC_ERROR_NONE && request_router->lb_policy_ != nullptr) {
|
257
|
-
if (self->tracer_enabled_) {
|
258
|
-
gpr_log(GPR_INFO,
|
259
|
-
"request_router=%p request=%p: cancelling pick from LB "
|
260
|
-
"policy %p",
|
261
|
-
request_router, request, request_router->lb_policy_.get());
|
262
|
-
}
|
263
|
-
request_router->lb_policy_->CancelPickLocked(&request->pick_,
|
264
|
-
GRPC_ERROR_REF(error));
|
265
|
-
}
|
266
|
-
request->pick_canceller_ = nullptr;
|
267
|
-
GRPC_CALL_STACK_UNREF(request->owning_call_, "pick_callback_cancel");
|
268
|
-
}
|
269
|
-
Delete(self);
|
270
|
-
}
|
271
|
-
|
272
|
-
RequestRouter* request_router_;
|
273
|
-
Request* request_;
|
274
|
-
const bool tracer_enabled_;
|
275
|
-
grpc_closure cancel_closure_;
|
276
|
-
bool finished_ = false;
|
277
|
-
};
|
278
|
-
|
279
|
-
//
|
280
|
-
// RequestRouter::Request
|
281
|
-
//
|
282
|
-
|
283
|
-
RequestRouter::Request::Request(grpc_call_stack* owning_call,
|
284
|
-
grpc_call_combiner* call_combiner,
|
285
|
-
grpc_polling_entity* pollent,
|
286
|
-
grpc_metadata_batch* send_initial_metadata,
|
287
|
-
uint32_t* send_initial_metadata_flags,
|
288
|
-
ApplyServiceConfigCallback apply_service_config,
|
289
|
-
void* apply_service_config_user_data,
|
290
|
-
grpc_closure* on_route_done)
|
291
|
-
: owning_call_(owning_call),
|
292
|
-
call_combiner_(call_combiner),
|
293
|
-
pollent_(pollent),
|
294
|
-
apply_service_config_(apply_service_config),
|
295
|
-
apply_service_config_user_data_(apply_service_config_user_data),
|
296
|
-
on_route_done_(on_route_done) {
|
297
|
-
pick_.initial_metadata = send_initial_metadata;
|
298
|
-
pick_.initial_metadata_flags = send_initial_metadata_flags;
|
299
|
-
}
|
300
|
-
|
301
|
-
RequestRouter::Request::~Request() {
|
302
|
-
if (pick_.connected_subchannel != nullptr) {
|
303
|
-
pick_.connected_subchannel.reset();
|
304
|
-
}
|
305
|
-
for (size_t i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
|
306
|
-
if (pick_.subchannel_call_context[i].destroy != nullptr) {
|
307
|
-
pick_.subchannel_call_context[i].destroy(
|
308
|
-
pick_.subchannel_call_context[i].value);
|
309
|
-
}
|
310
|
-
}
|
311
|
-
}
|
312
|
-
|
313
|
-
// Invoked once resolver results are available.
|
314
|
-
void RequestRouter::Request::ProcessServiceConfigAndStartLbPickLocked() {
|
315
|
-
// Get service config data if needed.
|
316
|
-
if (!apply_service_config_(apply_service_config_user_data_)) return;
|
317
|
-
// Start LB pick.
|
318
|
-
StartLbPickLocked();
|
319
|
-
}
|
320
|
-
|
321
|
-
void RequestRouter::Request::MaybeAddCallToInterestedPartiesLocked() {
|
322
|
-
if (!pollent_added_to_interested_parties_) {
|
323
|
-
pollent_added_to_interested_parties_ = true;
|
324
|
-
grpc_polling_entity_add_to_pollset_set(
|
325
|
-
pollent_, request_router_->interested_parties_);
|
326
|
-
}
|
327
|
-
}
|
328
|
-
|
329
|
-
void RequestRouter::Request::MaybeRemoveCallFromInterestedPartiesLocked() {
|
330
|
-
if (pollent_added_to_interested_parties_) {
|
331
|
-
pollent_added_to_interested_parties_ = false;
|
332
|
-
grpc_polling_entity_del_from_pollset_set(
|
333
|
-
pollent_, request_router_->interested_parties_);
|
334
|
-
}
|
335
|
-
}
|
336
|
-
|
337
|
-
// Starts a pick on the LB policy.
|
338
|
-
void RequestRouter::Request::StartLbPickLocked() {
|
339
|
-
if (request_router_->tracer_->enabled()) {
|
340
|
-
gpr_log(GPR_INFO,
|
341
|
-
"request_router=%p request=%p: starting pick on lb_policy=%p",
|
342
|
-
request_router_, this, request_router_->lb_policy_.get());
|
343
|
-
}
|
344
|
-
GRPC_CLOSURE_INIT(&on_pick_done_, &LbPickDoneLocked, this,
|
345
|
-
grpc_combiner_scheduler(request_router_->combiner_));
|
346
|
-
pick_.on_complete = &on_pick_done_;
|
347
|
-
GRPC_CALL_STACK_REF(owning_call_, "pick_callback");
|
348
|
-
grpc_error* error = GRPC_ERROR_NONE;
|
349
|
-
const bool pick_done =
|
350
|
-
request_router_->lb_policy_->PickLocked(&pick_, &error);
|
351
|
-
if (pick_done) {
|
352
|
-
// Pick completed synchronously.
|
353
|
-
if (request_router_->tracer_->enabled()) {
|
354
|
-
gpr_log(GPR_INFO,
|
355
|
-
"request_router=%p request=%p: pick completed synchronously",
|
356
|
-
request_router_, this);
|
357
|
-
}
|
358
|
-
GRPC_CLOSURE_RUN(on_route_done_, error);
|
359
|
-
GRPC_CALL_STACK_UNREF(owning_call_, "pick_callback");
|
360
|
-
} else {
|
361
|
-
// Pick will be returned asynchronously.
|
362
|
-
// Add the request's polling entity to the request_router's
|
363
|
-
// interested_parties, so that the I/O of the LB policy can be done
|
364
|
-
// under it. It will be removed in LbPickDoneLocked().
|
365
|
-
MaybeAddCallToInterestedPartiesLocked();
|
366
|
-
// Request notification on call cancellation.
|
367
|
-
// We allocate a separate object to track cancellation, since the
|
368
|
-
// cancellation closure might still be pending when we need to reuse
|
369
|
-
// the memory in which this Request object is stored for a subsequent
|
370
|
-
// retry attempt.
|
371
|
-
pick_canceller_ = New<AsyncPickCanceller>(this);
|
372
|
-
}
|
373
|
-
}
|
374
|
-
|
375
|
-
// Callback invoked by LoadBalancingPolicy::PickLocked() for async picks.
|
376
|
-
// Unrefs the LB policy and invokes on_route_done_.
|
377
|
-
void RequestRouter::Request::LbPickDoneLocked(void* arg, grpc_error* error) {
|
378
|
-
Request* self = static_cast<Request*>(arg);
|
379
|
-
RequestRouter* request_router = self->request_router_;
|
380
|
-
if (request_router->tracer_->enabled()) {
|
381
|
-
gpr_log(GPR_INFO,
|
382
|
-
"request_router=%p request=%p: pick completed asynchronously",
|
383
|
-
request_router, self);
|
384
|
-
}
|
385
|
-
self->MaybeRemoveCallFromInterestedPartiesLocked();
|
386
|
-
if (self->pick_canceller_ != nullptr) {
|
387
|
-
self->pick_canceller_->MarkFinishedLocked();
|
388
|
-
}
|
389
|
-
GRPC_CLOSURE_RUN(self->on_route_done_, GRPC_ERROR_REF(error));
|
390
|
-
GRPC_CALL_STACK_UNREF(self->owning_call_, "pick_callback");
|
391
|
-
}
|
392
|
-
|
393
|
-
//
|
394
|
-
// RequestRouter::LbConnectivityWatcher
|
395
|
-
//
|
396
|
-
|
397
|
-
class RequestRouter::LbConnectivityWatcher {
|
398
|
-
public:
|
399
|
-
LbConnectivityWatcher(RequestRouter* request_router,
|
400
|
-
grpc_connectivity_state state,
|
401
|
-
LoadBalancingPolicy* lb_policy,
|
402
|
-
grpc_channel_stack* owning_stack,
|
403
|
-
grpc_combiner* combiner)
|
404
|
-
: request_router_(request_router),
|
405
|
-
state_(state),
|
406
|
-
lb_policy_(lb_policy),
|
407
|
-
owning_stack_(owning_stack) {
|
408
|
-
GRPC_CHANNEL_STACK_REF(owning_stack_, "LbConnectivityWatcher");
|
409
|
-
GRPC_CLOSURE_INIT(&on_changed_, &OnLbPolicyStateChangedLocked, this,
|
410
|
-
grpc_combiner_scheduler(combiner));
|
411
|
-
lb_policy_->NotifyOnStateChangeLocked(&state_, &on_changed_);
|
412
|
-
}
|
413
|
-
|
414
|
-
~LbConnectivityWatcher() {
|
415
|
-
GRPC_CHANNEL_STACK_UNREF(owning_stack_, "LbConnectivityWatcher");
|
416
|
-
}
|
417
|
-
|
418
|
-
private:
|
419
|
-
static void OnLbPolicyStateChangedLocked(void* arg, grpc_error* error) {
|
420
|
-
LbConnectivityWatcher* self = static_cast<LbConnectivityWatcher*>(arg);
|
421
|
-
// If the notification is not for the current policy, we're stale,
|
422
|
-
// so delete ourselves.
|
423
|
-
if (self->lb_policy_ != self->request_router_->lb_policy_.get()) {
|
424
|
-
Delete(self);
|
425
|
-
return;
|
426
|
-
}
|
427
|
-
// Otherwise, process notification.
|
428
|
-
if (self->request_router_->tracer_->enabled()) {
|
429
|
-
gpr_log(GPR_INFO, "request_router=%p: lb_policy=%p state changed to %s",
|
430
|
-
self->request_router_, self->lb_policy_,
|
431
|
-
grpc_connectivity_state_name(self->state_));
|
432
|
-
}
|
433
|
-
self->request_router_->SetConnectivityStateLocked(
|
434
|
-
self->state_, GRPC_ERROR_REF(error), "lb_changed");
|
435
|
-
// If shutting down, terminate watch.
|
436
|
-
if (self->state_ == GRPC_CHANNEL_SHUTDOWN) {
|
437
|
-
Delete(self);
|
438
|
-
return;
|
439
|
-
}
|
440
|
-
// Renew watch.
|
441
|
-
self->lb_policy_->NotifyOnStateChangeLocked(&self->state_,
|
442
|
-
&self->on_changed_);
|
443
|
-
}
|
444
|
-
|
445
|
-
RequestRouter* request_router_;
|
446
|
-
grpc_connectivity_state state_;
|
447
|
-
// LB policy address. No ref held, so not safe to dereference unless
|
448
|
-
// it happens to match request_router->lb_policy_.
|
449
|
-
LoadBalancingPolicy* lb_policy_;
|
450
|
-
grpc_channel_stack* owning_stack_;
|
451
|
-
grpc_closure on_changed_;
|
452
|
-
};
|
453
|
-
|
454
|
-
//
|
455
|
-
// RequestRounter::ReresolutionRequestHandler
|
456
|
-
//
|
457
|
-
|
458
|
-
class RequestRouter::ReresolutionRequestHandler {
|
459
|
-
public:
|
460
|
-
ReresolutionRequestHandler(RequestRouter* request_router,
|
461
|
-
LoadBalancingPolicy* lb_policy,
|
462
|
-
grpc_channel_stack* owning_stack,
|
463
|
-
grpc_combiner* combiner)
|
464
|
-
: request_router_(request_router),
|
465
|
-
lb_policy_(lb_policy),
|
466
|
-
owning_stack_(owning_stack) {
|
467
|
-
GRPC_CHANNEL_STACK_REF(owning_stack_, "ReresolutionRequestHandler");
|
468
|
-
GRPC_CLOSURE_INIT(&closure_, &OnRequestReresolutionLocked, this,
|
469
|
-
grpc_combiner_scheduler(combiner));
|
470
|
-
lb_policy_->SetReresolutionClosureLocked(&closure_);
|
471
|
-
}
|
472
|
-
|
473
|
-
private:
|
474
|
-
static void OnRequestReresolutionLocked(void* arg, grpc_error* error) {
|
475
|
-
ReresolutionRequestHandler* self =
|
476
|
-
static_cast<ReresolutionRequestHandler*>(arg);
|
477
|
-
RequestRouter* request_router = self->request_router_;
|
478
|
-
// If this invocation is for a stale LB policy, treat it as an LB shutdown
|
479
|
-
// signal.
|
480
|
-
if (self->lb_policy_ != request_router->lb_policy_.get() ||
|
481
|
-
error != GRPC_ERROR_NONE || request_router->resolver_ == nullptr) {
|
482
|
-
GRPC_CHANNEL_STACK_UNREF(request_router->owning_stack_,
|
483
|
-
"ReresolutionRequestHandler");
|
484
|
-
Delete(self);
|
485
|
-
return;
|
486
|
-
}
|
487
|
-
if (request_router->tracer_->enabled()) {
|
488
|
-
gpr_log(GPR_INFO, "request_router=%p: started name re-resolving",
|
489
|
-
request_router);
|
490
|
-
}
|
491
|
-
request_router->resolver_->RequestReresolutionLocked();
|
492
|
-
// Give back the closure to the LB policy.
|
493
|
-
self->lb_policy_->SetReresolutionClosureLocked(&self->closure_);
|
494
|
-
}
|
495
|
-
|
496
|
-
RequestRouter* request_router_;
|
497
|
-
// LB policy address. No ref held, so not safe to dereference unless
|
498
|
-
// it happens to match request_router->lb_policy_.
|
499
|
-
LoadBalancingPolicy* lb_policy_;
|
500
|
-
grpc_channel_stack* owning_stack_;
|
501
|
-
grpc_closure closure_;
|
502
|
-
};
|
503
|
-
|
504
|
-
//
|
505
|
-
// RequestRouter
|
506
|
-
//
|
507
|
-
|
508
|
-
RequestRouter::RequestRouter(
|
509
|
-
grpc_channel_stack* owning_stack, grpc_combiner* combiner,
|
510
|
-
grpc_client_channel_factory* client_channel_factory,
|
511
|
-
grpc_pollset_set* interested_parties, TraceFlag* tracer,
|
512
|
-
ProcessResolverResultCallback process_resolver_result,
|
513
|
-
void* process_resolver_result_user_data, const char* target_uri,
|
514
|
-
const grpc_channel_args* args, grpc_error** error)
|
515
|
-
: owning_stack_(owning_stack),
|
516
|
-
combiner_(combiner),
|
517
|
-
client_channel_factory_(client_channel_factory),
|
518
|
-
interested_parties_(interested_parties),
|
519
|
-
tracer_(tracer),
|
520
|
-
process_resolver_result_(process_resolver_result),
|
521
|
-
process_resolver_result_user_data_(process_resolver_result_user_data) {
|
522
|
-
// Get subchannel pool.
|
523
|
-
const grpc_arg* arg =
|
524
|
-
grpc_channel_args_find(args, GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL);
|
525
|
-
if (grpc_channel_arg_get_bool(arg, false)) {
|
526
|
-
subchannel_pool_ = MakeRefCounted<LocalSubchannelPool>();
|
527
|
-
} else {
|
528
|
-
subchannel_pool_ = GlobalSubchannelPool::instance();
|
529
|
-
}
|
530
|
-
GRPC_CLOSURE_INIT(&on_resolver_result_changed_,
|
531
|
-
&RequestRouter::OnResolverResultChangedLocked, this,
|
532
|
-
grpc_combiner_scheduler(combiner));
|
533
|
-
grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE,
|
534
|
-
"request_router");
|
535
|
-
grpc_channel_args* new_args = nullptr;
|
536
|
-
if (process_resolver_result == nullptr) {
|
537
|
-
grpc_arg arg = grpc_channel_arg_integer_create(
|
538
|
-
const_cast<char*>(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION), 0);
|
539
|
-
new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
|
540
|
-
}
|
541
|
-
resolver_ = ResolverRegistry::CreateResolver(
|
542
|
-
target_uri, (new_args == nullptr ? args : new_args), interested_parties_,
|
543
|
-
combiner_);
|
544
|
-
grpc_channel_args_destroy(new_args);
|
545
|
-
if (resolver_ == nullptr) {
|
546
|
-
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed");
|
547
|
-
}
|
548
|
-
}
|
549
|
-
|
550
|
-
RequestRouter::~RequestRouter() {
|
551
|
-
if (resolver_ != nullptr) {
|
552
|
-
// The only way we can get here is if we never started resolving,
|
553
|
-
// because we take a ref to the channel stack when we start
|
554
|
-
// resolving and do not release it until the resolver callback is
|
555
|
-
// invoked after the resolver shuts down.
|
556
|
-
resolver_.reset();
|
557
|
-
}
|
558
|
-
if (lb_policy_ != nullptr) {
|
559
|
-
grpc_pollset_set_del_pollset_set(lb_policy_->interested_parties(),
|
560
|
-
interested_parties_);
|
561
|
-
lb_policy_.reset();
|
562
|
-
}
|
563
|
-
if (client_channel_factory_ != nullptr) {
|
564
|
-
grpc_client_channel_factory_unref(client_channel_factory_);
|
565
|
-
}
|
566
|
-
grpc_connectivity_state_destroy(&state_tracker_);
|
567
|
-
}
|
568
|
-
|
569
|
-
namespace {
|
570
|
-
|
571
|
-
const char* GetChannelConnectivityStateChangeString(
|
572
|
-
grpc_connectivity_state state) {
|
573
|
-
switch (state) {
|
574
|
-
case GRPC_CHANNEL_IDLE:
|
575
|
-
return "Channel state change to IDLE";
|
576
|
-
case GRPC_CHANNEL_CONNECTING:
|
577
|
-
return "Channel state change to CONNECTING";
|
578
|
-
case GRPC_CHANNEL_READY:
|
579
|
-
return "Channel state change to READY";
|
580
|
-
case GRPC_CHANNEL_TRANSIENT_FAILURE:
|
581
|
-
return "Channel state change to TRANSIENT_FAILURE";
|
582
|
-
case GRPC_CHANNEL_SHUTDOWN:
|
583
|
-
return "Channel state change to SHUTDOWN";
|
584
|
-
}
|
585
|
-
GPR_UNREACHABLE_CODE(return "UNKNOWN");
|
586
|
-
}
|
587
|
-
|
588
|
-
} // namespace
|
589
|
-
|
590
|
-
void RequestRouter::SetConnectivityStateLocked(grpc_connectivity_state state,
|
591
|
-
grpc_error* error,
|
592
|
-
const char* reason) {
|
593
|
-
if (lb_policy_ != nullptr) {
|
594
|
-
if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
|
595
|
-
// Cancel picks with wait_for_ready=false.
|
596
|
-
lb_policy_->CancelMatchingPicksLocked(
|
597
|
-
/* mask= */ GRPC_INITIAL_METADATA_WAIT_FOR_READY,
|
598
|
-
/* check= */ 0, GRPC_ERROR_REF(error));
|
599
|
-
} else if (state == GRPC_CHANNEL_SHUTDOWN) {
|
600
|
-
// Cancel all picks.
|
601
|
-
lb_policy_->CancelMatchingPicksLocked(/* mask= */ 0, /* check= */ 0,
|
602
|
-
GRPC_ERROR_REF(error));
|
603
|
-
}
|
604
|
-
}
|
605
|
-
if (tracer_->enabled()) {
|
606
|
-
gpr_log(GPR_INFO, "request_router=%p: setting connectivity state to %s",
|
607
|
-
this, grpc_connectivity_state_name(state));
|
608
|
-
}
|
609
|
-
if (channelz_node_ != nullptr) {
|
610
|
-
channelz_node_->AddTraceEvent(
|
611
|
-
channelz::ChannelTrace::Severity::Info,
|
612
|
-
grpc_slice_from_static_string(
|
613
|
-
GetChannelConnectivityStateChangeString(state)));
|
614
|
-
}
|
615
|
-
grpc_connectivity_state_set(&state_tracker_, state, error, reason);
|
616
|
-
}
|
617
|
-
|
618
|
-
void RequestRouter::StartResolvingLocked() {
|
619
|
-
if (tracer_->enabled()) {
|
620
|
-
gpr_log(GPR_INFO, "request_router=%p: starting name resolution", this);
|
621
|
-
}
|
622
|
-
GPR_ASSERT(!started_resolving_);
|
623
|
-
started_resolving_ = true;
|
624
|
-
GRPC_CHANNEL_STACK_REF(owning_stack_, "resolver");
|
625
|
-
resolver_->NextLocked(&resolver_result_, &on_resolver_result_changed_);
|
626
|
-
}
|
627
|
-
|
628
|
-
// Invoked from the resolver NextLocked() callback when the resolver
|
629
|
-
// is shutting down.
|
630
|
-
void RequestRouter::OnResolverShutdownLocked(grpc_error* error) {
|
631
|
-
if (tracer_->enabled()) {
|
632
|
-
gpr_log(GPR_INFO, "request_router=%p: shutting down", this);
|
633
|
-
}
|
634
|
-
if (lb_policy_ != nullptr) {
|
635
|
-
if (tracer_->enabled()) {
|
636
|
-
gpr_log(GPR_INFO, "request_router=%p: shutting down lb_policy=%p", this,
|
637
|
-
lb_policy_.get());
|
638
|
-
}
|
639
|
-
grpc_pollset_set_del_pollset_set(lb_policy_->interested_parties(),
|
640
|
-
interested_parties_);
|
641
|
-
lb_policy_.reset();
|
642
|
-
}
|
643
|
-
if (resolver_ != nullptr) {
|
644
|
-
// This should never happen; it can only be triggered by a resolver
|
645
|
-
// implementation spotaneously deciding to report shutdown without
|
646
|
-
// being orphaned. This code is included just to be defensive.
|
647
|
-
if (tracer_->enabled()) {
|
648
|
-
gpr_log(GPR_INFO,
|
649
|
-
"request_router=%p: spontaneous shutdown from resolver %p", this,
|
650
|
-
resolver_.get());
|
651
|
-
}
|
652
|
-
resolver_.reset();
|
653
|
-
SetConnectivityStateLocked(GRPC_CHANNEL_SHUTDOWN,
|
654
|
-
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
655
|
-
"Resolver spontaneous shutdown", &error, 1),
|
656
|
-
"resolver_spontaneous_shutdown");
|
657
|
-
}
|
658
|
-
grpc_closure_list_fail_all(&waiting_for_resolver_result_closures_,
|
659
|
-
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
660
|
-
"Channel disconnected", &error, 1));
|
661
|
-
GRPC_CLOSURE_LIST_SCHED(&waiting_for_resolver_result_closures_);
|
662
|
-
GRPC_CHANNEL_STACK_UNREF(owning_stack_, "resolver");
|
663
|
-
grpc_channel_args_destroy(resolver_result_);
|
664
|
-
resolver_result_ = nullptr;
|
665
|
-
GRPC_ERROR_UNREF(error);
|
666
|
-
}
|
667
|
-
|
668
|
-
// Creates a new LB policy, replacing any previous one.
|
669
|
-
// If the new policy is created successfully, sets *connectivity_state and
|
670
|
-
// *connectivity_error to its initial connectivity state; otherwise,
|
671
|
-
// leaves them unchanged.
|
672
|
-
void RequestRouter::CreateNewLbPolicyLocked(
|
673
|
-
const char* lb_policy_name, grpc_json* lb_config,
|
674
|
-
grpc_connectivity_state* connectivity_state,
|
675
|
-
grpc_error** connectivity_error, TraceStringVector* trace_strings) {
|
676
|
-
LoadBalancingPolicy::Args lb_policy_args;
|
677
|
-
lb_policy_args.combiner = combiner_;
|
678
|
-
lb_policy_args.client_channel_factory = client_channel_factory_;
|
679
|
-
lb_policy_args.subchannel_pool = subchannel_pool_;
|
680
|
-
lb_policy_args.args = resolver_result_;
|
681
|
-
lb_policy_args.lb_config = lb_config;
|
682
|
-
OrphanablePtr<LoadBalancingPolicy> new_lb_policy =
|
683
|
-
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(lb_policy_name,
|
684
|
-
lb_policy_args);
|
685
|
-
if (GPR_UNLIKELY(new_lb_policy == nullptr)) {
|
686
|
-
gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name);
|
687
|
-
if (channelz_node_ != nullptr) {
|
688
|
-
char* str;
|
689
|
-
gpr_asprintf(&str, "Could not create LB policy \'%s\'", lb_policy_name);
|
690
|
-
trace_strings->push_back(str);
|
691
|
-
}
|
692
|
-
} else {
|
693
|
-
if (tracer_->enabled()) {
|
694
|
-
gpr_log(GPR_INFO, "request_router=%p: created new LB policy \"%s\" (%p)",
|
695
|
-
this, lb_policy_name, new_lb_policy.get());
|
696
|
-
}
|
697
|
-
if (channelz_node_ != nullptr) {
|
698
|
-
char* str;
|
699
|
-
gpr_asprintf(&str, "Created new LB policy \'%s\'", lb_policy_name);
|
700
|
-
trace_strings->push_back(str);
|
701
|
-
}
|
702
|
-
// Swap out the LB policy and update the fds in interested_parties_.
|
703
|
-
if (lb_policy_ != nullptr) {
|
704
|
-
if (tracer_->enabled()) {
|
705
|
-
gpr_log(GPR_INFO, "request_router=%p: shutting down lb_policy=%p", this,
|
706
|
-
lb_policy_.get());
|
707
|
-
}
|
708
|
-
grpc_pollset_set_del_pollset_set(lb_policy_->interested_parties(),
|
709
|
-
interested_parties_);
|
710
|
-
lb_policy_->HandOffPendingPicksLocked(new_lb_policy.get());
|
711
|
-
}
|
712
|
-
lb_policy_ = std::move(new_lb_policy);
|
713
|
-
grpc_pollset_set_add_pollset_set(lb_policy_->interested_parties(),
|
714
|
-
interested_parties_);
|
715
|
-
// Create re-resolution request handler for the new LB policy. It
|
716
|
-
// will delete itself when no longer needed.
|
717
|
-
New<ReresolutionRequestHandler>(this, lb_policy_.get(), owning_stack_,
|
718
|
-
combiner_);
|
719
|
-
// Get the new LB policy's initial connectivity state and start a
|
720
|
-
// connectivity watch.
|
721
|
-
GRPC_ERROR_UNREF(*connectivity_error);
|
722
|
-
*connectivity_state =
|
723
|
-
lb_policy_->CheckConnectivityLocked(connectivity_error);
|
724
|
-
if (exit_idle_when_lb_policy_arrives_) {
|
725
|
-
lb_policy_->ExitIdleLocked();
|
726
|
-
exit_idle_when_lb_policy_arrives_ = false;
|
727
|
-
}
|
728
|
-
// Create new watcher. It will delete itself when done.
|
729
|
-
New<LbConnectivityWatcher>(this, *connectivity_state, lb_policy_.get(),
|
730
|
-
owning_stack_, combiner_);
|
731
|
-
}
|
732
|
-
}
|
733
|
-
|
734
|
-
void RequestRouter::MaybeAddTraceMessagesForAddressChangesLocked(
|
735
|
-
TraceStringVector* trace_strings) {
|
736
|
-
const ServerAddressList* addresses =
|
737
|
-
FindServerAddressListChannelArg(resolver_result_);
|
738
|
-
const bool resolution_contains_addresses =
|
739
|
-
addresses != nullptr && addresses->size() > 0;
|
740
|
-
if (!resolution_contains_addresses &&
|
741
|
-
previous_resolution_contained_addresses_) {
|
742
|
-
trace_strings->push_back(gpr_strdup("Address list became empty"));
|
743
|
-
} else if (resolution_contains_addresses &&
|
744
|
-
!previous_resolution_contained_addresses_) {
|
745
|
-
trace_strings->push_back(gpr_strdup("Address list became non-empty"));
|
746
|
-
}
|
747
|
-
previous_resolution_contained_addresses_ = resolution_contains_addresses;
|
748
|
-
}
|
749
|
-
|
750
|
-
void RequestRouter::ConcatenateAndAddChannelTraceLocked(
|
751
|
-
TraceStringVector* trace_strings) const {
|
752
|
-
if (!trace_strings->empty()) {
|
753
|
-
gpr_strvec v;
|
754
|
-
gpr_strvec_init(&v);
|
755
|
-
gpr_strvec_add(&v, gpr_strdup("Resolution event: "));
|
756
|
-
bool is_first = 1;
|
757
|
-
for (size_t i = 0; i < trace_strings->size(); ++i) {
|
758
|
-
if (!is_first) gpr_strvec_add(&v, gpr_strdup(", "));
|
759
|
-
is_first = false;
|
760
|
-
gpr_strvec_add(&v, (*trace_strings)[i]);
|
761
|
-
}
|
762
|
-
char* flat;
|
763
|
-
size_t flat_len = 0;
|
764
|
-
flat = gpr_strvec_flatten(&v, &flat_len);
|
765
|
-
channelz_node_->AddTraceEvent(channelz::ChannelTrace::Severity::Info,
|
766
|
-
grpc_slice_new(flat, flat_len, gpr_free));
|
767
|
-
gpr_strvec_destroy(&v);
|
768
|
-
}
|
769
|
-
}
|
770
|
-
|
771
|
-
// Callback invoked when a resolver result is available.
|
772
|
-
void RequestRouter::OnResolverResultChangedLocked(void* arg,
|
773
|
-
grpc_error* error) {
|
774
|
-
RequestRouter* self = static_cast<RequestRouter*>(arg);
|
775
|
-
if (self->tracer_->enabled()) {
|
776
|
-
const char* disposition =
|
777
|
-
self->resolver_result_ != nullptr
|
778
|
-
? ""
|
779
|
-
: (error == GRPC_ERROR_NONE ? " (transient error)"
|
780
|
-
: " (resolver shutdown)");
|
781
|
-
gpr_log(GPR_INFO,
|
782
|
-
"request_router=%p: got resolver result: resolver_result=%p "
|
783
|
-
"error=%s%s",
|
784
|
-
self, self->resolver_result_, grpc_error_string(error),
|
785
|
-
disposition);
|
786
|
-
}
|
787
|
-
// Handle shutdown.
|
788
|
-
if (error != GRPC_ERROR_NONE || self->resolver_ == nullptr) {
|
789
|
-
self->OnResolverShutdownLocked(GRPC_ERROR_REF(error));
|
790
|
-
return;
|
791
|
-
}
|
792
|
-
// Data used to set the channel's connectivity state.
|
793
|
-
bool set_connectivity_state = true;
|
794
|
-
// We only want to trace the address resolution in the follow cases:
|
795
|
-
// (a) Address resolution resulted in service config change.
|
796
|
-
// (b) Address resolution that causes number of backends to go from
|
797
|
-
// zero to non-zero.
|
798
|
-
// (c) Address resolution that causes number of backends to go from
|
799
|
-
// non-zero to zero.
|
800
|
-
// (d) Address resolution that causes a new LB policy to be created.
|
801
|
-
//
|
802
|
-
// we track a list of strings to eventually be concatenated and traced.
|
803
|
-
TraceStringVector trace_strings;
|
804
|
-
grpc_connectivity_state connectivity_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
|
805
|
-
grpc_error* connectivity_error =
|
806
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No load balancing policy");
|
807
|
-
// resolver_result_ will be null in the case of a transient
|
808
|
-
// resolution error. In that case, we don't have any new result to
|
809
|
-
// process, which means that we keep using the previous result (if any).
|
810
|
-
if (self->resolver_result_ == nullptr) {
|
811
|
-
if (self->tracer_->enabled()) {
|
812
|
-
gpr_log(GPR_INFO, "request_router=%p: resolver transient failure", self);
|
813
|
-
}
|
814
|
-
// Don't override connectivity state if we already have an LB policy.
|
815
|
-
if (self->lb_policy_ != nullptr) set_connectivity_state = false;
|
816
|
-
} else {
|
817
|
-
// Parse the resolver result.
|
818
|
-
const char* lb_policy_name = nullptr;
|
819
|
-
grpc_json* lb_policy_config = nullptr;
|
820
|
-
const bool service_config_changed = self->process_resolver_result_(
|
821
|
-
self->process_resolver_result_user_data_, *self->resolver_result_,
|
822
|
-
&lb_policy_name, &lb_policy_config);
|
823
|
-
GPR_ASSERT(lb_policy_name != nullptr);
|
824
|
-
// Check to see if we're already using the right LB policy.
|
825
|
-
const bool lb_policy_name_changed =
|
826
|
-
self->lb_policy_ == nullptr ||
|
827
|
-
strcmp(self->lb_policy_->name(), lb_policy_name) != 0;
|
828
|
-
if (self->lb_policy_ != nullptr && !lb_policy_name_changed) {
|
829
|
-
// Continue using the same LB policy. Update with new addresses.
|
830
|
-
if (self->tracer_->enabled()) {
|
831
|
-
gpr_log(GPR_INFO,
|
832
|
-
"request_router=%p: updating existing LB policy \"%s\" (%p)",
|
833
|
-
self, lb_policy_name, self->lb_policy_.get());
|
834
|
-
}
|
835
|
-
self->lb_policy_->UpdateLocked(*self->resolver_result_, lb_policy_config);
|
836
|
-
// No need to set the channel's connectivity state; the existing
|
837
|
-
// watch on the LB policy will take care of that.
|
838
|
-
set_connectivity_state = false;
|
839
|
-
} else {
|
840
|
-
// Instantiate new LB policy.
|
841
|
-
self->CreateNewLbPolicyLocked(lb_policy_name, lb_policy_config,
|
842
|
-
&connectivity_state, &connectivity_error,
|
843
|
-
&trace_strings);
|
844
|
-
}
|
845
|
-
// Add channel trace event.
|
846
|
-
if (self->channelz_node_ != nullptr) {
|
847
|
-
if (service_config_changed) {
|
848
|
-
// TODO(ncteisen): might be worth somehow including a snippet of the
|
849
|
-
// config in the trace, at the risk of bloating the trace logs.
|
850
|
-
trace_strings.push_back(gpr_strdup("Service config changed"));
|
851
|
-
}
|
852
|
-
self->MaybeAddTraceMessagesForAddressChangesLocked(&trace_strings);
|
853
|
-
self->ConcatenateAndAddChannelTraceLocked(&trace_strings);
|
854
|
-
}
|
855
|
-
// Clean up.
|
856
|
-
grpc_channel_args_destroy(self->resolver_result_);
|
857
|
-
self->resolver_result_ = nullptr;
|
858
|
-
}
|
859
|
-
// Set the channel's connectivity state if needed.
|
860
|
-
if (set_connectivity_state) {
|
861
|
-
self->SetConnectivityStateLocked(connectivity_state, connectivity_error,
|
862
|
-
"resolver_result");
|
863
|
-
} else {
|
864
|
-
GRPC_ERROR_UNREF(connectivity_error);
|
865
|
-
}
|
866
|
-
// Invoke closures that were waiting for results and renew the watch.
|
867
|
-
GRPC_CLOSURE_LIST_SCHED(&self->waiting_for_resolver_result_closures_);
|
868
|
-
self->resolver_->NextLocked(&self->resolver_result_,
|
869
|
-
&self->on_resolver_result_changed_);
|
870
|
-
}
|
871
|
-
|
872
|
-
void RequestRouter::RouteCallLocked(Request* request) {
|
873
|
-
GPR_ASSERT(request->pick_.connected_subchannel == nullptr);
|
874
|
-
request->request_router_ = this;
|
875
|
-
if (lb_policy_ != nullptr) {
|
876
|
-
// We already have resolver results, so process the service config
|
877
|
-
// and start an LB pick.
|
878
|
-
request->ProcessServiceConfigAndStartLbPickLocked();
|
879
|
-
} else if (resolver_ == nullptr) {
|
880
|
-
GRPC_CLOSURE_RUN(request->on_route_done_,
|
881
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
|
882
|
-
} else {
|
883
|
-
// We do not yet have an LB policy, so wait for a resolver result.
|
884
|
-
if (!started_resolving_) {
|
885
|
-
StartResolvingLocked();
|
886
|
-
}
|
887
|
-
// Create a new waiter, which will delete itself when done.
|
888
|
-
New<Request::ResolverResultWaiter>(request);
|
889
|
-
// Add the request's polling entity to the request_router's
|
890
|
-
// interested_parties, so that the I/O of the resolver can be done
|
891
|
-
// under it. It will be removed in LbPickDoneLocked().
|
892
|
-
request->MaybeAddCallToInterestedPartiesLocked();
|
893
|
-
}
|
894
|
-
}
|
895
|
-
|
896
|
-
void RequestRouter::ShutdownLocked(grpc_error* error) {
|
897
|
-
if (resolver_ != nullptr) {
|
898
|
-
SetConnectivityStateLocked(GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
|
899
|
-
"disconnect");
|
900
|
-
resolver_.reset();
|
901
|
-
if (!started_resolving_) {
|
902
|
-
grpc_closure_list_fail_all(&waiting_for_resolver_result_closures_,
|
903
|
-
GRPC_ERROR_REF(error));
|
904
|
-
GRPC_CLOSURE_LIST_SCHED(&waiting_for_resolver_result_closures_);
|
905
|
-
}
|
906
|
-
if (lb_policy_ != nullptr) {
|
907
|
-
grpc_pollset_set_del_pollset_set(lb_policy_->interested_parties(),
|
908
|
-
interested_parties_);
|
909
|
-
lb_policy_.reset();
|
910
|
-
}
|
911
|
-
}
|
912
|
-
GRPC_ERROR_UNREF(error);
|
913
|
-
}
|
914
|
-
|
915
|
-
grpc_connectivity_state RequestRouter::GetConnectivityState() {
|
916
|
-
return grpc_connectivity_state_check(&state_tracker_);
|
917
|
-
}
|
918
|
-
|
919
|
-
void RequestRouter::NotifyOnConnectivityStateChange(
|
920
|
-
grpc_connectivity_state* state, grpc_closure* closure) {
|
921
|
-
grpc_connectivity_state_notify_on_state_change(&state_tracker_, state,
|
922
|
-
closure);
|
923
|
-
}
|
924
|
-
|
925
|
-
void RequestRouter::ExitIdleLocked() {
|
926
|
-
if (lb_policy_ != nullptr) {
|
927
|
-
lb_policy_->ExitIdleLocked();
|
928
|
-
} else {
|
929
|
-
exit_idle_when_lb_policy_arrives_ = true;
|
930
|
-
if (!started_resolving_ && resolver_ != nullptr) {
|
931
|
-
StartResolvingLocked();
|
932
|
-
}
|
933
|
-
}
|
934
|
-
}
|
935
|
-
|
936
|
-
void RequestRouter::ResetConnectionBackoffLocked() {
|
937
|
-
if (resolver_ != nullptr) {
|
938
|
-
resolver_->ResetBackoffLocked();
|
939
|
-
resolver_->RequestReresolutionLocked();
|
940
|
-
}
|
941
|
-
if (lb_policy_ != nullptr) {
|
942
|
-
lb_policy_->ResetBackoffLocked();
|
943
|
-
}
|
944
|
-
}
|
945
|
-
|
946
|
-
} // namespace grpc_core
|