grpc 1.28.0 → 1.31.0.pre2
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 +8314 -11869
- data/include/grpc/grpc.h +2 -2
- data/include/grpc/grpc_security.h +30 -9
- data/include/grpc/grpc_security_constants.h +4 -0
- data/include/grpc/impl/codegen/grpc_types.h +23 -23
- data/include/grpc/impl/codegen/port_platform.h +6 -34
- data/include/grpc/module.modulemap +24 -39
- data/src/core/ext/filters/client_channel/backend_metric.cc +18 -12
- data/src/core/ext/filters/client_channel/client_channel.cc +591 -479
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -2
- data/src/core/ext/filters/client_channel/config_selector.cc +62 -0
- data/src/core/ext/filters/client_channel/config_selector.h +93 -0
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -2
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +9 -22
- data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +6 -5
- data/src/core/ext/filters/client_channel/http_proxy.cc +23 -14
- data/src/core/ext/filters/client_channel/lb_policy.cc +19 -18
- data/src/core/ext/filters/client_channel/lb_policy.h +44 -33
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +83 -0
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +99 -0
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +10 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +279 -324
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +11 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +871 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -17
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +733 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +84 -37
- data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +938 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +528 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -2
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +1143 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +10 -7
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +2 -1
- data/src/core/ext/filters/client_channel/parse_address.cc +22 -21
- data/src/core/ext/filters/client_channel/resolver.cc +5 -8
- data/src/core/ext/filters/client_channel/resolver.h +12 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +78 -61
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +41 -40
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +8 -7
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +22 -24
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +12 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +79 -122
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +199 -163
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +7 -4
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +46 -45
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +93 -102
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +0 -4
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +38 -8
- data/src/core/ext/filters/client_channel/resolver_factory.h +2 -2
- data/src/core/ext/filters/client_channel/resolver_registry.cc +19 -17
- data/src/core/ext/filters/client_channel/resolver_registry.h +8 -8
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +21 -22
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +19 -16
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +49 -55
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +43 -23
- data/src/core/ext/filters/client_channel/server_address.cc +6 -9
- data/src/core/ext/filters/client_channel/server_address.h +6 -12
- data/src/core/ext/filters/client_channel/service_config.cc +104 -144
- data/src/core/ext/filters/client_channel/service_config.h +28 -98
- data/src/core/ext/filters/client_channel/service_config_call_data.h +68 -0
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +142 -0
- data/src/core/ext/filters/client_channel/service_config_parser.cc +87 -0
- data/src/core/ext/filters/client_channel/service_config_parser.h +89 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +55 -25
- data/src/core/ext/filters/client_channel/subchannel.h +35 -11
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +565 -234
- data/src/core/ext/filters/client_channel/xds/xds_api.h +102 -37
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +55 -71
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +4 -3
- data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +4 -2
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +619 -347
- data/src/core/ext/filters/client_channel/xds/xds_client.h +57 -22
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +11 -12
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +40 -28
- data/src/core/ext/filters/http/client/http_client_filter.cc +28 -33
- data/src/core/ext/filters/http/client_authority_filter.cc +4 -4
- data/src/core/ext/filters/http/http_filters_plugin.cc +28 -12
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +258 -221
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +399 -0
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.h +31 -0
- data/src/core/ext/filters/message_size/message_size_filter.cc +61 -88
- data/src/core/ext/filters/message_size/message_size_filter.h +10 -4
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +386 -350
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +6 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +1 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +7 -13
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +4 -6
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +42 -26
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +25 -30
- data/src/core/ext/transport/chttp2/transport/flow_control.h +14 -16
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +9 -12
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +4 -6
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +12 -13
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -7
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +9 -12
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +29 -16
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +25 -29
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +2 -3
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +13 -17
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +2 -2
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +4 -5
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +2 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +27 -21
- data/src/core/ext/transport/chttp2/transport/parsing.cc +33 -43
- data/src/core/ext/transport/chttp2/transport/stream_map.h +2 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +24 -22
- data/src/core/ext/transport/inproc/inproc_transport.cc +54 -15
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +3 -4
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +4 -229
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +5 -876
- data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +114 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +429 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +72 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +198 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +105 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +388 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +23 -10
- data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +352 -310
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +42 -34
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +7 -7
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +79 -61
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +55 -49
- data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.c +35 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +79 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +48 -27
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +258 -214
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +51 -45
- data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +71 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +107 -100
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +24 -20
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +157 -122
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +9 -9
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +38 -18
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +173 -73
- data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.c +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +88 -0
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +95 -101
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +49 -65
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +9 -6
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +53 -38
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +70 -62
- data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +15 -10
- data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +95 -63
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +3 -2
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +91 -80
- data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +9 -10
- data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +36 -31
- data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +68 -46
- data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +770 -722
- data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +16 -15
- data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +95 -88
- data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +48 -28
- data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +305 -210
- data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +5 -5
- data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +51 -0
- data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +125 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +4 -2
- data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +22 -16
- data/src/core/ext/upb-generated/envoy/type/http.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/http.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +16 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +48 -11
- data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +14 -14
- data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +23 -23
- data/src/core/ext/upb-generated/envoy/type/percent.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/percent.upb.h +8 -9
- data/src/core/ext/upb-generated/envoy/type/range.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/range.upb.h +15 -16
- data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +7 -8
- data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +36 -35
- data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +0 -1
- data/src/core/ext/upb-generated/google/api/annotations.upb.h +0 -1
- data/src/core/ext/upb-generated/google/api/http.upb.h +29 -28
- data/src/core/ext/upb-generated/google/protobuf/any.upb.h +5 -6
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +12 -11
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +421 -389
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +5 -6
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +1 -2
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +1 -1
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +33 -54
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +5 -6
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +27 -28
- data/src/core/ext/upb-generated/google/rpc/status.upb.h +8 -8
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +1 -1
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +32 -45
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +4 -4
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +157 -178
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +14 -13
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +6 -7
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +59 -56
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +11 -12
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +0 -1
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +28 -0
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +64 -0
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +6 -6
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +41 -68
- data/src/core/ext/upb-generated/validate/validate.upb.c +21 -20
- data/src/core/ext/upb-generated/validate/validate.upb.h +569 -562
- data/src/core/lib/channel/channel_args.cc +15 -14
- data/src/core/lib/channel/channel_args.h +3 -1
- data/src/core/lib/channel/channel_stack.h +20 -13
- data/src/core/lib/channel/channel_trace.cc +2 -6
- data/src/core/lib/channel/channelz.cc +10 -21
- data/src/core/lib/channel/channelz.h +3 -2
- data/src/core/lib/channel/channelz_registry.cc +5 -3
- data/src/core/lib/channel/connected_channel.cc +7 -5
- data/src/core/lib/channel/context.h +1 -1
- data/src/core/lib/channel/handshaker.cc +11 -13
- data/src/core/lib/channel/handshaker.h +4 -2
- data/src/core/lib/channel/handshaker_registry.cc +5 -17
- data/src/core/lib/channel/status_util.cc +2 -3
- data/src/core/lib/compression/message_compress.cc +5 -1
- data/src/core/lib/debug/stats.cc +21 -27
- data/src/core/lib/debug/stats.h +3 -1
- data/src/core/lib/gpr/log_linux.cc +6 -8
- data/src/core/lib/gpr/log_posix.cc +6 -8
- data/src/core/lib/gpr/spinlock.h +2 -3
- data/src/core/lib/gpr/string.cc +10 -33
- data/src/core/lib/gpr/string.h +4 -18
- data/src/core/lib/gpr/sync_abseil.cc +2 -0
- data/src/core/lib/gpr/time.cc +4 -0
- data/src/core/lib/gpr/time_posix.cc +1 -1
- data/src/core/lib/gprpp/atomic.h +6 -6
- data/src/core/lib/gprpp/fork.cc +1 -1
- data/src/core/lib/gprpp/global_config_env.cc +8 -6
- data/src/core/lib/gprpp/host_port.cc +29 -35
- data/src/core/lib/gprpp/host_port.h +14 -17
- data/src/core/lib/gprpp/map.h +5 -11
- data/src/core/lib/gprpp/ref_counted_ptr.h +5 -0
- data/src/core/lib/http/format_request.cc +46 -65
- data/src/core/lib/http/httpcli.cc +15 -13
- data/src/core/lib/http/httpcli.h +2 -3
- data/src/core/lib/http/httpcli_security_connector.cc +10 -10
- data/src/core/lib/http/parser.h +2 -3
- data/src/core/lib/iomgr/buffer_list.h +22 -21
- data/src/core/lib/iomgr/call_combiner.h +3 -2
- data/src/core/lib/iomgr/cfstream_handle.cc +4 -2
- data/src/core/lib/iomgr/closure.h +2 -3
- data/src/core/lib/iomgr/dualstack_socket_posix.cc +47 -0
- data/src/core/lib/iomgr/endpoint_cfstream.cc +2 -3
- data/src/core/lib/iomgr/endpoint_pair.h +2 -3
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +10 -10
- data/src/core/lib/iomgr/error.cc +6 -9
- data/src/core/lib/iomgr/error.h +0 -1
- data/src/core/lib/iomgr/error_cfstream.cc +9 -8
- data/src/core/lib/iomgr/ev_apple.cc +356 -0
- data/src/core/lib/iomgr/ev_apple.h +43 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +25 -29
- data/src/core/lib/iomgr/ev_epollex_linux.cc +17 -24
- data/src/core/lib/iomgr/ev_poll_posix.cc +9 -8
- data/src/core/lib/iomgr/ev_posix.cc +4 -3
- data/src/core/lib/iomgr/exec_ctx.h +14 -2
- data/src/core/lib/iomgr/iomgr.cc +10 -0
- data/src/core/lib/iomgr/iomgr.h +10 -0
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +84 -20
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +14 -0
- data/src/core/lib/iomgr/pollset_set_custom.cc +10 -10
- data/src/core/lib/{gprpp/optional.h → iomgr/pollset_uv.h} +11 -12
- data/src/core/lib/iomgr/port.h +2 -21
- data/src/core/lib/iomgr/python_util.h +46 -0
- data/src/core/lib/iomgr/resolve_address.h +4 -6
- data/src/core/lib/iomgr/resolve_address_custom.cc +42 -57
- data/src/core/lib/iomgr/resolve_address_custom.h +4 -2
- data/src/core/lib/iomgr/resolve_address_posix.cc +10 -11
- data/src/core/lib/iomgr/resolve_address_windows.cc +16 -25
- data/src/core/lib/iomgr/resource_quota.cc +38 -37
- data/src/core/lib/iomgr/sockaddr_utils.cc +29 -33
- data/src/core/lib/iomgr/sockaddr_utils.h +10 -15
- data/src/core/lib/iomgr/socket_factory_posix.h +2 -3
- data/src/core/lib/iomgr/socket_mutator.h +2 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +102 -81
- data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
- data/src/core/lib/iomgr/socket_windows.cc +4 -5
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -18
- data/src/core/lib/iomgr/tcp_client_custom.cc +6 -9
- data/src/core/lib/iomgr/tcp_client_posix.cc +30 -36
- data/src/core/lib/iomgr/tcp_client_windows.cc +10 -11
- data/src/core/lib/iomgr/tcp_custom.cc +3 -4
- data/src/core/lib/iomgr/tcp_custom.h +1 -1
- data/src/core/lib/iomgr/tcp_server.cc +3 -4
- data/src/core/lib/iomgr/tcp_server.h +7 -5
- data/src/core/lib/iomgr/tcp_server_custom.cc +11 -23
- data/src/core/lib/iomgr/tcp_server_posix.cc +38 -44
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +7 -8
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +10 -18
- data/src/core/lib/iomgr/tcp_server_windows.cc +16 -16
- data/src/core/lib/iomgr/tcp_uv.cc +3 -2
- data/src/core/lib/iomgr/time_averaged_stats.h +2 -3
- data/src/core/lib/iomgr/timer_generic.cc +15 -15
- data/src/core/lib/{gprpp/inlined_vector.h → iomgr/timer_generic.h} +19 -17
- data/src/core/lib/iomgr/timer_heap.h +2 -3
- data/src/core/lib/iomgr/udp_server.cc +32 -36
- data/src/core/lib/iomgr/udp_server.h +5 -2
- data/src/core/lib/iomgr/unix_sockets_posix.cc +9 -14
- data/src/core/lib/iomgr/unix_sockets_posix.h +3 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +5 -2
- data/src/core/lib/json/json.h +3 -2
- data/src/core/lib/json/json_reader.cc +25 -26
- data/src/core/lib/json/json_writer.cc +13 -12
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +12 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +6 -3
- data/src/core/lib/security/credentials/credentials.cc +0 -84
- data/src/core/lib/security/credentials/credentials.h +13 -62
- data/src/core/lib/security/credentials/fake/fake_credentials.h +4 -0
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +8 -6
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -17
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +8 -6
- data/src/core/lib/security/credentials/iam/iam_credentials.h +4 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/json_token.h +2 -5
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +7 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +12 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +8 -15
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +73 -54
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +9 -3
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +19 -6
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +10 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +23 -13
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +48 -11
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +21 -6
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +17 -17
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +3 -2
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/security_connector.cc +2 -0
- data/src/core/lib/security/security_connector/security_connector.h +2 -2
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +38 -36
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +8 -5
- data/src/core/lib/security/security_connector/ssl_utils.cc +89 -21
- data/src/core/lib/security/security_connector/ssl_utils.h +18 -12
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +101 -72
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +27 -5
- data/src/core/lib/security/transport/auth_filters.h +0 -5
- data/src/core/lib/security/transport/client_auth_filter.cc +11 -11
- data/src/core/lib/security/util/json_util.cc +12 -13
- data/src/core/lib/slice/slice.cc +38 -1
- data/src/core/lib/slice/slice_intern.cc +2 -3
- data/src/core/lib/slice/slice_internal.h +15 -0
- data/src/core/lib/slice/slice_utils.h +9 -0
- data/src/core/lib/surface/byte_buffer_reader.cc +2 -47
- data/src/core/lib/surface/call.cc +42 -44
- data/src/core/lib/surface/call_log_batch.cc +50 -58
- data/src/core/lib/surface/channel.cc +53 -31
- data/src/core/lib/surface/channel.h +35 -4
- data/src/core/lib/surface/channel_ping.cc +2 -3
- data/src/core/lib/surface/completion_queue.cc +304 -47
- data/src/core/lib/surface/completion_queue.h +8 -0
- data/src/core/lib/surface/event_string.cc +18 -25
- data/src/core/lib/surface/event_string.h +3 -1
- data/src/core/lib/surface/init.cc +2 -0
- data/src/core/lib/surface/init_secure.cc +1 -4
- data/src/core/lib/surface/server.cc +971 -837
- data/src/core/lib/surface/server.h +66 -12
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.h +7 -2
- data/src/core/lib/transport/connectivity_state.cc +7 -6
- data/src/core/lib/transport/connectivity_state.h +5 -3
- data/src/core/lib/transport/metadata.cc +3 -3
- data/src/core/lib/transport/metadata_batch.h +2 -3
- data/src/core/lib/transport/static_metadata.h +1 -1
- data/src/core/lib/transport/status_conversion.cc +6 -14
- data/src/core/lib/transport/transport.cc +2 -3
- data/src/core/lib/transport/transport.h +9 -2
- data/src/core/lib/transport/transport_op_string.cc +61 -102
- data/src/core/lib/uri/uri_parser.cc +8 -15
- data/src/core/lib/uri/uri_parser.h +2 -3
- data/src/core/plugin_registry/grpc_plugin_registry.cc +24 -4
- data/src/core/tsi/alts/crypt/aes_gcm.cc +0 -2
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +31 -14
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +8 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +34 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +9 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +2 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +2 -3
- data/src/core/tsi/fake_transport_security.cc +10 -15
- data/src/core/tsi/ssl/session_cache/ssl_session.h +0 -2
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +0 -2
- data/src/core/tsi/ssl_transport_security.cc +154 -50
- data/src/core/tsi/ssl_transport_security.h +22 -10
- data/src/core/tsi/ssl_types.h +0 -2
- data/src/core/tsi/transport_security.h +6 -9
- data/src/core/tsi/transport_security_grpc.h +2 -3
- data/src/core/tsi/transport_security_interface.h +8 -3
- data/src/ruby/ext/grpc/extconf.rb +5 -2
- data/src/ruby/ext/grpc/rb_call.c +12 -3
- data/src/ruby/ext/grpc/rb_call.h +4 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +57 -12
- 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/errors.rb +103 -42
- data/src/ruby/lib/grpc/generic/active_call.rb +2 -3
- data/src/ruby/lib/grpc/generic/interceptors.rb +5 -5
- data/src/ruby/lib/grpc/generic/rpc_server.rb +9 -10
- data/src/ruby/lib/grpc/generic/service.rb +5 -4
- data/src/ruby/lib/grpc/structs.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/generate_proto_ruby.sh +5 -3
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +11 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +16 -0
- data/src/ruby/spec/debug_message_spec.rb +134 -0
- data/src/ruby/spec/generic/service_spec.rb +2 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +7 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +7 -1
- data/src/ruby/spec/support/services.rb +10 -4
- data/src/ruby/spec/testdata/ca.pem +18 -13
- data/src/ruby/spec/testdata/client.key +26 -14
- data/src/ruby/spec/testdata/client.pem +18 -12
- data/src/ruby/spec/testdata/server1.key +26 -14
- data/src/ruby/spec/testdata/server1.pem +20 -14
- data/third_party/abseil-cpp/absl/time/civil_time.cc +175 -0
- data/third_party/abseil-cpp/absl/time/civil_time.h +538 -0
- data/third_party/abseil-cpp/absl/time/clock.cc +569 -0
- data/third_party/abseil-cpp/absl/time/clock.h +74 -0
- data/third_party/abseil-cpp/absl/time/duration.cc +922 -0
- data/third_party/abseil-cpp/absl/time/format.cc +153 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h +332 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +622 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +384 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +102 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc +94 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +140 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h +52 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +922 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +45 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +76 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +121 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +93 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +958 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +138 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +308 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +55 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +187 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc +159 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +132 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +122 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +115 -0
- data/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc +31 -0
- data/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc +24 -0
- data/third_party/abseil-cpp/absl/time/time.cc +499 -0
- data/third_party/abseil-cpp/absl/time/time.h +1584 -0
- data/third_party/boringssl-with-bazel/err_data.c +335 -297
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_enum.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +7 -5
- data/third_party/boringssl-with-bazel/src/crypto/cpu-intel.c +13 -4
- data/third_party/boringssl-with-bazel/src/crypto/crypto.c +11 -0
- data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/curve25519.c +18 -26
- data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/curve25519_tables.h +13 -21
- data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/internal.h +14 -22
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/dh/dh.c +15 -0
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +10 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +385 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +56 -0
- data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +33 -32
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +143 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +17 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +25 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +8 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.c +30 -154
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +16 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +289 -117
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +13 -27
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +96 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +25 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +434 -161
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +63 -71
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +18 -25
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64-table.h +9481 -9485
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.c +104 -122
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +740 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +297 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +90 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +125 -148
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +189 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/util.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +61 -18
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +20 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +137 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.h +49 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/getrandom_fillin.h +64 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +41 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +32 -17
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +24 -114
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +51 -38
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +15 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +62 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +44 -35
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +47 -16
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +15 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +36 -5
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +6 -10
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +16 -0
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +249 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +1227 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +682 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +8 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +0 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +13 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +10 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +57 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +4 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +33 -9
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +25 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +4 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +35 -13
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +0 -154
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +28 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +74 -35
- data/third_party/boringssl-with-bazel/src/include/openssl/aes.h +16 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +22 -22
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +6 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +9 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +20 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +16 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +6 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/err.h +2 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +69 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +5 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +3 -17
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +31 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/sha.h +26 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +191 -79
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +282 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +791 -715
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +1 -0
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +0 -4
- data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +3 -3
- data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +13 -4
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +146 -57
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +23 -5
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +30 -22
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +21 -4
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +74 -54
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +10 -10
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +21 -21
- data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +29 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -1
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +13 -2
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +44 -5
- data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +6 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +5 -5
- data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +51 -26
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +47 -53
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +129 -48
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +23 -75
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +55 -22
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +63 -25
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +245 -175
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +135 -75
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +1593 -1672
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +512 -503
- data/third_party/re2/re2/bitmap256.h +117 -0
- data/third_party/re2/re2/bitstate.cc +385 -0
- data/third_party/re2/re2/compile.cc +1279 -0
- data/third_party/re2/re2/dfa.cc +2130 -0
- data/third_party/re2/re2/filtered_re2.cc +121 -0
- data/third_party/re2/re2/filtered_re2.h +109 -0
- data/third_party/re2/re2/mimics_pcre.cc +197 -0
- data/third_party/re2/re2/nfa.cc +713 -0
- data/third_party/re2/re2/onepass.cc +623 -0
- data/third_party/re2/re2/parse.cc +2464 -0
- data/third_party/re2/re2/perl_groups.cc +119 -0
- data/third_party/re2/re2/pod_array.h +55 -0
- data/third_party/re2/re2/prefilter.cc +710 -0
- data/third_party/re2/re2/prefilter.h +108 -0
- data/third_party/re2/re2/prefilter_tree.cc +407 -0
- data/third_party/re2/re2/prefilter_tree.h +139 -0
- data/third_party/re2/re2/prog.cc +988 -0
- data/third_party/re2/re2/prog.h +436 -0
- data/third_party/re2/re2/re2.cc +1362 -0
- data/third_party/re2/re2/re2.h +1002 -0
- data/third_party/re2/re2/regexp.cc +980 -0
- data/third_party/re2/re2/regexp.h +659 -0
- data/third_party/re2/re2/set.cc +154 -0
- data/third_party/re2/re2/set.h +80 -0
- data/third_party/re2/re2/simplify.cc +657 -0
- data/third_party/re2/re2/sparse_array.h +392 -0
- data/third_party/re2/re2/sparse_set.h +264 -0
- data/third_party/re2/re2/stringpiece.cc +65 -0
- data/third_party/re2/re2/stringpiece.h +210 -0
- data/third_party/re2/re2/tostring.cc +351 -0
- data/third_party/re2/re2/unicode_casefold.cc +582 -0
- data/third_party/re2/re2/unicode_casefold.h +78 -0
- data/third_party/re2/re2/unicode_groups.cc +6269 -0
- data/third_party/re2/re2/unicode_groups.h +67 -0
- data/third_party/re2/re2/walker-inl.h +246 -0
- data/third_party/re2/util/benchmark.h +156 -0
- data/third_party/re2/util/flags.h +26 -0
- data/third_party/re2/util/logging.h +109 -0
- data/third_party/re2/util/malloc_counter.h +19 -0
- data/third_party/re2/util/mix.h +41 -0
- data/third_party/re2/util/mutex.h +148 -0
- data/third_party/re2/util/pcre.cc +1025 -0
- data/third_party/re2/util/pcre.h +681 -0
- data/third_party/re2/util/rune.cc +260 -0
- data/third_party/re2/util/strutil.cc +149 -0
- data/third_party/re2/util/strutil.h +21 -0
- data/third_party/re2/util/test.h +50 -0
- data/third_party/re2/util/utf.h +44 -0
- data/third_party/re2/util/util.h +42 -0
- data/third_party/upb/upb/decode.c +467 -504
- data/third_party/upb/upb/encode.c +163 -121
- data/third_party/upb/upb/msg.c +130 -64
- data/third_party/upb/upb/msg.h +418 -14
- data/third_party/upb/upb/port_def.inc +35 -6
- data/third_party/upb/upb/port_undef.inc +8 -1
- data/third_party/upb/upb/table.c +53 -75
- data/third_party/upb/upb/table.int.h +11 -43
- data/third_party/upb/upb/upb.c +148 -124
- data/third_party/upb/upb/upb.h +65 -147
- data/third_party/upb/upb/upb.hpp +86 -0
- metadata +175 -47
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +0 -1754
- data/src/core/lib/gprpp/string_view.h +0 -60
- data/src/core/tsi/grpc_shadow_boringssl.h +0 -3311
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256.c +0 -1063
- data/third_party/upb/upb/generated_util.h +0 -105
@@ -24,15 +24,16 @@
|
|
24
24
|
#include <functional>
|
25
25
|
#include <iterator>
|
26
26
|
|
27
|
+
#include "absl/strings/string_view.h"
|
28
|
+
|
27
29
|
#include "src/core/ext/filters/client_channel/server_address.h"
|
28
30
|
#include "src/core/ext/filters/client_channel/service_config.h"
|
29
31
|
#include "src/core/ext/filters/client_channel/subchannel_interface.h"
|
30
32
|
#include "src/core/lib/gprpp/map.h"
|
31
33
|
#include "src/core/lib/gprpp/orphanable.h"
|
32
34
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
33
|
-
#include "src/core/lib/gprpp/string_view.h"
|
34
|
-
#include "src/core/lib/iomgr/combiner.h"
|
35
35
|
#include "src/core/lib/iomgr/polling_entity.h"
|
36
|
+
#include "src/core/lib/iomgr/work_serializer.h"
|
36
37
|
#include "src/core/lib/transport/connectivity_state.h"
|
37
38
|
|
38
39
|
namespace grpc_core {
|
@@ -72,7 +73,7 @@ extern DebugOnlyTraceFlag grpc_trace_lb_policy_refcount;
|
|
72
73
|
/// LoadBalacingPolicy API.
|
73
74
|
///
|
74
75
|
/// Note: All methods with a "Locked" suffix must be called from the
|
75
|
-
///
|
76
|
+
/// work_serializer passed to the constructor.
|
76
77
|
///
|
77
78
|
/// Any I/O done by the LB policy should be done under the pollset_set
|
78
79
|
/// returned by \a interested_parties().
|
@@ -93,11 +94,11 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
93
94
|
/// Application-specific requests cost metrics. Metric names are
|
94
95
|
/// determined by the application. Each value is an absolute cost
|
95
96
|
/// (e.g. 3487 bytes of storage) associated with the request.
|
96
|
-
std::map<
|
97
|
+
std::map<absl::string_view, double, StringLess> request_cost;
|
97
98
|
/// Application-specific resource utilization metrics. Metric names
|
98
99
|
/// are determined by the application. Each value is expressed as a
|
99
100
|
/// fraction of total resources available.
|
100
|
-
std::map<
|
101
|
+
std::map<absl::string_view, double, StringLess> utilization;
|
101
102
|
};
|
102
103
|
|
103
104
|
/// Interface for accessing per-call state.
|
@@ -115,7 +116,17 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
115
116
|
|
116
117
|
/// Returns the backend metric data returned by the server for the call,
|
117
118
|
/// or null if no backend metric data was returned.
|
119
|
+
// TODO(roth): Move this out of CallState, since it should not be
|
120
|
+
// accessible to the picker, only to the recv_trailing_metadata_ready
|
121
|
+
// callback. It should instead be in its own interface.
|
118
122
|
virtual const BackendMetricData* GetBackendMetricData() = 0;
|
123
|
+
|
124
|
+
/// EXPERIMENTAL API.
|
125
|
+
/// Returns the value of the call attribute \a key.
|
126
|
+
/// Keys are static strings, so an attribute can be accessed by an LB
|
127
|
+
/// policy implementation only if it knows about the internal key.
|
128
|
+
/// Returns a null string_view if key not found.
|
129
|
+
virtual absl::string_view ExperimentalGetCallAttribute(const char* key) = 0;
|
119
130
|
};
|
120
131
|
|
121
132
|
/// Interface for accessing metadata.
|
@@ -123,12 +134,13 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
123
134
|
class MetadataInterface {
|
124
135
|
public:
|
125
136
|
class iterator
|
126
|
-
: public std::iterator<
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
137
|
+
: public std::iterator<
|
138
|
+
std::input_iterator_tag,
|
139
|
+
std::pair<absl::string_view, absl::string_view>, // value_type
|
140
|
+
std::ptrdiff_t, // difference_type
|
141
|
+
std::pair<absl::string_view, absl::string_view>*, // pointer
|
142
|
+
std::pair<absl::string_view, absl::string_view>& // reference
|
143
|
+
> {
|
132
144
|
public:
|
133
145
|
iterator(const MetadataInterface* md, intptr_t handle)
|
134
146
|
: md_(md), handle_(handle) {}
|
@@ -155,7 +167,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
155
167
|
/// Implementations must ensure that the key and value remain alive
|
156
168
|
/// until the call ends. If desired, they may be allocated via
|
157
169
|
/// CallState::Alloc().
|
158
|
-
virtual void Add(
|
170
|
+
virtual void Add(absl::string_view key, absl::string_view value) = 0;
|
159
171
|
|
160
172
|
/// Iteration interface.
|
161
173
|
virtual iterator begin() const = 0;
|
@@ -172,19 +184,21 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
172
184
|
friend class iterator;
|
173
185
|
|
174
186
|
virtual intptr_t IteratorHandleNext(intptr_t handle) const = 0;
|
175
|
-
virtual std::pair<
|
187
|
+
virtual std::pair<absl::string_view /*key*/, absl::string_view /*value */>
|
176
188
|
IteratorHandleGet(intptr_t handle) const = 0;
|
177
189
|
};
|
178
190
|
|
179
191
|
/// Arguments used when picking a subchannel for a call.
|
180
192
|
struct PickArgs {
|
193
|
+
/// The path of the call. Indicates the RPC service and method name.
|
194
|
+
absl::string_view path;
|
181
195
|
/// Initial metadata associated with the picking call.
|
182
196
|
/// The LB policy may use the existing metadata to influence its routing
|
183
197
|
/// decision, and it may add new metadata elements to be sent with the
|
184
198
|
/// call to the chosen backend.
|
185
199
|
MetadataInterface* initial_metadata;
|
186
200
|
/// An interface for accessing call state. Can be used to allocate
|
187
|
-
///
|
201
|
+
/// memory associated with the call in an efficient way.
|
188
202
|
CallState* call_state;
|
189
203
|
};
|
190
204
|
|
@@ -226,6 +240,9 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
226
240
|
/// does not take ownership, so any data that needs to be used after
|
227
241
|
/// returning must be copied.
|
228
242
|
/// The call state can be used to obtain backend metric data.
|
243
|
+
// TODO(roth): The arguments to this callback should be moved into a
|
244
|
+
// struct, so that we can later add new fields without breaking
|
245
|
+
// existing implementations.
|
229
246
|
std::function<void(grpc_error*, MetadataInterface*, CallState*)>
|
230
247
|
recv_trailing_metadata_ready;
|
231
248
|
};
|
@@ -242,7 +259,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
242
259
|
/// live in the LB policy object itself.
|
243
260
|
///
|
244
261
|
/// Currently, pickers are always accessed from within the
|
245
|
-
/// client_channel data plane
|
262
|
+
/// client_channel data plane mutex, so they do not have to be
|
246
263
|
/// thread-safe.
|
247
264
|
class SubchannelPicker {
|
248
265
|
public:
|
@@ -254,9 +271,6 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
254
271
|
|
255
272
|
/// A proxy object implemented by the client channel and used by the
|
256
273
|
/// LB policy to communicate with the channel.
|
257
|
-
// TODO(juanlishen): Consider adding a mid-layer subclass that helps handle
|
258
|
-
// things like swapping in pending policy when it's ready. Currently, we are
|
259
|
-
// duplicating the logic in many subclasses.
|
260
274
|
class ChannelControlHelper {
|
261
275
|
public:
|
262
276
|
ChannelControlHelper() = default;
|
@@ -276,7 +290,8 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
276
290
|
|
277
291
|
/// Adds a trace message associated with the channel.
|
278
292
|
enum TraceSeverity { TRACE_INFO, TRACE_WARNING, TRACE_ERROR };
|
279
|
-
virtual void AddTraceEvent(TraceSeverity severity,
|
293
|
+
virtual void AddTraceEvent(TraceSeverity severity,
|
294
|
+
absl::string_view message) = 0;
|
280
295
|
};
|
281
296
|
|
282
297
|
/// Interface for configuration data used by an LB policy implementation.
|
@@ -302,19 +317,15 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
302
317
|
UpdateArgs() = default;
|
303
318
|
~UpdateArgs() { grpc_channel_args_destroy(args); }
|
304
319
|
UpdateArgs(const UpdateArgs& other);
|
305
|
-
UpdateArgs(UpdateArgs&& other);
|
320
|
+
UpdateArgs(UpdateArgs&& other) noexcept;
|
306
321
|
UpdateArgs& operator=(const UpdateArgs& other);
|
307
|
-
UpdateArgs& operator=(UpdateArgs&& other);
|
322
|
+
UpdateArgs& operator=(UpdateArgs&& other) noexcept;
|
308
323
|
};
|
309
324
|
|
310
325
|
/// Args used to instantiate an LB policy.
|
311
326
|
struct Args {
|
312
|
-
/// The
|
313
|
-
|
314
|
-
// TODO(roth): Once we have a C++-like interface for combiners, this
|
315
|
-
// API should change to take a smart pointer that does pass ownership
|
316
|
-
// of a reference.
|
317
|
-
Combiner* combiner = nullptr;
|
327
|
+
/// The work_serializer under which all LB policy calls will be run.
|
328
|
+
std::shared_ptr<WorkSerializer> work_serializer;
|
318
329
|
/// Channel control helper.
|
319
330
|
/// Note: LB policies MUST NOT call any method on the helper from
|
320
331
|
/// their constructor.
|
@@ -352,7 +363,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
352
363
|
|
353
364
|
grpc_pollset_set* interested_parties() const { return interested_parties_; }
|
354
365
|
|
355
|
-
// Note: This must be invoked while holding the
|
366
|
+
// Note: This must be invoked while holding the work_serializer.
|
356
367
|
void Orphan() override;
|
357
368
|
|
358
369
|
// A picker that returns PICK_QUEUE for all picks.
|
@@ -368,8 +379,6 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
368
379
|
PickResult Pick(PickArgs args) override;
|
369
380
|
|
370
381
|
private:
|
371
|
-
static void CallExitIdle(void* arg, grpc_error* error);
|
372
|
-
|
373
382
|
RefCountedPtr<LoadBalancingPolicy> parent_;
|
374
383
|
bool exit_idle_called_ = false;
|
375
384
|
};
|
@@ -387,7 +396,9 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
387
396
|
};
|
388
397
|
|
389
398
|
protected:
|
390
|
-
|
399
|
+
std::shared_ptr<WorkSerializer> work_serializer() const {
|
400
|
+
return work_serializer_;
|
401
|
+
}
|
391
402
|
|
392
403
|
// Note: LB policies MUST NOT call any method on the helper from their
|
393
404
|
// constructor.
|
@@ -399,8 +410,8 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
|
|
399
410
|
virtual void ShutdownLocked() = 0;
|
400
411
|
|
401
412
|
private:
|
402
|
-
///
|
403
|
-
|
413
|
+
/// Work Serializer under which LB policy actions take place.
|
414
|
+
std::shared_ptr<WorkSerializer> work_serializer_;
|
404
415
|
/// Owned pointer to interested parties in load balancing decisions.
|
405
416
|
grpc_pollset_set* interested_parties_;
|
406
417
|
/// Channel control helper.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2020 gRPC authors.
|
3
|
+
//
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
// you may not use this file except in compliance with the License.
|
6
|
+
// You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
// See the License for the specific language governing permissions and
|
14
|
+
// limitations under the License.
|
15
|
+
//
|
16
|
+
|
17
|
+
#include <grpc/support/port_platform.h>
|
18
|
+
|
19
|
+
#include "src/core/ext/filters/client_channel/lb_policy/address_filtering.h"
|
20
|
+
|
21
|
+
#include "src/core/lib/channel/channel_args.h"
|
22
|
+
|
23
|
+
#define GRPC_ARG_HIERARCHICAL_PATH "grpc.internal.address.hierarchical_path"
|
24
|
+
|
25
|
+
namespace grpc_core {
|
26
|
+
|
27
|
+
namespace {
|
28
|
+
|
29
|
+
void* HierarchicalPathCopy(void* p) {
|
30
|
+
std::vector<std::string>* path = static_cast<std::vector<std::string>*>(p);
|
31
|
+
return static_cast<void*>(new std::vector<std::string>(*path));
|
32
|
+
}
|
33
|
+
|
34
|
+
void HierarchicalPathDestroy(void* p) {
|
35
|
+
std::vector<std::string>* path = static_cast<std::vector<std::string>*>(p);
|
36
|
+
delete path;
|
37
|
+
}
|
38
|
+
|
39
|
+
int HierarchicalPathCompare(void* p1, void* p2) {
|
40
|
+
std::vector<std::string>* path1 = static_cast<std::vector<std::string>*>(p1);
|
41
|
+
std::vector<std::string>* path2 = static_cast<std::vector<std::string>*>(p2);
|
42
|
+
for (size_t i = 0; i < path1->size(); ++i) {
|
43
|
+
if (path2->size() == i) return 1;
|
44
|
+
int r = (*path1)[i].compare((*path2)[i]);
|
45
|
+
if (r != 0) return r;
|
46
|
+
}
|
47
|
+
if (path2->size() > path1->size()) return -1;
|
48
|
+
return 0;
|
49
|
+
}
|
50
|
+
|
51
|
+
const grpc_arg_pointer_vtable hierarchical_path_arg_vtable = {
|
52
|
+
HierarchicalPathCopy, HierarchicalPathDestroy, HierarchicalPathCompare};
|
53
|
+
|
54
|
+
} // namespace
|
55
|
+
|
56
|
+
grpc_arg MakeHierarchicalPathArg(const std::vector<std::string>& path) {
|
57
|
+
return grpc_channel_arg_pointer_create(
|
58
|
+
const_cast<char*>(GRPC_ARG_HIERARCHICAL_PATH),
|
59
|
+
const_cast<std::vector<std::string>*>(&path),
|
60
|
+
&hierarchical_path_arg_vtable);
|
61
|
+
}
|
62
|
+
|
63
|
+
HierarchicalAddressMap MakeHierarchicalAddressMap(
|
64
|
+
const ServerAddressList& addresses) {
|
65
|
+
HierarchicalAddressMap result;
|
66
|
+
for (const ServerAddress& address : addresses) {
|
67
|
+
auto* path = grpc_channel_args_find_pointer<std::vector<std::string>>(
|
68
|
+
address.args(), GRPC_ARG_HIERARCHICAL_PATH);
|
69
|
+
if (path == nullptr || path->empty()) continue;
|
70
|
+
auto it = path->begin();
|
71
|
+
ServerAddressList& target_list = result[*it];
|
72
|
+
++it;
|
73
|
+
std::vector<std::string> remaining_path(it, path->end());
|
74
|
+
const char* name_to_remove = GRPC_ARG_HIERARCHICAL_PATH;
|
75
|
+
grpc_arg new_arg = MakeHierarchicalPathArg(remaining_path);
|
76
|
+
grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
|
77
|
+
address.args(), &name_to_remove, 1, &new_arg, 1);
|
78
|
+
target_list.emplace_back(address.address(), new_args);
|
79
|
+
}
|
80
|
+
return result;
|
81
|
+
}
|
82
|
+
|
83
|
+
} // namespace grpc_core
|
@@ -0,0 +1,99 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2020 gRPC authors.
|
3
|
+
//
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
// you may not use this file except in compliance with the License.
|
6
|
+
// You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
// See the License for the specific language governing permissions and
|
14
|
+
// limitations under the License.
|
15
|
+
//
|
16
|
+
|
17
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_ADDRESS_FILTERING_H
|
18
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_ADDRESS_FILTERING_H
|
19
|
+
|
20
|
+
#include <grpc/support/port_platform.h>
|
21
|
+
|
22
|
+
#include <map>
|
23
|
+
#include <string>
|
24
|
+
#include <vector>
|
25
|
+
|
26
|
+
#include "absl/strings/string_view.h"
|
27
|
+
|
28
|
+
#include "src/core/ext/filters/client_channel/server_address.h"
|
29
|
+
|
30
|
+
// The resolver returns a flat list of addresses. When a hierarchy of
|
31
|
+
// LB policies is in use, each leaf of the hierarchy will need a
|
32
|
+
// different subset of those addresses. This library provides a
|
33
|
+
// mechanism for determining which address is passed to which leaf
|
34
|
+
// policy.
|
35
|
+
//
|
36
|
+
// Each address will have an associated path that indicates which child
|
37
|
+
// it should be sent to at each level of the hierarchy to wind up at the
|
38
|
+
// right leaf policy. Each LB policy will look at the first element of
|
39
|
+
// the path of each address to determine which child to send the address
|
40
|
+
// to. It will then remove that first element when passing the address
|
41
|
+
// down to its child.
|
42
|
+
//
|
43
|
+
// For example, consider the following LB policy hierarchy:
|
44
|
+
//
|
45
|
+
// - priority
|
46
|
+
// - child0 (weighted_target)
|
47
|
+
// - localityA (round_robin)
|
48
|
+
// - localityB (round_robin)
|
49
|
+
// - child1 (weighted_target)
|
50
|
+
// - localityC (round_robin)
|
51
|
+
// - localityD (round_robin)
|
52
|
+
//
|
53
|
+
// Now consider the following addresses:
|
54
|
+
// - 10.0.0.1:80 path=["child0", "localityA"]
|
55
|
+
// - 10.0.0.2:80 path=["child0", "localityB"]
|
56
|
+
// - 10.0.0.3:80 path=["child1", "localityC"]
|
57
|
+
// - 10.0.0.4:80 path=["child1", "localityD"]
|
58
|
+
//
|
59
|
+
// The priority policy will split this up into two lists, one for each
|
60
|
+
// of its children:
|
61
|
+
// - child0:
|
62
|
+
// - 10.0.0.1:80 path=["localityA"]
|
63
|
+
// - 10.0.0.2:80 path=["localityB"]
|
64
|
+
// - child1:
|
65
|
+
// - 10.0.0.3:80 path=["localityC"]
|
66
|
+
// - 10.0.0.4:80 path=["localityD"]
|
67
|
+
//
|
68
|
+
// The weighted_target policy for child0 will split its list up into two
|
69
|
+
// lists, one for each of its children:
|
70
|
+
// - localityA:
|
71
|
+
// - 10.0.0.1:80 path=[]
|
72
|
+
// - localityB:
|
73
|
+
// - 10.0.0.2:80 path=[]
|
74
|
+
//
|
75
|
+
// Similarly, the weighted_target policy for child1 will split its list
|
76
|
+
// up into two lists, one for each of its children:
|
77
|
+
// - localityC:
|
78
|
+
// - 10.0.0.3:80 path=[]
|
79
|
+
// - localityD:
|
80
|
+
// - 10.0.0.4:80 path=[]
|
81
|
+
|
82
|
+
namespace grpc_core {
|
83
|
+
|
84
|
+
// Constructs a channel arg containing the hierarchical path
|
85
|
+
// to be associated with an address.
|
86
|
+
grpc_arg MakeHierarchicalPathArg(const std::vector<std::string>& path);
|
87
|
+
|
88
|
+
// A map from the next path element to the addresses that fall under
|
89
|
+
// that path element.
|
90
|
+
using HierarchicalAddressMap = std::map<std::string, ServerAddressList>;
|
91
|
+
|
92
|
+
// Splits up the addresses into a separate list for each child.
|
93
|
+
HierarchicalAddressMap MakeHierarchicalAddressMap(
|
94
|
+
const ServerAddressList& addresses);
|
95
|
+
|
96
|
+
} // namespace grpc_core
|
97
|
+
|
98
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_ADDRESS_FILTERING_H \
|
99
|
+
*/
|
@@ -49,7 +49,8 @@ class ChildPolicyHandler::Helper
|
|
49
49
|
std::unique_ptr<SubchannelPicker> picker) override {
|
50
50
|
if (parent_->shutting_down_) return;
|
51
51
|
// If this request is from the pending child policy, ignore it until
|
52
|
-
// it reports
|
52
|
+
// it reports something other than CONNECTING, at which point we swap it
|
53
|
+
// into place.
|
53
54
|
if (CalledByPendingChild()) {
|
54
55
|
if (GRPC_TRACE_FLAG_ENABLED(*(parent_->tracer_))) {
|
55
56
|
gpr_log(GPR_INFO,
|
@@ -57,7 +58,7 @@ class ChildPolicyHandler::Helper
|
|
57
58
|
"reports state=%s",
|
58
59
|
parent_.get(), this, child_, ConnectivityStateName(state));
|
59
60
|
}
|
60
|
-
if (state
|
61
|
+
if (state == GRPC_CHANNEL_CONNECTING) return;
|
61
62
|
grpc_pollset_set_del_pollset_set(
|
62
63
|
parent_->child_policy_->interested_parties(),
|
63
64
|
parent_->interested_parties());
|
@@ -86,7 +87,8 @@ class ChildPolicyHandler::Helper
|
|
86
87
|
parent_->channel_control_helper()->RequestReresolution();
|
87
88
|
}
|
88
89
|
|
89
|
-
void AddTraceEvent(TraceSeverity severity,
|
90
|
+
void AddTraceEvent(TraceSeverity severity,
|
91
|
+
absl::string_view message) override {
|
90
92
|
if (parent_->shutting_down_) return;
|
91
93
|
if (!CalledByPendingChild() && !CalledByCurrentChild()) return;
|
92
94
|
parent_->channel_control_helper()->AddTraceEvent(severity, message);
|
@@ -201,6 +203,10 @@ void ChildPolicyHandler::UpdateLocked(UpdateArgs args) {
|
|
201
203
|
// Cases 1, 2b, and 3b: create a new child policy.
|
202
204
|
// If child_policy_ is null, we set it (case 1), else we set
|
203
205
|
// pending_child_policy_ (cases 2b and 3b).
|
206
|
+
// TODO(roth): In cases 2b and 3b, we should start a timer here, so
|
207
|
+
// that there's an upper bound on the amount of time it takes us to
|
208
|
+
// switch to the new policy, even if the new policy stays in
|
209
|
+
// CONNECTING for a very long period of time.
|
204
210
|
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
205
211
|
gpr_log(GPR_INFO,
|
206
212
|
"[child_policy_handler %p] creating new %schild policy %s", this,
|
@@ -251,7 +257,7 @@ OrphanablePtr<LoadBalancingPolicy> ChildPolicyHandler::CreateChildPolicy(
|
|
251
257
|
const char* child_policy_name, const grpc_channel_args& args) {
|
252
258
|
Helper* helper = new Helper(Ref(DEBUG_LOCATION, "Helper"));
|
253
259
|
LoadBalancingPolicy::Args lb_policy_args;
|
254
|
-
lb_policy_args.
|
260
|
+
lb_policy_args.work_serializer = work_serializer();
|
255
261
|
lb_policy_args.channel_control_helper =
|
256
262
|
std::unique_ptr<ChannelControlHelper>(helper);
|
257
263
|
lb_policy_args.args = &args;
|
@@ -64,6 +64,13 @@
|
|
64
64
|
#include <limits.h>
|
65
65
|
#include <string.h>
|
66
66
|
|
67
|
+
#include "absl/container/inlined_vector.h"
|
68
|
+
#include "absl/strings/str_cat.h"
|
69
|
+
#include "absl/strings/str_format.h"
|
70
|
+
#include "absl/strings/str_join.h"
|
71
|
+
|
72
|
+
#include "upb/upb.hpp"
|
73
|
+
|
67
74
|
#include <grpc/byte_buffer_reader.h>
|
68
75
|
#include <grpc/grpc.h>
|
69
76
|
#include <grpc/support/alloc.h>
|
@@ -74,6 +81,7 @@
|
|
74
81
|
#include "src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h"
|
75
82
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
|
76
83
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
|
84
|
+
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h"
|
77
85
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h"
|
78
86
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
|
79
87
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
|
@@ -90,7 +98,6 @@
|
|
90
98
|
#include "src/core/lib/gprpp/memory.h"
|
91
99
|
#include "src/core/lib/gprpp/orphanable.h"
|
92
100
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
93
|
-
#include "src/core/lib/iomgr/combiner.h"
|
94
101
|
#include "src/core/lib/iomgr/sockaddr.h"
|
95
102
|
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
96
103
|
#include "src/core/lib/iomgr/timer.h"
|
@@ -124,16 +131,21 @@ constexpr char kGrpclb[] = "grpclb";
|
|
124
131
|
|
125
132
|
class GrpcLbConfig : public LoadBalancingPolicy::Config {
|
126
133
|
public:
|
127
|
-
|
128
|
-
|
134
|
+
GrpcLbConfig(RefCountedPtr<LoadBalancingPolicy::Config> child_policy,
|
135
|
+
std::string service_name)
|
136
|
+
: child_policy_(std::move(child_policy)),
|
137
|
+
service_name_(std::move(service_name)) {}
|
129
138
|
const char* name() const override { return kGrpclb; }
|
130
139
|
|
131
140
|
RefCountedPtr<LoadBalancingPolicy::Config> child_policy() const {
|
132
141
|
return child_policy_;
|
133
142
|
}
|
134
143
|
|
144
|
+
const std::string& service_name() const { return service_name_; }
|
145
|
+
|
135
146
|
private:
|
136
147
|
RefCountedPtr<LoadBalancingPolicy::Config> child_policy_;
|
148
|
+
std::string service_name_;
|
137
149
|
};
|
138
150
|
|
139
151
|
class GrpcLb : public LoadBalancingPolicy {
|
@@ -178,11 +190,11 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
178
190
|
static void OnBalancerMessageReceived(void* arg, grpc_error* error);
|
179
191
|
static void OnBalancerStatusReceived(void* arg, grpc_error* error);
|
180
192
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
193
|
+
void MaybeSendClientLoadReportLocked(grpc_error* error);
|
194
|
+
void ClientLoadReportDoneLocked(grpc_error* error);
|
195
|
+
void OnInitialRequestSentLocked();
|
196
|
+
void OnBalancerMessageReceivedLocked();
|
197
|
+
void OnBalancerStatusReceivedLocked(grpc_error* error);
|
186
198
|
|
187
199
|
// The owning LB policy.
|
188
200
|
RefCountedPtr<LoadBalancingPolicy> grpclb_policy_;
|
@@ -233,7 +245,7 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
233
245
|
const std::vector<GrpcLbServer>& serverlist() const { return serverlist_; }
|
234
246
|
|
235
247
|
// Returns a text representation suitable for logging.
|
236
|
-
|
248
|
+
std::string AsText() const;
|
237
249
|
|
238
250
|
// Extracts all non-drop entries into a ServerAddressList.
|
239
251
|
ServerAddressList GetServerAddressList(
|
@@ -247,16 +259,16 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
247
259
|
// should not be dropped.
|
248
260
|
//
|
249
261
|
// Note: This is called from the picker, so it will be invoked in
|
250
|
-
// the channel's data plane
|
251
|
-
//
|
262
|
+
// the channel's data plane mutex, NOT the control plane
|
263
|
+
// work_serializer. It should not be accessed by any other part of the LB
|
252
264
|
// policy.
|
253
265
|
const char* ShouldDrop();
|
254
266
|
|
255
267
|
private:
|
256
268
|
std::vector<GrpcLbServer> serverlist_;
|
257
269
|
|
258
|
-
// Guarded by the channel's data plane
|
259
|
-
// plane
|
270
|
+
// Guarded by the channel's data plane mutex, NOT the control
|
271
|
+
// plane work_serializer. It should not be accessed by anything but the
|
260
272
|
// picker via the ShouldDrop() method.
|
261
273
|
size_t drop_index_ = 0;
|
262
274
|
};
|
@@ -295,9 +307,41 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
295
307
|
void UpdateState(grpc_connectivity_state state,
|
296
308
|
std::unique_ptr<SubchannelPicker> picker) override;
|
297
309
|
void RequestReresolution() override;
|
298
|
-
void AddTraceEvent(TraceSeverity severity,
|
310
|
+
void AddTraceEvent(TraceSeverity severity,
|
311
|
+
absl::string_view message) override;
|
312
|
+
|
313
|
+
private:
|
314
|
+
RefCountedPtr<GrpcLb> parent_;
|
315
|
+
};
|
316
|
+
|
317
|
+
class StateWatcher : public AsyncConnectivityStateWatcherInterface {
|
318
|
+
public:
|
319
|
+
explicit StateWatcher(RefCountedPtr<GrpcLb> parent)
|
320
|
+
: AsyncConnectivityStateWatcherInterface(parent->work_serializer()),
|
321
|
+
parent_(std::move(parent)) {}
|
322
|
+
|
323
|
+
~StateWatcher() { parent_.reset(DEBUG_LOCATION, "StateWatcher"); }
|
299
324
|
|
300
325
|
private:
|
326
|
+
void OnConnectivityStateChange(grpc_connectivity_state new_state) override {
|
327
|
+
if (parent_->fallback_at_startup_checks_pending_ &&
|
328
|
+
new_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
|
329
|
+
// In TRANSIENT_FAILURE. Cancel the fallback timer and go into
|
330
|
+
// fallback mode immediately.
|
331
|
+
gpr_log(GPR_INFO,
|
332
|
+
"[grpclb %p] balancer channel in state TRANSIENT_FAILURE; "
|
333
|
+
"entering fallback mode",
|
334
|
+
parent_.get());
|
335
|
+
parent_->fallback_at_startup_checks_pending_ = false;
|
336
|
+
grpc_timer_cancel(&parent_->lb_fallback_timer_);
|
337
|
+
parent_->fallback_mode_ = true;
|
338
|
+
parent_->CreateOrUpdateChildPolicyLocked();
|
339
|
+
// Cancel the watch, since we don't care about the channel state once we
|
340
|
+
// go into fallback mode.
|
341
|
+
parent_->CancelBalancerChannelConnectivityWatchLocked();
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
301
345
|
RefCountedPtr<GrpcLb> parent_;
|
302
346
|
};
|
303
347
|
|
@@ -308,22 +352,19 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
308
352
|
// Helper functions used in UpdateLocked().
|
309
353
|
void ProcessAddressesAndChannelArgsLocked(const ServerAddressList& addresses,
|
310
354
|
const grpc_channel_args& args);
|
311
|
-
|
312
|
-
grpc_error* error);
|
313
|
-
static void OnBalancerChannelConnectivityChangedLocked(void* arg,
|
314
|
-
grpc_error* error);
|
355
|
+
|
315
356
|
void CancelBalancerChannelConnectivityWatchLocked();
|
316
357
|
|
317
358
|
// Methods for dealing with fallback state.
|
318
359
|
void MaybeEnterFallbackModeAfterStartup();
|
319
360
|
static void OnFallbackTimer(void* arg, grpc_error* error);
|
320
|
-
|
361
|
+
void OnFallbackTimerLocked(grpc_error* error);
|
321
362
|
|
322
363
|
// Methods for dealing with the balancer call.
|
323
364
|
void StartBalancerCallLocked();
|
324
365
|
void StartBalancerCallRetryTimerLocked();
|
325
366
|
static void OnBalancerCallRetryTimer(void* arg, grpc_error* error);
|
326
|
-
|
367
|
+
void OnBalancerCallRetryTimerLocked(grpc_error* error);
|
327
368
|
|
328
369
|
// Methods for dealing with the child policy.
|
329
370
|
grpc_channel_args* CreateChildPolicyArgsLocked(
|
@@ -334,6 +375,8 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
334
375
|
|
335
376
|
// Who the client is trying to communicate with.
|
336
377
|
const char* server_name_ = nullptr;
|
378
|
+
// Configurations for the policy.
|
379
|
+
RefCountedPtr<GrpcLbConfig> config_;
|
337
380
|
|
338
381
|
// Current channel args from the resolver.
|
339
382
|
grpc_channel_args* args_ = nullptr;
|
@@ -343,6 +386,7 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
343
386
|
|
344
387
|
// The channel for communicating with the LB server.
|
345
388
|
grpc_channel* lb_channel_ = nullptr;
|
389
|
+
StateWatcher* watcher_ = nullptr;
|
346
390
|
// Response generator to inject address updates into lb_channel_.
|
347
391
|
RefCountedPtr<FakeResolverResponseGenerator> response_generator_;
|
348
392
|
|
@@ -375,13 +419,9 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
375
419
|
bool fallback_at_startup_checks_pending_ = false;
|
376
420
|
grpc_timer lb_fallback_timer_;
|
377
421
|
grpc_closure lb_on_fallback_;
|
378
|
-
grpc_connectivity_state lb_channel_connectivity_ = GRPC_CHANNEL_IDLE;
|
379
|
-
grpc_closure lb_channel_on_connectivity_changed_;
|
380
422
|
|
381
423
|
// The child policy to use for the backends.
|
382
424
|
OrphanablePtr<LoadBalancingPolicy> child_policy_;
|
383
|
-
// The child policy config.
|
384
|
-
RefCountedPtr<LoadBalancingPolicy::Config> child_policy_config_;
|
385
425
|
// Child policy in state READY.
|
386
426
|
bool child_policy_ready_ = false;
|
387
427
|
};
|
@@ -415,28 +455,22 @@ void ParseServer(const GrpcLbServer& server, grpc_resolved_address* addr) {
|
|
415
455
|
}
|
416
456
|
}
|
417
457
|
|
418
|
-
|
419
|
-
|
420
|
-
gpr_strvec_init(&entries);
|
458
|
+
std::string GrpcLb::Serverlist::AsText() const {
|
459
|
+
std::vector<std::string> entries;
|
421
460
|
for (size_t i = 0; i < serverlist_.size(); ++i) {
|
422
461
|
const GrpcLbServer& server = serverlist_[i];
|
423
|
-
|
462
|
+
std::string ipport;
|
424
463
|
if (server.drop) {
|
425
|
-
ipport =
|
464
|
+
ipport = "(drop)";
|
426
465
|
} else {
|
427
466
|
grpc_resolved_address addr;
|
428
467
|
ParseServer(server, &addr);
|
429
|
-
grpc_sockaddr_to_string(&
|
468
|
+
ipport = grpc_sockaddr_to_string(&addr, false);
|
430
469
|
}
|
431
|
-
|
432
|
-
|
433
|
-
server.load_balance_token);
|
434
|
-
gpr_free(ipport);
|
435
|
-
gpr_strvec_add(&entries, entry);
|
470
|
+
entries.push_back(absl::StrFormat(" %" PRIuPTR ": %s token=%s\n", i,
|
471
|
+
ipport, server.load_balance_token));
|
436
472
|
}
|
437
|
-
|
438
|
-
gpr_strvec_destroy(&entries);
|
439
|
-
return result;
|
473
|
+
return absl::StrJoin(entries, "");
|
440
474
|
}
|
441
475
|
|
442
476
|
// vtables for channel args for LB token and client stats.
|
@@ -519,16 +553,14 @@ ServerAddressList GrpcLb::Serverlist::GetServerAddressList(
|
|
519
553
|
memcpy(lb_token, server.load_balance_token, lb_token_length);
|
520
554
|
lb_token[lb_token_length] = '\0';
|
521
555
|
} else {
|
522
|
-
char* uri = grpc_sockaddr_to_uri(&addr);
|
523
556
|
gpr_log(GPR_INFO,
|
524
557
|
"Missing LB token for backend address '%s'. The empty token will "
|
525
558
|
"be used instead",
|
526
|
-
|
527
|
-
gpr_free(uri);
|
559
|
+
grpc_sockaddr_to_uri(&addr).c_str());
|
528
560
|
lb_token[0] = '\0';
|
529
561
|
}
|
530
562
|
// Add address.
|
531
|
-
InlinedVector<grpc_arg, 2> args_to_add;
|
563
|
+
absl::InlinedVector<grpc_arg, 2> args_to_add;
|
532
564
|
args_to_add.emplace_back(grpc_channel_arg_pointer_create(
|
533
565
|
const_cast<char*>(GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN), lb_token,
|
534
566
|
&lb_token_arg_vtable));
|
@@ -599,7 +631,7 @@ GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs args) {
|
|
599
631
|
// how to interpret it.
|
600
632
|
args.initial_metadata->Add(
|
601
633
|
kGrpcLbClientStatsMetadataKey,
|
602
|
-
|
634
|
+
absl::string_view(reinterpret_cast<const char*>(client_stats), 0));
|
603
635
|
// Update calls-started.
|
604
636
|
client_stats->AddCallStarted();
|
605
637
|
}
|
@@ -692,7 +724,8 @@ void GrpcLb::Helper::RequestReresolution() {
|
|
692
724
|
}
|
693
725
|
}
|
694
726
|
|
695
|
-
void GrpcLb::Helper::AddTraceEvent(TraceSeverity severity,
|
727
|
+
void GrpcLb::Helper::AddTraceEvent(TraceSeverity severity,
|
728
|
+
absl::string_view message) {
|
696
729
|
if (parent_->shutting_down_) return;
|
697
730
|
parent_->channel_control_helper()->AddTraceEvent(severity, message);
|
698
731
|
}
|
@@ -712,6 +745,15 @@ GrpcLb::BalancerCallState::BalancerCallState(
|
|
712
745
|
// the polling entities from client_channel.
|
713
746
|
GPR_ASSERT(grpclb_policy()->server_name_ != nullptr);
|
714
747
|
GPR_ASSERT(grpclb_policy()->server_name_[0] != '\0');
|
748
|
+
// Closure Initialization
|
749
|
+
GRPC_CLOSURE_INIT(&lb_on_initial_request_sent_, OnInitialRequestSent, this,
|
750
|
+
grpc_schedule_on_exec_ctx);
|
751
|
+
GRPC_CLOSURE_INIT(&lb_on_balancer_message_received_,
|
752
|
+
OnBalancerMessageReceived, this, grpc_schedule_on_exec_ctx);
|
753
|
+
GRPC_CLOSURE_INIT(&lb_on_balancer_status_received_, OnBalancerStatusReceived,
|
754
|
+
this, grpc_schedule_on_exec_ctx);
|
755
|
+
GRPC_CLOSURE_INIT(&client_load_report_closure_, MaybeSendClientLoadReport,
|
756
|
+
this, grpc_schedule_on_exec_ctx);
|
715
757
|
const grpc_millis deadline =
|
716
758
|
grpclb_policy()->lb_call_timeout_ms_ == 0
|
717
759
|
? GRPC_MILLIS_INF_FUTURE
|
@@ -723,8 +765,11 @@ GrpcLb::BalancerCallState::BalancerCallState(
|
|
723
765
|
nullptr, deadline, nullptr);
|
724
766
|
// Init the LB call request payload.
|
725
767
|
upb::Arena arena;
|
726
|
-
grpc_slice request_payload_slice =
|
727
|
-
|
768
|
+
grpc_slice request_payload_slice = GrpcLbRequestCreate(
|
769
|
+
grpclb_policy()->config_->service_name().empty()
|
770
|
+
? grpclb_policy()->server_name_
|
771
|
+
: grpclb_policy()->config_->service_name().c_str(),
|
772
|
+
arena.ptr());
|
728
773
|
send_message_payload_ =
|
729
774
|
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
|
730
775
|
grpc_slice_unref_internal(request_payload_slice);
|
@@ -788,8 +833,6 @@ void GrpcLb::BalancerCallState::StartQuery() {
|
|
788
833
|
// with the callback.
|
789
834
|
auto self = Ref(DEBUG_LOCATION, "on_initial_request_sent");
|
790
835
|
self.release();
|
791
|
-
GRPC_CLOSURE_INIT(&lb_on_initial_request_sent_, OnInitialRequestSent, this,
|
792
|
-
grpc_schedule_on_exec_ctx);
|
793
836
|
call_error = grpc_call_start_batch_and_execute(
|
794
837
|
lb_call_, ops, (size_t)(op - ops), &lb_on_initial_request_sent_);
|
795
838
|
GPR_ASSERT(GRPC_CALL_OK == call_error);
|
@@ -812,8 +855,6 @@ void GrpcLb::BalancerCallState::StartQuery() {
|
|
812
855
|
// with the callback.
|
813
856
|
self = Ref(DEBUG_LOCATION, "on_message_received");
|
814
857
|
self.release();
|
815
|
-
GRPC_CLOSURE_INIT(&lb_on_balancer_message_received_,
|
816
|
-
OnBalancerMessageReceived, this, grpc_schedule_on_exec_ctx);
|
817
858
|
call_error = grpc_call_start_batch_and_execute(
|
818
859
|
lb_call_, ops, (size_t)(op - ops), &lb_on_balancer_message_received_);
|
819
860
|
GPR_ASSERT(GRPC_CALL_OK == call_error);
|
@@ -830,8 +871,6 @@ void GrpcLb::BalancerCallState::StartQuery() {
|
|
830
871
|
// This callback signals the end of the LB call, so it relies on the initial
|
831
872
|
// ref instead of a new ref. When it's invoked, it's the initial ref that is
|
832
873
|
// unreffed.
|
833
|
-
GRPC_CLOSURE_INIT(&lb_on_balancer_status_received_, OnBalancerStatusReceived,
|
834
|
-
this, grpc_schedule_on_exec_ctx);
|
835
874
|
call_error = grpc_call_start_batch_and_execute(
|
836
875
|
lb_call_, ops, (size_t)(op - ops), &lb_on_balancer_status_received_);
|
837
876
|
GPR_ASSERT(GRPC_CALL_OK == call_error);
|
@@ -850,28 +889,27 @@ void GrpcLb::BalancerCallState::ScheduleNextClientLoadReportLocked() {
|
|
850
889
|
void GrpcLb::BalancerCallState::MaybeSendClientLoadReport(void* arg,
|
851
890
|
grpc_error* error) {
|
852
891
|
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
892
|
+
GRPC_ERROR_REF(error); // ref owned by lambda
|
893
|
+
lb_calld->grpclb_policy()->work_serializer()->Run(
|
894
|
+
[lb_calld, error]() { lb_calld->MaybeSendClientLoadReportLocked(error); },
|
895
|
+
DEBUG_LOCATION);
|
857
896
|
}
|
858
897
|
|
859
898
|
void GrpcLb::BalancerCallState::MaybeSendClientLoadReportLocked(
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
lb_calld->Unref(DEBUG_LOCATION, "client_load_report");
|
899
|
+
grpc_error* error) {
|
900
|
+
client_load_report_timer_callback_pending_ = false;
|
901
|
+
if (error != GRPC_ERROR_NONE || this != grpclb_policy()->lb_calld_.get()) {
|
902
|
+
Unref(DEBUG_LOCATION, "client_load_report");
|
903
|
+
GRPC_ERROR_UNREF(error);
|
866
904
|
return;
|
867
905
|
}
|
868
906
|
// If we've already sent the initial request, then we can go ahead and send
|
869
907
|
// the load report. Otherwise, we need to wait until the initial request has
|
870
908
|
// been sent to send this (see OnInitialRequestSentLocked()).
|
871
|
-
if (
|
872
|
-
|
909
|
+
if (send_message_payload_ == nullptr) {
|
910
|
+
SendClientLoadReportLocked();
|
873
911
|
} else {
|
874
|
-
|
912
|
+
client_load_report_is_due_ = true;
|
875
913
|
}
|
876
914
|
}
|
877
915
|
|
@@ -930,140 +968,125 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
|
|
930
968
|
void GrpcLb::BalancerCallState::ClientLoadReportDone(void* arg,
|
931
969
|
grpc_error* error) {
|
932
970
|
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
971
|
+
GRPC_ERROR_REF(error); // ref owned by lambda
|
972
|
+
lb_calld->grpclb_policy()->work_serializer()->Run(
|
973
|
+
[lb_calld, error]() { lb_calld->ClientLoadReportDoneLocked(error); },
|
974
|
+
DEBUG_LOCATION);
|
937
975
|
}
|
938
976
|
|
939
|
-
void GrpcLb::BalancerCallState::ClientLoadReportDoneLocked(
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
if (error != GRPC_ERROR_NONE || lb_calld != grpclb_policy->lb_calld_.get()) {
|
946
|
-
lb_calld->Unref(DEBUG_LOCATION, "client_load_report");
|
977
|
+
void GrpcLb::BalancerCallState::ClientLoadReportDoneLocked(grpc_error* error) {
|
978
|
+
grpc_byte_buffer_destroy(send_message_payload_);
|
979
|
+
send_message_payload_ = nullptr;
|
980
|
+
if (error != GRPC_ERROR_NONE || this != grpclb_policy()->lb_calld_.get()) {
|
981
|
+
Unref(DEBUG_LOCATION, "client_load_report");
|
982
|
+
GRPC_ERROR_UNREF(error);
|
947
983
|
return;
|
948
984
|
}
|
949
|
-
|
985
|
+
ScheduleNextClientLoadReportLocked();
|
950
986
|
}
|
951
987
|
|
952
988
|
void GrpcLb::BalancerCallState::OnInitialRequestSent(void* arg,
|
953
|
-
grpc_error* error) {
|
989
|
+
grpc_error* /*error*/) {
|
954
990
|
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
|
955
|
-
lb_calld->grpclb_policy()->
|
956
|
-
|
957
|
-
OnInitialRequestSentLocked, lb_calld, nullptr),
|
958
|
-
GRPC_ERROR_REF(error));
|
991
|
+
lb_calld->grpclb_policy()->work_serializer()->Run(
|
992
|
+
[lb_calld]() { lb_calld->OnInitialRequestSentLocked(); }, DEBUG_LOCATION);
|
959
993
|
}
|
960
994
|
|
961
|
-
void GrpcLb::BalancerCallState::OnInitialRequestSentLocked(
|
962
|
-
|
963
|
-
|
964
|
-
grpc_byte_buffer_destroy(lb_calld->send_message_payload_);
|
965
|
-
lb_calld->send_message_payload_ = nullptr;
|
995
|
+
void GrpcLb::BalancerCallState::OnInitialRequestSentLocked() {
|
996
|
+
grpc_byte_buffer_destroy(send_message_payload_);
|
997
|
+
send_message_payload_ = nullptr;
|
966
998
|
// If we attempted to send a client load report before the initial request was
|
967
999
|
// sent (and this lb_calld is still in use), send the load report now.
|
968
|
-
if (
|
969
|
-
|
970
|
-
|
971
|
-
lb_calld->client_load_report_is_due_ = false;
|
1000
|
+
if (client_load_report_is_due_ && this == grpclb_policy()->lb_calld_.get()) {
|
1001
|
+
SendClientLoadReportLocked();
|
1002
|
+
client_load_report_is_due_ = false;
|
972
1003
|
}
|
973
|
-
|
1004
|
+
Unref(DEBUG_LOCATION, "on_initial_request_sent");
|
974
1005
|
}
|
975
1006
|
|
976
|
-
void GrpcLb::BalancerCallState::OnBalancerMessageReceived(
|
977
|
-
|
1007
|
+
void GrpcLb::BalancerCallState::OnBalancerMessageReceived(
|
1008
|
+
void* arg, grpc_error* /*error*/) {
|
978
1009
|
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
|
979
|
-
lb_calld->grpclb_policy()->
|
980
|
-
|
981
|
-
|
982
|
-
GRPC_ERROR_REF(error));
|
1010
|
+
lb_calld->grpclb_policy()->work_serializer()->Run(
|
1011
|
+
[lb_calld]() { lb_calld->OnBalancerMessageReceivedLocked(); },
|
1012
|
+
DEBUG_LOCATION);
|
983
1013
|
}
|
984
1014
|
|
985
|
-
void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
|
986
|
-
void* arg, grpc_error* /*error*/) {
|
987
|
-
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
|
988
|
-
GrpcLb* grpclb_policy = lb_calld->grpclb_policy();
|
1015
|
+
void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked() {
|
989
1016
|
// Null payload means the LB call was cancelled.
|
990
|
-
if (
|
991
|
-
|
992
|
-
|
1017
|
+
if (this != grpclb_policy()->lb_calld_.get() ||
|
1018
|
+
recv_message_payload_ == nullptr) {
|
1019
|
+
Unref(DEBUG_LOCATION, "on_message_received");
|
993
1020
|
return;
|
994
1021
|
}
|
995
1022
|
grpc_byte_buffer_reader bbr;
|
996
|
-
grpc_byte_buffer_reader_init(&bbr,
|
1023
|
+
grpc_byte_buffer_reader_init(&bbr, recv_message_payload_);
|
997
1024
|
grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr);
|
998
1025
|
grpc_byte_buffer_reader_destroy(&bbr);
|
999
|
-
grpc_byte_buffer_destroy(
|
1000
|
-
|
1026
|
+
grpc_byte_buffer_destroy(recv_message_payload_);
|
1027
|
+
recv_message_payload_ = nullptr;
|
1001
1028
|
GrpcLbResponse response;
|
1002
1029
|
upb::Arena arena;
|
1003
1030
|
if (!GrpcLbResponseParse(response_slice, arena.ptr(), &response) ||
|
1004
|
-
(response.type == response.INITIAL &&
|
1031
|
+
(response.type == response.INITIAL && seen_initial_response_)) {
|
1005
1032
|
char* response_slice_str =
|
1006
1033
|
grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX);
|
1007
1034
|
gpr_log(GPR_ERROR,
|
1008
1035
|
"[grpclb %p] lb_calld=%p: Invalid LB response received: '%s'. "
|
1009
1036
|
"Ignoring.",
|
1010
|
-
grpclb_policy,
|
1037
|
+
grpclb_policy(), this, response_slice_str);
|
1011
1038
|
gpr_free(response_slice_str);
|
1012
1039
|
} else {
|
1013
1040
|
switch (response.type) {
|
1014
1041
|
case response.INITIAL: {
|
1015
1042
|
if (response.client_stats_report_interval != 0) {
|
1016
|
-
|
1043
|
+
client_stats_report_interval_ =
|
1017
1044
|
GPR_MAX(GPR_MS_PER_SEC, response.client_stats_report_interval);
|
1018
1045
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1019
1046
|
gpr_log(GPR_INFO,
|
1020
1047
|
"[grpclb %p] lb_calld=%p: Received initial LB response "
|
1021
1048
|
"message; client load reporting interval = %" PRId64
|
1022
1049
|
" milliseconds",
|
1023
|
-
grpclb_policy,
|
1024
|
-
lb_calld->client_stats_report_interval_);
|
1050
|
+
grpclb_policy(), this, client_stats_report_interval_);
|
1025
1051
|
}
|
1026
1052
|
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1027
1053
|
gpr_log(GPR_INFO,
|
1028
1054
|
"[grpclb %p] lb_calld=%p: Received initial LB response "
|
1029
1055
|
"message; client load reporting NOT enabled",
|
1030
|
-
grpclb_policy,
|
1056
|
+
grpclb_policy(), this);
|
1031
1057
|
}
|
1032
|
-
|
1058
|
+
seen_initial_response_ = true;
|
1033
1059
|
break;
|
1034
1060
|
}
|
1035
1061
|
case response.SERVERLIST: {
|
1036
|
-
GPR_ASSERT(
|
1062
|
+
GPR_ASSERT(lb_call_ != nullptr);
|
1037
1063
|
auto serverlist_wrapper =
|
1038
1064
|
MakeRefCounted<Serverlist>(std::move(response.serverlist));
|
1039
1065
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1040
|
-
grpc_core::UniquePtr<char> serverlist_text =
|
1041
|
-
serverlist_wrapper->AsText();
|
1042
1066
|
gpr_log(GPR_INFO,
|
1043
1067
|
"[grpclb %p] lb_calld=%p: Serverlist with %" PRIuPTR
|
1044
1068
|
" servers received:\n%s",
|
1045
|
-
grpclb_policy,
|
1069
|
+
grpclb_policy(), this,
|
1046
1070
|
serverlist_wrapper->serverlist().size(),
|
1047
|
-
|
1071
|
+
serverlist_wrapper->AsText().c_str());
|
1048
1072
|
}
|
1049
|
-
|
1073
|
+
seen_serverlist_ = true;
|
1050
1074
|
// Start sending client load report only after we start using the
|
1051
1075
|
// serverlist returned from the current LB call.
|
1052
|
-
if (
|
1053
|
-
|
1054
|
-
lb_calld->client_stats_ = MakeRefCounted<GrpcLbClientStats>();
|
1076
|
+
if (client_stats_report_interval_ > 0 && client_stats_ == nullptr) {
|
1077
|
+
client_stats_ = MakeRefCounted<GrpcLbClientStats>();
|
1055
1078
|
// Ref held by callback.
|
1056
|
-
|
1057
|
-
|
1079
|
+
Ref(DEBUG_LOCATION, "client_load_report").release();
|
1080
|
+
ScheduleNextClientLoadReportLocked();
|
1058
1081
|
}
|
1059
1082
|
// Check if the serverlist differs from the previous one.
|
1060
|
-
if (grpclb_policy->serverlist_ != nullptr &&
|
1061
|
-
*grpclb_policy->serverlist_ == *serverlist_wrapper) {
|
1083
|
+
if (grpclb_policy()->serverlist_ != nullptr &&
|
1084
|
+
*grpclb_policy()->serverlist_ == *serverlist_wrapper) {
|
1062
1085
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1063
1086
|
gpr_log(GPR_INFO,
|
1064
1087
|
"[grpclb %p] lb_calld=%p: Incoming server list identical "
|
1065
1088
|
"to current, ignoring.",
|
1066
|
-
grpclb_policy,
|
1089
|
+
grpclb_policy(), this);
|
1067
1090
|
}
|
1068
1091
|
} else { // New serverlist.
|
1069
1092
|
// Dispose of the fallback.
|
@@ -1085,155 +1108,135 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
|
|
1085
1108
|
// the grpclb implementation at this point, since we're deprecating
|
1086
1109
|
// it in favor of the xds policy. We will implement this the
|
1087
1110
|
// right way in the xds policy instead.
|
1088
|
-
if (grpclb_policy->fallback_mode_) {
|
1111
|
+
if (grpclb_policy()->fallback_mode_) {
|
1089
1112
|
gpr_log(GPR_INFO,
|
1090
1113
|
"[grpclb %p] Received response from balancer; exiting "
|
1091
1114
|
"fallback mode",
|
1092
|
-
grpclb_policy);
|
1093
|
-
grpclb_policy->fallback_mode_ = false;
|
1115
|
+
grpclb_policy());
|
1116
|
+
grpclb_policy()->fallback_mode_ = false;
|
1094
1117
|
}
|
1095
|
-
if (grpclb_policy->fallback_at_startup_checks_pending_) {
|
1096
|
-
grpclb_policy->fallback_at_startup_checks_pending_ = false;
|
1097
|
-
grpc_timer_cancel(&grpclb_policy->lb_fallback_timer_);
|
1098
|
-
grpclb_policy->CancelBalancerChannelConnectivityWatchLocked();
|
1118
|
+
if (grpclb_policy()->fallback_at_startup_checks_pending_) {
|
1119
|
+
grpclb_policy()->fallback_at_startup_checks_pending_ = false;
|
1120
|
+
grpc_timer_cancel(&grpclb_policy()->lb_fallback_timer_);
|
1121
|
+
grpclb_policy()->CancelBalancerChannelConnectivityWatchLocked();
|
1099
1122
|
}
|
1100
1123
|
// Update the serverlist in the GrpcLb instance. This serverlist
|
1101
1124
|
// instance will be destroyed either upon the next update or when the
|
1102
1125
|
// GrpcLb instance is destroyed.
|
1103
|
-
grpclb_policy->serverlist_ = std::move(serverlist_wrapper);
|
1104
|
-
grpclb_policy->CreateOrUpdateChildPolicyLocked();
|
1126
|
+
grpclb_policy()->serverlist_ = std::move(serverlist_wrapper);
|
1127
|
+
grpclb_policy()->CreateOrUpdateChildPolicyLocked();
|
1105
1128
|
}
|
1106
1129
|
break;
|
1107
1130
|
}
|
1108
1131
|
case response.FALLBACK: {
|
1109
|
-
if (!grpclb_policy->fallback_mode_) {
|
1132
|
+
if (!grpclb_policy()->fallback_mode_) {
|
1110
1133
|
gpr_log(GPR_INFO,
|
1111
1134
|
"[grpclb %p] Entering fallback mode as requested by balancer",
|
1112
|
-
grpclb_policy);
|
1113
|
-
if (grpclb_policy->fallback_at_startup_checks_pending_) {
|
1114
|
-
grpclb_policy->fallback_at_startup_checks_pending_ = false;
|
1115
|
-
grpc_timer_cancel(&grpclb_policy->lb_fallback_timer_);
|
1116
|
-
grpclb_policy->CancelBalancerChannelConnectivityWatchLocked();
|
1135
|
+
grpclb_policy());
|
1136
|
+
if (grpclb_policy()->fallback_at_startup_checks_pending_) {
|
1137
|
+
grpclb_policy()->fallback_at_startup_checks_pending_ = false;
|
1138
|
+
grpc_timer_cancel(&grpclb_policy()->lb_fallback_timer_);
|
1139
|
+
grpclb_policy()->CancelBalancerChannelConnectivityWatchLocked();
|
1117
1140
|
}
|
1118
|
-
grpclb_policy->fallback_mode_ = true;
|
1119
|
-
grpclb_policy->CreateOrUpdateChildPolicyLocked();
|
1141
|
+
grpclb_policy()->fallback_mode_ = true;
|
1142
|
+
grpclb_policy()->CreateOrUpdateChildPolicyLocked();
|
1120
1143
|
// Reset serverlist, so that if the balancer exits fallback
|
1121
1144
|
// mode by sending the same serverlist we were previously
|
1122
1145
|
// using, we don't incorrectly ignore it as a duplicate.
|
1123
|
-
grpclb_policy->serverlist_.reset();
|
1146
|
+
grpclb_policy()->serverlist_.reset();
|
1124
1147
|
}
|
1125
1148
|
break;
|
1126
1149
|
}
|
1127
1150
|
}
|
1128
1151
|
}
|
1129
1152
|
grpc_slice_unref_internal(response_slice);
|
1130
|
-
if (!grpclb_policy->shutting_down_) {
|
1153
|
+
if (!grpclb_policy()->shutting_down_) {
|
1131
1154
|
// Keep listening for serverlist updates.
|
1132
1155
|
grpc_op op;
|
1133
1156
|
memset(&op, 0, sizeof(op));
|
1134
1157
|
op.op = GRPC_OP_RECV_MESSAGE;
|
1135
|
-
op.data.recv_message.recv_message = &
|
1158
|
+
op.data.recv_message.recv_message = &recv_message_payload_;
|
1136
1159
|
op.flags = 0;
|
1137
1160
|
op.reserved = nullptr;
|
1138
1161
|
// Reuse the "OnBalancerMessageReceivedLocked" ref taken in StartQuery().
|
1139
|
-
GRPC_CLOSURE_INIT(&lb_calld->lb_on_balancer_message_received_,
|
1140
|
-
GrpcLb::BalancerCallState::OnBalancerMessageReceived,
|
1141
|
-
lb_calld, grpc_schedule_on_exec_ctx);
|
1142
1162
|
const grpc_call_error call_error = grpc_call_start_batch_and_execute(
|
1143
|
-
|
1144
|
-
&lb_calld->lb_on_balancer_message_received_);
|
1163
|
+
lb_call_, &op, 1, &lb_on_balancer_message_received_);
|
1145
1164
|
GPR_ASSERT(GRPC_CALL_OK == call_error);
|
1146
1165
|
} else {
|
1147
|
-
|
1166
|
+
Unref(DEBUG_LOCATION, "on_message_received+grpclb_shutdown");
|
1148
1167
|
}
|
1149
1168
|
}
|
1150
1169
|
|
1151
1170
|
void GrpcLb::BalancerCallState::OnBalancerStatusReceived(void* arg,
|
1152
1171
|
grpc_error* error) {
|
1153
1172
|
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1173
|
+
GRPC_ERROR_REF(error); // owned by lambda
|
1174
|
+
lb_calld->grpclb_policy()->work_serializer()->Run(
|
1175
|
+
[lb_calld, error]() { lb_calld->OnBalancerStatusReceivedLocked(error); },
|
1176
|
+
DEBUG_LOCATION);
|
1158
1177
|
}
|
1159
1178
|
|
1160
1179
|
void GrpcLb::BalancerCallState::OnBalancerStatusReceivedLocked(
|
1161
|
-
|
1162
|
-
|
1163
|
-
GrpcLb* grpclb_policy = lb_calld->grpclb_policy();
|
1164
|
-
GPR_ASSERT(lb_calld->lb_call_ != nullptr);
|
1180
|
+
grpc_error* error) {
|
1181
|
+
GPR_ASSERT(lb_call_ != nullptr);
|
1165
1182
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1166
|
-
char* status_details =
|
1167
|
-
grpc_slice_to_c_string(lb_calld->lb_call_status_details_);
|
1183
|
+
char* status_details = grpc_slice_to_c_string(lb_call_status_details_);
|
1168
1184
|
gpr_log(GPR_INFO,
|
1169
1185
|
"[grpclb %p] lb_calld=%p: Status from LB server received. "
|
1170
1186
|
"Status = %d, details = '%s', (lb_call: %p), error '%s'",
|
1171
|
-
grpclb_policy,
|
1172
|
-
|
1187
|
+
grpclb_policy(), this, lb_call_status_, status_details, lb_call_,
|
1188
|
+
grpc_error_string(error));
|
1173
1189
|
gpr_free(status_details);
|
1174
1190
|
}
|
1191
|
+
GRPC_ERROR_UNREF(error);
|
1175
1192
|
// If this lb_calld is still in use, this call ended because of a failure so
|
1176
1193
|
// we want to retry connecting. Otherwise, we have deliberately ended this
|
1177
1194
|
// call and no further action is required.
|
1178
|
-
if (
|
1195
|
+
if (this == grpclb_policy()->lb_calld_.get()) {
|
1179
1196
|
// If the fallback-at-startup checks are pending, go into fallback mode
|
1180
1197
|
// immediately. This short-circuits the timeout for the fallback-at-startup
|
1181
1198
|
// case.
|
1182
|
-
if (grpclb_policy->fallback_at_startup_checks_pending_) {
|
1183
|
-
GPR_ASSERT(!
|
1199
|
+
if (grpclb_policy()->fallback_at_startup_checks_pending_) {
|
1200
|
+
GPR_ASSERT(!seen_serverlist_);
|
1184
1201
|
gpr_log(GPR_INFO,
|
1185
1202
|
"[grpclb %p] Balancer call finished without receiving "
|
1186
1203
|
"serverlist; entering fallback mode",
|
1187
|
-
grpclb_policy);
|
1188
|
-
grpclb_policy->fallback_at_startup_checks_pending_ = false;
|
1189
|
-
grpc_timer_cancel(&grpclb_policy->lb_fallback_timer_);
|
1190
|
-
grpclb_policy->CancelBalancerChannelConnectivityWatchLocked();
|
1191
|
-
grpclb_policy->fallback_mode_ = true;
|
1192
|
-
grpclb_policy->CreateOrUpdateChildPolicyLocked();
|
1204
|
+
grpclb_policy());
|
1205
|
+
grpclb_policy()->fallback_at_startup_checks_pending_ = false;
|
1206
|
+
grpc_timer_cancel(&grpclb_policy()->lb_fallback_timer_);
|
1207
|
+
grpclb_policy()->CancelBalancerChannelConnectivityWatchLocked();
|
1208
|
+
grpclb_policy()->fallback_mode_ = true;
|
1209
|
+
grpclb_policy()->CreateOrUpdateChildPolicyLocked();
|
1193
1210
|
} else {
|
1194
1211
|
// This handles the fallback-after-startup case.
|
1195
|
-
grpclb_policy->MaybeEnterFallbackModeAfterStartup();
|
1212
|
+
grpclb_policy()->MaybeEnterFallbackModeAfterStartup();
|
1196
1213
|
}
|
1197
|
-
grpclb_policy->lb_calld_.reset();
|
1198
|
-
GPR_ASSERT(!grpclb_policy->shutting_down_);
|
1199
|
-
grpclb_policy->channel_control_helper()->RequestReresolution();
|
1200
|
-
if (
|
1214
|
+
grpclb_policy()->lb_calld_.reset();
|
1215
|
+
GPR_ASSERT(!grpclb_policy()->shutting_down_);
|
1216
|
+
grpclb_policy()->channel_control_helper()->RequestReresolution();
|
1217
|
+
if (seen_initial_response_) {
|
1201
1218
|
// If we lose connection to the LB server, reset the backoff and restart
|
1202
1219
|
// the LB call immediately.
|
1203
|
-
grpclb_policy->lb_call_backoff_.Reset();
|
1204
|
-
grpclb_policy->StartBalancerCallLocked();
|
1220
|
+
grpclb_policy()->lb_call_backoff_.Reset();
|
1221
|
+
grpclb_policy()->StartBalancerCallLocked();
|
1205
1222
|
} else {
|
1206
1223
|
// If this LB call fails establishing any connection to the LB server,
|
1207
1224
|
// retry later.
|
1208
|
-
grpclb_policy->StartBalancerCallRetryTimerLocked();
|
1225
|
+
grpclb_policy()->StartBalancerCallRetryTimerLocked();
|
1209
1226
|
}
|
1210
1227
|
}
|
1211
|
-
|
1228
|
+
Unref(DEBUG_LOCATION, "lb_call_ended");
|
1212
1229
|
}
|
1213
1230
|
|
1214
1231
|
//
|
1215
1232
|
// helper code for creating balancer channel
|
1216
1233
|
//
|
1217
1234
|
|
1218
|
-
ServerAddressList ExtractBalancerAddresses(const
|
1219
|
-
ServerAddressList
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
// recursively use the grpclb policy in the channel used to talk to
|
1224
|
-
// the balancers. Note that we do NOT strip out the balancer_name
|
1225
|
-
// channel arg, since we need that to set the authority correctly
|
1226
|
-
// to talk to the balancers.
|
1227
|
-
static const char* args_to_remove[] = {
|
1228
|
-
GRPC_ARG_ADDRESS_IS_BALANCER,
|
1229
|
-
};
|
1230
|
-
balancer_addresses.emplace_back(
|
1231
|
-
addresses[i].address(),
|
1232
|
-
grpc_channel_args_copy_and_remove(addresses[i].args(), args_to_remove,
|
1233
|
-
GPR_ARRAY_SIZE(args_to_remove)));
|
1234
|
-
}
|
1235
|
-
}
|
1236
|
-
return balancer_addresses;
|
1235
|
+
ServerAddressList ExtractBalancerAddresses(const grpc_channel_args& args) {
|
1236
|
+
const ServerAddressList* addresses =
|
1237
|
+
FindGrpclbBalancerAddressesInChannelArgs(args);
|
1238
|
+
if (addresses != nullptr) return *addresses;
|
1239
|
+
return ServerAddressList();
|
1237
1240
|
}
|
1238
1241
|
|
1239
1242
|
/* Returns the channel args for the LB channel, used to create a bidirectional
|
@@ -1277,7 +1280,7 @@ grpc_channel_args* BuildBalancerChannelArgs(
|
|
1277
1280
|
GRPC_ARG_CHANNELZ_CHANNEL_NODE,
|
1278
1281
|
};
|
1279
1282
|
// Channel args to add.
|
1280
|
-
InlinedVector<grpc_arg, 3> args_to_add;
|
1283
|
+
absl::InlinedVector<grpc_arg, 3> args_to_add;
|
1281
1284
|
// The fake resolver response generator, which we use to inject
|
1282
1285
|
// address updates into the LB channel.
|
1283
1286
|
args_to_add.emplace_back(
|
@@ -1319,6 +1322,11 @@ GrpcLb::GrpcLb(Args args)
|
|
1319
1322
|
.set_jitter(GRPC_GRPCLB_RECONNECT_JITTER)
|
1320
1323
|
.set_max_backoff(GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS *
|
1321
1324
|
1000)) {
|
1325
|
+
// Closure Initialization
|
1326
|
+
GRPC_CLOSURE_INIT(&lb_on_fallback_, &GrpcLb::OnFallbackTimer, this,
|
1327
|
+
grpc_schedule_on_exec_ctx);
|
1328
|
+
GRPC_CLOSURE_INIT(&lb_on_call_retry_, &GrpcLb::OnBalancerCallRetryTimer, this,
|
1329
|
+
grpc_schedule_on_exec_ctx);
|
1322
1330
|
// Record server name.
|
1323
1331
|
const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI);
|
1324
1332
|
const char* server_uri = grpc_channel_arg_get_string(arg);
|
@@ -1353,6 +1361,7 @@ void GrpcLb::ShutdownLocked() {
|
|
1353
1361
|
grpc_timer_cancel(&lb_call_retry_timer_);
|
1354
1362
|
}
|
1355
1363
|
if (fallback_at_startup_checks_pending_) {
|
1364
|
+
fallback_at_startup_checks_pending_ = false;
|
1356
1365
|
grpc_timer_cancel(&lb_fallback_timer_);
|
1357
1366
|
CancelBalancerChannelConnectivityWatchLocked();
|
1358
1367
|
}
|
@@ -1386,12 +1395,8 @@ void GrpcLb::ResetBackoffLocked() {
|
|
1386
1395
|
|
1387
1396
|
void GrpcLb::UpdateLocked(UpdateArgs args) {
|
1388
1397
|
const bool is_initial_update = lb_channel_ == nullptr;
|
1389
|
-
|
1390
|
-
|
1391
|
-
child_policy_config_ = grpclb_config->child_policy();
|
1392
|
-
} else {
|
1393
|
-
child_policy_config_ = nullptr;
|
1394
|
-
}
|
1398
|
+
config_ = args.config;
|
1399
|
+
GPR_ASSERT(config_ != nullptr);
|
1395
1400
|
ProcessAddressesAndChannelArgsLocked(args.addresses, *args.args);
|
1396
1401
|
// Update the existing child policy.
|
1397
1402
|
if (child_policy_ != nullptr) CreateOrUpdateChildPolicyLocked();
|
@@ -1402,8 +1407,6 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1402
1407
|
// Start timer.
|
1403
1408
|
grpc_millis deadline = ExecCtx::Get()->Now() + fallback_at_startup_timeout_;
|
1404
1409
|
Ref(DEBUG_LOCATION, "on_fallback_timer").release(); // Ref for callback
|
1405
|
-
GRPC_CLOSURE_INIT(&lb_on_fallback_, &GrpcLb::OnFallbackTimer, this,
|
1406
|
-
grpc_schedule_on_exec_ctx);
|
1407
1410
|
grpc_timer_init(&lb_fallback_timer_, deadline, &lb_on_fallback_);
|
1408
1411
|
// Start watching the channel's connectivity state. If the channel
|
1409
1412
|
// goes into state TRANSIENT_FAILURE before the timer fires, we go into
|
@@ -1412,15 +1415,10 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1412
1415
|
grpc_channel_get_channel_stack(lb_channel_));
|
1413
1416
|
GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
|
1414
1417
|
// Ref held by callback.
|
1415
|
-
Ref(DEBUG_LOCATION, "
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
grpc_client_channel_watch_connectivity_state(
|
1420
|
-
client_channel_elem,
|
1421
|
-
grpc_polling_entity_create_from_pollset_set(interested_parties()),
|
1422
|
-
&lb_channel_connectivity_, &lb_channel_on_connectivity_changed_,
|
1423
|
-
nullptr);
|
1418
|
+
watcher_ = new StateWatcher(Ref(DEBUG_LOCATION, "StateWatcher"));
|
1419
|
+
grpc_client_channel_start_connectivity_watch(
|
1420
|
+
client_channel_elem, GRPC_CHANNEL_IDLE,
|
1421
|
+
OrphanablePtr<AsyncConnectivityStateWatcherInterface>(watcher_));
|
1424
1422
|
// Start balancer call.
|
1425
1423
|
StartBalancerCallLocked();
|
1426
1424
|
}
|
@@ -1430,27 +1428,25 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1430
1428
|
// helpers for UpdateLocked()
|
1431
1429
|
//
|
1432
1430
|
|
1433
|
-
|
1434
|
-
|
1431
|
+
ServerAddressList AddNullLbTokenToAddresses(
|
1432
|
+
const ServerAddressList& addresses) {
|
1435
1433
|
static const char* lb_token = "";
|
1436
1434
|
grpc_arg arg = grpc_channel_arg_pointer_create(
|
1437
1435
|
const_cast<char*>(GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN),
|
1438
1436
|
const_cast<char*>(lb_token), &lb_token_arg_vtable);
|
1439
|
-
ServerAddressList
|
1437
|
+
ServerAddressList addresses_out;
|
1440
1438
|
for (size_t i = 0; i < addresses.size(); ++i) {
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
grpc_channel_args_copy_and_add(addresses[i].args(), &arg, 1));
|
1445
|
-
}
|
1439
|
+
addresses_out.emplace_back(
|
1440
|
+
addresses[i].address(),
|
1441
|
+
grpc_channel_args_copy_and_add(addresses[i].args(), &arg, 1));
|
1446
1442
|
}
|
1447
|
-
return
|
1443
|
+
return addresses_out;
|
1448
1444
|
}
|
1449
1445
|
|
1450
1446
|
void GrpcLb::ProcessAddressesAndChannelArgsLocked(
|
1451
1447
|
const ServerAddressList& addresses, const grpc_channel_args& args) {
|
1452
1448
|
// Update fallback address list.
|
1453
|
-
fallback_backend_addresses_ =
|
1449
|
+
fallback_backend_addresses_ = AddNullLbTokenToAddresses(addresses);
|
1454
1450
|
// Make sure that GRPC_ARG_LB_POLICY_NAME is set in channel args,
|
1455
1451
|
// since we use this to trigger the client_load_reporting filter.
|
1456
1452
|
static const char* args_to_remove[] = {GRPC_ARG_LB_POLICY_NAME};
|
@@ -1460,16 +1456,15 @@ void GrpcLb::ProcessAddressesAndChannelArgsLocked(
|
|
1460
1456
|
args_ = grpc_channel_args_copy_and_add_and_remove(
|
1461
1457
|
&args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &new_arg, 1);
|
1462
1458
|
// Construct args for balancer channel.
|
1463
|
-
ServerAddressList balancer_addresses = ExtractBalancerAddresses(
|
1459
|
+
ServerAddressList balancer_addresses = ExtractBalancerAddresses(args);
|
1464
1460
|
grpc_channel_args* lb_channel_args = BuildBalancerChannelArgs(
|
1465
1461
|
balancer_addresses, response_generator_.get(), &args);
|
1466
1462
|
// Create balancer channel if needed.
|
1467
1463
|
if (lb_channel_ == nullptr) {
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1464
|
+
std::string uri_str = absl::StrCat("fake:///", server_name_);
|
1465
|
+
lb_channel_ =
|
1466
|
+
CreateGrpclbBalancerChannel(uri_str.c_str(), *lb_channel_args);
|
1471
1467
|
GPR_ASSERT(lb_channel_ != nullptr);
|
1472
|
-
gpr_free(uri_str);
|
1473
1468
|
}
|
1474
1469
|
// Propagate updates to the LB channel (pick_first) through the fake
|
1475
1470
|
// resolver.
|
@@ -1479,60 +1474,11 @@ void GrpcLb::ProcessAddressesAndChannelArgsLocked(
|
|
1479
1474
|
response_generator_->SetResponse(std::move(result));
|
1480
1475
|
}
|
1481
1476
|
|
1482
|
-
void GrpcLb::OnBalancerChannelConnectivityChanged(void* arg,
|
1483
|
-
grpc_error* error) {
|
1484
|
-
GrpcLb* self = static_cast<GrpcLb*>(arg);
|
1485
|
-
self->combiner()->Run(
|
1486
|
-
GRPC_CLOSURE_INIT(&self->lb_channel_on_connectivity_changed_,
|
1487
|
-
&GrpcLb::OnBalancerChannelConnectivityChangedLocked,
|
1488
|
-
self, nullptr),
|
1489
|
-
GRPC_ERROR_REF(error));
|
1490
|
-
}
|
1491
|
-
|
1492
|
-
void GrpcLb::OnBalancerChannelConnectivityChangedLocked(void* arg,
|
1493
|
-
grpc_error* /*error*/) {
|
1494
|
-
GrpcLb* self = static_cast<GrpcLb*>(arg);
|
1495
|
-
if (!self->shutting_down_ && self->fallback_at_startup_checks_pending_) {
|
1496
|
-
if (self->lb_channel_connectivity_ != GRPC_CHANNEL_TRANSIENT_FAILURE) {
|
1497
|
-
// Not in TRANSIENT_FAILURE. Renew connectivity watch.
|
1498
|
-
grpc_channel_element* client_channel_elem =
|
1499
|
-
grpc_channel_stack_last_element(
|
1500
|
-
grpc_channel_get_channel_stack(self->lb_channel_));
|
1501
|
-
GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
|
1502
|
-
GRPC_CLOSURE_INIT(&self->lb_channel_on_connectivity_changed_,
|
1503
|
-
&GrpcLb::OnBalancerChannelConnectivityChanged, self,
|
1504
|
-
grpc_schedule_on_exec_ctx);
|
1505
|
-
grpc_client_channel_watch_connectivity_state(
|
1506
|
-
client_channel_elem,
|
1507
|
-
grpc_polling_entity_create_from_pollset_set(
|
1508
|
-
self->interested_parties()),
|
1509
|
-
&self->lb_channel_connectivity_,
|
1510
|
-
&self->lb_channel_on_connectivity_changed_, nullptr);
|
1511
|
-
return; // Early out so we don't drop the ref below.
|
1512
|
-
}
|
1513
|
-
// In TRANSIENT_FAILURE. Cancel the fallback timer and go into
|
1514
|
-
// fallback mode immediately.
|
1515
|
-
gpr_log(GPR_INFO,
|
1516
|
-
"[grpclb %p] balancer channel in state TRANSIENT_FAILURE; "
|
1517
|
-
"entering fallback mode",
|
1518
|
-
self);
|
1519
|
-
self->fallback_at_startup_checks_pending_ = false;
|
1520
|
-
grpc_timer_cancel(&self->lb_fallback_timer_);
|
1521
|
-
self->fallback_mode_ = true;
|
1522
|
-
self->CreateOrUpdateChildPolicyLocked();
|
1523
|
-
}
|
1524
|
-
// Done watching connectivity state, so drop ref.
|
1525
|
-
self->Unref(DEBUG_LOCATION, "watch_lb_channel_connectivity");
|
1526
|
-
}
|
1527
|
-
|
1528
1477
|
void GrpcLb::CancelBalancerChannelConnectivityWatchLocked() {
|
1529
1478
|
grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
|
1530
1479
|
grpc_channel_get_channel_stack(lb_channel_));
|
1531
1480
|
GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
|
1532
|
-
|
1533
|
-
client_channel_elem,
|
1534
|
-
grpc_polling_entity_create_from_pollset_set(interested_parties()),
|
1535
|
-
nullptr, &lb_channel_on_connectivity_changed_, nullptr);
|
1481
|
+
grpc_client_channel_stop_connectivity_watch(client_channel_elem, watcher_);
|
1536
1482
|
}
|
1537
1483
|
|
1538
1484
|
//
|
@@ -1571,33 +1517,30 @@ void GrpcLb::StartBalancerCallRetryTimerLocked() {
|
|
1571
1517
|
// with the callback.
|
1572
1518
|
auto self = Ref(DEBUG_LOCATION, "on_balancer_call_retry_timer");
|
1573
1519
|
self.release();
|
1574
|
-
GRPC_CLOSURE_INIT(&lb_on_call_retry_, &GrpcLb::OnBalancerCallRetryTimer, this,
|
1575
|
-
grpc_schedule_on_exec_ctx);
|
1576
1520
|
retry_timer_callback_pending_ = true;
|
1577
1521
|
grpc_timer_init(&lb_call_retry_timer_, next_try, &lb_on_call_retry_);
|
1578
1522
|
}
|
1579
1523
|
|
1580
1524
|
void GrpcLb::OnBalancerCallRetryTimer(void* arg, grpc_error* error) {
|
1581
1525
|
GrpcLb* grpclb_policy = static_cast<GrpcLb*>(arg);
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1526
|
+
GRPC_ERROR_REF(error); // ref owned by lambda
|
1527
|
+
grpclb_policy->work_serializer()->Run(
|
1528
|
+
[grpclb_policy, error]() {
|
1529
|
+
grpclb_policy->OnBalancerCallRetryTimerLocked(error);
|
1530
|
+
},
|
1531
|
+
DEBUG_LOCATION);
|
1587
1532
|
}
|
1588
1533
|
|
1589
|
-
void GrpcLb::OnBalancerCallRetryTimerLocked(
|
1590
|
-
|
1591
|
-
|
1592
|
-
if (!grpclb_policy->shutting_down_ && error == GRPC_ERROR_NONE &&
|
1593
|
-
grpclb_policy->lb_calld_ == nullptr) {
|
1534
|
+
void GrpcLb::OnBalancerCallRetryTimerLocked(grpc_error* error) {
|
1535
|
+
retry_timer_callback_pending_ = false;
|
1536
|
+
if (!shutting_down_ && error == GRPC_ERROR_NONE && lb_calld_ == nullptr) {
|
1594
1537
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1595
|
-
gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server",
|
1596
|
-
grpclb_policy);
|
1538
|
+
gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server", this);
|
1597
1539
|
}
|
1598
|
-
|
1540
|
+
StartBalancerCallLocked();
|
1599
1541
|
}
|
1600
|
-
|
1542
|
+
Unref(DEBUG_LOCATION, "on_balancer_call_retry_timer");
|
1543
|
+
GRPC_ERROR_UNREF(error);
|
1601
1544
|
}
|
1602
1545
|
|
1603
1546
|
//
|
@@ -1624,28 +1567,28 @@ void GrpcLb::MaybeEnterFallbackModeAfterStartup() {
|
|
1624
1567
|
|
1625
1568
|
void GrpcLb::OnFallbackTimer(void* arg, grpc_error* error) {
|
1626
1569
|
GrpcLb* grpclb_policy = static_cast<GrpcLb*>(arg);
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1570
|
+
GRPC_ERROR_REF(error); // ref owned by lambda
|
1571
|
+
grpclb_policy->work_serializer()->Run(
|
1572
|
+
[grpclb_policy, error]() { grpclb_policy->OnFallbackTimerLocked(error); },
|
1573
|
+
DEBUG_LOCATION);
|
1631
1574
|
}
|
1632
1575
|
|
1633
|
-
void GrpcLb::OnFallbackTimerLocked(
|
1634
|
-
GrpcLb* grpclb_policy = static_cast<GrpcLb*>(arg);
|
1576
|
+
void GrpcLb::OnFallbackTimerLocked(grpc_error* error) {
|
1635
1577
|
// If we receive a serverlist after the timer fires but before this callback
|
1636
1578
|
// actually runs, don't fall back.
|
1637
|
-
if (
|
1638
|
-
|
1579
|
+
if (fallback_at_startup_checks_pending_ && !shutting_down_ &&
|
1580
|
+
error == GRPC_ERROR_NONE) {
|
1639
1581
|
gpr_log(GPR_INFO,
|
1640
1582
|
"[grpclb %p] No response from balancer after fallback timeout; "
|
1641
1583
|
"entering fallback mode",
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1584
|
+
this);
|
1585
|
+
fallback_at_startup_checks_pending_ = false;
|
1586
|
+
CancelBalancerChannelConnectivityWatchLocked();
|
1587
|
+
fallback_mode_ = true;
|
1588
|
+
CreateOrUpdateChildPolicyLocked();
|
1647
1589
|
}
|
1648
|
-
|
1590
|
+
Unref(DEBUG_LOCATION, "on_fallback_timer");
|
1591
|
+
GRPC_ERROR_UNREF(error);
|
1649
1592
|
}
|
1650
1593
|
|
1651
1594
|
//
|
@@ -1654,7 +1597,7 @@ void GrpcLb::OnFallbackTimerLocked(void* arg, grpc_error* error) {
|
|
1654
1597
|
|
1655
1598
|
grpc_channel_args* GrpcLb::CreateChildPolicyArgsLocked(
|
1656
1599
|
bool is_backend_from_grpclb_load_balancer) {
|
1657
|
-
InlinedVector<grpc_arg, 2> args_to_add;
|
1600
|
+
absl::InlinedVector<grpc_arg, 2> args_to_add;
|
1658
1601
|
args_to_add.emplace_back(grpc_channel_arg_integer_create(
|
1659
1602
|
const_cast<char*>(GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER),
|
1660
1603
|
is_backend_from_grpclb_load_balancer));
|
@@ -1669,7 +1612,7 @@ grpc_channel_args* GrpcLb::CreateChildPolicyArgsLocked(
|
|
1669
1612
|
OrphanablePtr<LoadBalancingPolicy> GrpcLb::CreateChildPolicyLocked(
|
1670
1613
|
const grpc_channel_args* args) {
|
1671
1614
|
LoadBalancingPolicy::Args lb_policy_args;
|
1672
|
-
lb_policy_args.
|
1615
|
+
lb_policy_args.work_serializer = work_serializer();
|
1673
1616
|
lb_policy_args.args = args;
|
1674
1617
|
lb_policy_args.channel_control_helper = absl::make_unique<Helper>(Ref());
|
1675
1618
|
OrphanablePtr<LoadBalancingPolicy> lb_policy =
|
@@ -1707,7 +1650,7 @@ void GrpcLb::CreateOrUpdateChildPolicyLocked() {
|
|
1707
1650
|
update_args.args =
|
1708
1651
|
CreateChildPolicyArgsLocked(is_backend_from_grpclb_load_balancer);
|
1709
1652
|
GPR_ASSERT(update_args.args != nullptr);
|
1710
|
-
update_args.config =
|
1653
|
+
update_args.config = config_->child_policy();
|
1711
1654
|
// Create child policy if needed.
|
1712
1655
|
if (child_policy_ == nullptr) {
|
1713
1656
|
child_policy_ = CreateChildPolicyLocked(update_args.args);
|
@@ -1737,12 +1680,23 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
|
|
1737
1680
|
const Json& json, grpc_error** error) const override {
|
1738
1681
|
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
|
1739
1682
|
if (json.type() == Json::Type::JSON_NULL) {
|
1740
|
-
return MakeRefCounted<GrpcLbConfig>(nullptr);
|
1683
|
+
return MakeRefCounted<GrpcLbConfig>(nullptr, "");
|
1741
1684
|
}
|
1742
1685
|
std::vector<grpc_error*> error_list;
|
1743
1686
|
Json child_policy_config_json_tmp;
|
1744
1687
|
const Json* child_policy_config_json;
|
1745
|
-
|
1688
|
+
std::string service_name;
|
1689
|
+
auto it = json.object_value().find("serviceName");
|
1690
|
+
if (it != json.object_value().end()) {
|
1691
|
+
const Json& service_name_json = it->second;
|
1692
|
+
if (service_name_json.type() != Json::Type::STRING) {
|
1693
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1694
|
+
"field:serviceName error:type should be string"));
|
1695
|
+
} else {
|
1696
|
+
service_name = service_name_json.string_value();
|
1697
|
+
}
|
1698
|
+
}
|
1699
|
+
it = json.object_value().find("childPolicy");
|
1746
1700
|
if (it == json.object_value().end()) {
|
1747
1701
|
child_policy_config_json_tmp = Json::Array{Json::Object{
|
1748
1702
|
{"round_robin", Json::Object()},
|
@@ -1762,7 +1716,8 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
|
|
1762
1716
|
GRPC_ERROR_CREATE_FROM_VECTOR("field:childPolicy", &child_errors));
|
1763
1717
|
}
|
1764
1718
|
if (error_list.empty()) {
|
1765
|
-
return MakeRefCounted<GrpcLbConfig>(std::move(child_policy_config)
|
1719
|
+
return MakeRefCounted<GrpcLbConfig>(std::move(child_policy_config),
|
1720
|
+
std::move(service_name));
|
1766
1721
|
} else {
|
1767
1722
|
*error = GRPC_ERROR_CREATE_FROM_VECTOR("GrpcLb Parser", &error_list);
|
1768
1723
|
return nullptr;
|