grpc 1.31.0.pre1 → 1.33.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +693 -16022
- data/include/grpc/grpc.h +0 -5
- data/include/grpc/grpc_security.h +47 -14
- data/include/grpc/impl/codegen/README.md +22 -0
- data/include/grpc/impl/codegen/grpc_types.h +0 -5
- data/include/grpc/impl/codegen/port_platform.h +6 -1
- data/src/core/ext/filters/client_channel/backup_poller.cc +3 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +264 -186
- data/src/core/ext/filters/client_channel/client_channel.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -3
- data/src/core/ext/filters/client_channel/config_selector.cc +0 -4
- data/src/core/ext/filters/client_channel/config_selector.h +34 -5
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +6 -1
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -3
- data/src/core/ext/filters/client_channel/lb_policy.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +48 -35
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +9 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +126 -119
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +0 -13
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +0 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -37
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +21 -15
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +32 -13
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -7
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -32
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +26 -16
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +207 -129
- data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +453 -255
- data/src/core/ext/filters/client_channel/lb_policy/xds/eds_drop.cc +571 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +727 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +8 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +3 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +602 -58
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +28 -0
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +8 -39
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +4 -3
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +49 -47
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +5 -9
- data/src/core/ext/filters/client_channel/server_address.cc +120 -7
- data/src/core/ext/filters/client_channel/server_address.h +48 -21
- data/src/core/ext/filters/client_channel/service_config.cc +16 -13
- data/src/core/ext/filters/client_channel/service_config.h +7 -4
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +2 -2
- data/src/core/ext/filters/client_channel/service_config_parser.cc +8 -6
- data/src/core/ext/filters/client_channel/service_config_parser.h +8 -5
- data/src/core/ext/filters/client_channel/subchannel.cc +64 -23
- data/src/core/ext/filters/client_channel/subchannel.h +16 -4
- data/src/core/ext/filters/client_channel/subchannel_interface.h +44 -0
- data/src/core/ext/filters/max_age/max_age_filter.cc +2 -1
- data/src/core/ext/filters/message_size/message_size_filter.cc +2 -1
- data/src/core/ext/filters/message_size/message_size_filter.h +2 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +87 -31
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +18 -1
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +10 -35
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +19 -25
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +6 -6
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +256 -287
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +11 -3
- data/src/core/ext/transport/chttp2/transport/flow_control.h +10 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +10 -1
- data/src/core/ext/transport/chttp2/transport/parsing.cc +17 -30
- data/src/core/ext/transport/chttp2/transport/writing.cc +6 -5
- data/src/core/ext/transport/inproc/inproc_transport.cc +12 -12
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +244 -0
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +766 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +74 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +226 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +458 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +1635 -0
- data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/filter.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +69 -0
- data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/outlier_detection.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +323 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +124 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +379 -0
- data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/backoff.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +79 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +310 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +869 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +103 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +351 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +34 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +71 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +53 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +133 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +241 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +752 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +170 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +684 -0
- data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/http_uri.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +80 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +176 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +645 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +28 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +58 -0
- data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/socket_option.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +88 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +36 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +85 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +91 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +220 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +91 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +273 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +112 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +332 -0
- data/src/core/ext/upb-generated/envoy/config/listener/{v2 → v3}/api_listener.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +65 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +128 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +467 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +155 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +539 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +41 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +94 -0
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +178 -0
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +616 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +63 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +204 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +900 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +3290 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +60 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +139 -0
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +50 -0
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +108 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +364 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +1336 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +20 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +34 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +110 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +387 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +76 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +214 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +147 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +570 -0
- data/src/core/ext/upb-generated/envoy/{api/v2 → service/cluster/v3}/cds.upb.c +5 -6
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +49 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/{v2 → v3}/ads.upb.c +5 -4
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +49 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +139 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +449 -0
- data/src/core/ext/upb-generated/envoy/{api/v2 → service/endpoint/v3}/eds.upb.c +5 -6
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +49 -0
- data/src/core/ext/upb-generated/envoy/{api/v2 → service/listener/v3}/lds.upb.c +5 -6
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +49 -0
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +55 -0
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +136 -0
- data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/rds.upb.c +5 -6
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +49 -0
- data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/srds.upb.c +5 -6
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +49 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +47 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +114 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +35 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +77 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +34 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +71 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +64 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +145 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +54 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +133 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +63 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +188 -0
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +88 -0
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +258 -0
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +90 -0
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +250 -0
- data/src/core/ext/upb-generated/envoy/type/{http.upb.c → v3/http.upb.c} +2 -2
- data/src/core/ext/upb-generated/envoy/type/{http.upb.h → v3/http.upb.h} +8 -8
- data/src/core/ext/upb-generated/envoy/type/{percent.upb.c → v3/percent.upb.c} +9 -8
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +86 -0
- data/src/core/ext/upb-generated/envoy/type/{range.upb.c → v3/range.upb.c} +12 -11
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +111 -0
- data/src/core/ext/upb-generated/envoy/type/{semantic_version.upb.c → v3/semantic_version.upb.c} +6 -5
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +61 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +242 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +753 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +234 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +759 -0
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +36 -36
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +1 -1
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +31 -0
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +57 -0
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +27 -0
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +53 -0
- data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.c +28 -0
- data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +53 -0
- data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +52 -0
- data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +129 -0
- data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +42 -0
- data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +77 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +36 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +85 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +54 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +160 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +36 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +84 -0
- data/src/core/ext/upb-generated/validate/validate.upb.c +11 -11
- data/src/core/ext/upb-generated/validate/validate.upb.h +1 -1
- data/src/core/ext/xds/certificate_provider_factory.h +59 -0
- data/src/core/ext/xds/certificate_provider_registry.cc +103 -0
- data/src/core/ext/xds/certificate_provider_registry.h +57 -0
- data/src/core/ext/xds/certificate_provider_store.h +50 -0
- data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +377 -0
- data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +102 -0
- data/src/core/ext/xds/xds_api.cc +2596 -0
- data/src/core/ext/xds/xds_api.h +397 -0
- data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.cc +44 -2
- data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.h +8 -3
- data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_args.h +9 -6
- data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.cc +541 -785
- data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.h +114 -93
- data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.cc +20 -14
- data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.h +36 -8
- data/src/core/lib/channel/channel_args.h +0 -1
- data/src/core/lib/channel/channelz.cc +24 -60
- data/src/core/lib/channel/channelz.h +12 -20
- data/src/core/lib/channel/channelz_registry.cc +15 -12
- data/src/core/lib/channel/channelz_registry.h +3 -0
- data/src/core/lib/gpr/sync_posix.cc +2 -8
- data/src/core/lib/gpr/time_precise.cc +2 -0
- data/src/core/lib/gpr/time_precise.h +6 -2
- data/src/core/lib/gprpp/dual_ref_counted.h +336 -0
- data/src/core/lib/gprpp/ref_counted.h +51 -22
- data/src/core/lib/gprpp/ref_counted_ptr.h +153 -0
- data/src/core/lib/iomgr/endpoint.cc +5 -1
- data/src/core/lib/iomgr/endpoint.h +7 -3
- data/src/core/lib/iomgr/endpoint_cfstream.cc +36 -11
- data/src/core/lib/iomgr/ev_posix.cc +0 -2
- data/src/core/lib/iomgr/exec_ctx.h +10 -8
- data/src/core/lib/iomgr/iomgr.cc +0 -10
- data/src/core/lib/iomgr/iomgr.h +0 -10
- data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.cc +1 -1
- data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.h +3 -3
- data/src/core/lib/iomgr/sockaddr_utils.cc +2 -1
- data/src/core/lib/iomgr/sockaddr_utils.h +2 -1
- data/src/core/lib/iomgr/tcp_custom.cc +32 -16
- data/src/core/lib/iomgr/tcp_posix.cc +31 -13
- data/src/core/lib/iomgr/tcp_windows.cc +26 -10
- data/src/core/lib/json/json_util.cc +58 -0
- data/src/core/lib/json/json_util.h +37 -0
- data/src/core/lib/security/authorization/authorization_engine.cc +177 -0
- data/src/core/lib/security/authorization/authorization_engine.h +84 -0
- data/src/core/lib/security/authorization/evaluate_args.cc +153 -0
- data/src/core/lib/security/authorization/evaluate_args.h +59 -0
- data/src/core/lib/security/authorization/mock_cel/activation.h +57 -0
- data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +42 -0
- data/src/core/lib/security/authorization/mock_cel/cel_expression.h +68 -0
- data/src/core/lib/security/authorization/mock_cel/cel_value.h +93 -0
- data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +67 -0
- data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +56 -0
- data/src/core/lib/security/authorization/mock_cel/statusor.h +50 -0
- data/src/core/lib/security/certificate_provider.h +60 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +56 -38
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +321 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +214 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +45 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.h +51 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +7 -12
- data/src/core/lib/security/security_connector/ssl_utils.h +5 -0
- data/src/core/lib/security/transport/secure_endpoint.cc +7 -1
- data/src/core/lib/surface/call.cc +12 -12
- data/src/core/lib/surface/call.h +2 -1
- data/src/core/lib/surface/channel.cc +37 -51
- data/src/core/lib/surface/channel.h +18 -3
- data/src/core/lib/surface/completion_queue.cc +10 -272
- data/src/core/lib/surface/completion_queue.h +0 -8
- data/src/core/lib/surface/init.cc +27 -12
- data/src/core/lib/surface/server.cc +1066 -1244
- data/src/core/lib/surface/server.h +363 -87
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/authority_override.cc +38 -0
- data/src/core/lib/transport/authority_override.h +32 -0
- data/src/core/lib/transport/bdp_estimator.h +2 -1
- data/src/core/lib/transport/connectivity_state.cc +18 -13
- data/src/core/lib/transport/connectivity_state.h +20 -8
- data/src/core/lib/transport/error_utils.cc +13 -0
- data/src/core/lib/transport/error_utils.h +6 -0
- data/src/core/lib/transport/metadata.cc +11 -1
- data/src/core/lib/transport/static_metadata.cc +295 -276
- data/src/core/lib/transport/static_metadata.h +80 -73
- data/src/core/lib/transport/transport.h +7 -0
- data/src/core/lib/uri/uri_parser.cc +23 -21
- data/src/core/lib/uri/uri_parser.h +3 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +35 -20
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +22 -0
- data/src/core/tsi/ssl_transport_security.cc +2 -2
- data/src/ruby/bin/math_services_pb.rb +4 -4
- data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -4
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +7 -7
- data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +2 -2
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +5 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +28 -12
- data/src/ruby/spec/channel_credentials_spec.rb +10 -0
- data/src/ruby/spec/generic/active_call_spec.rb +19 -8
- data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +20 -0
- data/src/ruby/spec/user_agent_spec.rb +74 -0
- data/third_party/abseil-cpp/absl/algorithm/container.h +1727 -0
- data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +161 -0
- data/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc +93 -0
- data/third_party/abseil-cpp/absl/base/internal/exponential_biased.h +130 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +620 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +126 -0
- data/third_party/abseil-cpp/absl/container/fixed_array.h +515 -0
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +503 -0
- data/third_party/abseil-cpp/absl/container/internal/common.h +202 -0
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +440 -0
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +146 -0
- data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +191 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h +85 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +269 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +297 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +30 -0
- data/third_party/abseil-cpp/absl/container/internal/have_sse.h +49 -0
- data/third_party/abseil-cpp/absl/container/internal/layout.h +741 -0
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +48 -0
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1882 -0
- data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +138 -0
- data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h +32 -0
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +1895 -0
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +71 -0
- data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +382 -0
- data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +134 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +192 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +125 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +70 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +99 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +248 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +24 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +85 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +346 -0
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +128 -0
- data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +194 -0
- data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h +158 -0
- data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +140 -0
- data/third_party/abseil-cpp/absl/debugging/stacktrace.h +231 -0
- data/third_party/abseil-cpp/absl/debugging/symbolize.cc +25 -0
- data/third_party/abseil-cpp/absl/debugging/symbolize.h +99 -0
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +1480 -0
- data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +40 -0
- data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +81 -0
- data/third_party/abseil-cpp/absl/functional/function_ref.h +139 -0
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +106 -0
- data/third_party/abseil-cpp/absl/hash/hash.h +324 -0
- data/third_party/abseil-cpp/absl/hash/internal/city.cc +346 -0
- data/third_party/abseil-cpp/absl/hash/internal/city.h +96 -0
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +55 -0
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +988 -0
- data/third_party/abseil-cpp/absl/status/status.cc +447 -0
- data/third_party/abseil-cpp/absl/status/status.h +428 -0
- data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +43 -0
- data/third_party/abseil-cpp/absl/status/status_payload_printer.h +51 -0
- data/third_party/abseil-cpp/absl/strings/cord.cc +2019 -0
- data/third_party/abseil-cpp/absl/strings/cord.h +1121 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +151 -0
- data/third_party/abseil-cpp/absl/synchronization/barrier.cc +52 -0
- data/third_party/abseil-cpp/absl/synchronization/barrier.h +79 -0
- data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +57 -0
- data/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +99 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +140 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +60 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +697 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h +141 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +155 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +261 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +106 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +115 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +484 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +159 -0
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +2728 -0
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +1056 -0
- data/third_party/abseil-cpp/absl/synchronization/notification.cc +78 -0
- data/third_party/abseil-cpp/absl/synchronization/notification.h +123 -0
- data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +64 -0
- data/third_party/abseil-cpp/absl/types/bad_variant_access.h +82 -0
- data/third_party/abseil-cpp/absl/types/internal/variant.h +1646 -0
- data/third_party/abseil-cpp/absl/types/variant.h +861 -0
- data/third_party/boringssl-with-bazel/err_data.c +475 -467
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +0 -6
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +9 -43
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +55 -4
- data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +34 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +16 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +6 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +30 -10
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -15
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +543 -0
- data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +237 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +44 -2
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +221 -49
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +64 -20
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +0 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +7 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +21 -18
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +24 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +67 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +29 -35
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +13 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +10 -10
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +28 -40
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +20 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +7 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +55 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +52 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +0 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +2 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +6 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +12 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +9 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +4 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +48 -9
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +2 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +26 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +199 -78
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +52 -43
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +18 -18
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +2 -3
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +13 -9
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +3 -6
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +8 -9
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +10 -0
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +34 -9
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -2
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +4 -8
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +7 -2
- data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +5 -3
- 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 +64 -15
- data/third_party/upb/upb/encode.c +2 -2
- data/third_party/upb/upb/msg.h +2 -2
- data/third_party/upb/upb/port_def.inc +1 -1
- data/third_party/upb/upb/table.c +0 -11
- data/third_party/upb/upb/table.int.h +0 -9
- data/third_party/upb/upb/upb.c +16 -14
- data/third_party/upb/upb/upb.h +26 -0
- data/third_party/upb/upb/upb.hpp +2 -0
- metadata +340 -153
- data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +0 -528
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +0 -1142
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +0 -2110
- data/src/core/ext/filters/client_channel/xds/xds_api.h +0 -345
- data/src/core/ext/filters/client_channel/xds/xds_channel.h +0 -46
- data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +0 -106
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -21
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +0 -34
- data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +0 -114
- data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +0 -429
- data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +0 -72
- data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +0 -198
- data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +0 -105
- data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +0 -388
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +0 -52
- data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +0 -403
- data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +0 -1453
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -74
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +0 -226
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +0 -69
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +0 -323
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -112
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +0 -334
- data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +0 -79
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +0 -313
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +0 -891
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +0 -96
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +0 -328
- data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +0 -34
- data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +0 -71
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +0 -197
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +0 -649
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +0 -172
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +0 -693
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +0 -80
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +0 -152
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +0 -536
- data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +0 -88
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -129
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +0 -386
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +0 -52
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +0 -92
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +0 -224
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -18
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -32
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +0 -91
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +0 -273
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -112
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +0 -332
- data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +0 -52
- data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +0 -109
- data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +0 -415
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +0 -18
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -32
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +0 -145
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +0 -538
- data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +0 -43
- data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +0 -111
- data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +0 -52
- data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +0 -63
- data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +0 -204
- data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +0 -18
- data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -32
- data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +0 -815
- data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +0 -2984
- data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +0 -59
- data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +0 -135
- data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +0 -52
- data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +0 -228
- data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +0 -732
- data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +0 -316
- data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +0 -1167
- data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +0 -65
- data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +0 -51
- data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +0 -125
- data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +0 -49
- data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +0 -54
- data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +0 -136
- data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +0 -63
- data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +0 -145
- data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +0 -53
- data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +0 -133
- data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +0 -88
- data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +0 -258
- data/src/core/ext/upb-generated/envoy/type/percent.upb.h +0 -86
- data/src/core/ext/upb-generated/envoy/type/range.upb.h +0 -111
- data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +0 -61
- data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +0 -89
- data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +0 -250
- data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +0 -17
- data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +0 -29
- data/src/core/lib/security/transport/target_authority_table.cc +0 -75
- data/src/core/lib/security/transport/target_authority_table.h +0 -40
- data/src/core/lib/slice/slice_hash_table.h +0 -199
- data/src/core/lib/slice/slice_weak_hash_table.h +0 -102
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +0 -110
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +0 -274
@@ -1,1142 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// Copyright 2018 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 <inttypes.h>
|
20
|
-
#include <limits.h>
|
21
|
-
#include <string.h>
|
22
|
-
|
23
|
-
#include "absl/container/inlined_vector.h"
|
24
|
-
#include "absl/strings/match.h"
|
25
|
-
#include "absl/strings/numbers.h"
|
26
|
-
#include "absl/strings/str_cat.h"
|
27
|
-
#include "absl/strings/str_join.h"
|
28
|
-
#include "absl/strings/str_split.h"
|
29
|
-
#include "absl/strings/string_view.h"
|
30
|
-
#include "re2/re2.h"
|
31
|
-
|
32
|
-
#include <grpc/grpc.h>
|
33
|
-
|
34
|
-
#include "src/core/ext/filters/client_channel/lb_policy.h"
|
35
|
-
#include "src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h"
|
36
|
-
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
37
|
-
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
38
|
-
#include "src/core/ext/filters/client_channel/xds/xds_api.h"
|
39
|
-
#include "src/core/lib/channel/channel_args.h"
|
40
|
-
#include "src/core/lib/gpr/string.h"
|
41
|
-
#include "src/core/lib/gprpp/orphanable.h"
|
42
|
-
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
43
|
-
#include "src/core/lib/iomgr/timer.h"
|
44
|
-
#include "src/core/lib/iomgr/work_serializer.h"
|
45
|
-
|
46
|
-
#define GRPC_XDS_ROUTING_CHILD_RETENTION_INTERVAL_MS (15 * 60 * 1000)
|
47
|
-
|
48
|
-
namespace grpc_core {
|
49
|
-
|
50
|
-
TraceFlag grpc_xds_routing_lb_trace(false, "xds_routing_lb");
|
51
|
-
|
52
|
-
namespace {
|
53
|
-
|
54
|
-
constexpr char kXdsRouting[] = "xds_routing_experimental";
|
55
|
-
|
56
|
-
// Config for xds_routing LB policy.
|
57
|
-
class XdsRoutingLbConfig : public LoadBalancingPolicy::Config {
|
58
|
-
public:
|
59
|
-
struct Route {
|
60
|
-
XdsApi::RdsUpdate::RdsRoute::Matchers matchers;
|
61
|
-
std::string action;
|
62
|
-
};
|
63
|
-
using RouteTable = std::vector<Route>;
|
64
|
-
using ActionMap =
|
65
|
-
std::map<std::string, RefCountedPtr<LoadBalancingPolicy::Config>>;
|
66
|
-
|
67
|
-
XdsRoutingLbConfig(ActionMap action_map, RouteTable route_table)
|
68
|
-
: action_map_(std::move(action_map)),
|
69
|
-
route_table_(std::move(route_table)) {}
|
70
|
-
|
71
|
-
const char* name() const override { return kXdsRouting; }
|
72
|
-
|
73
|
-
const ActionMap& action_map() const { return action_map_; }
|
74
|
-
|
75
|
-
const RouteTable& route_table() const { return route_table_; }
|
76
|
-
|
77
|
-
private:
|
78
|
-
ActionMap action_map_;
|
79
|
-
RouteTable route_table_;
|
80
|
-
};
|
81
|
-
|
82
|
-
// xds_routing LB policy.
|
83
|
-
class XdsRoutingLb : public LoadBalancingPolicy {
|
84
|
-
public:
|
85
|
-
explicit XdsRoutingLb(Args args);
|
86
|
-
|
87
|
-
const char* name() const override { return kXdsRouting; }
|
88
|
-
|
89
|
-
void UpdateLocked(UpdateArgs args) override;
|
90
|
-
void ExitIdleLocked() override;
|
91
|
-
void ResetBackoffLocked() override;
|
92
|
-
|
93
|
-
private:
|
94
|
-
// A simple wrapper for ref-counting a picker from the child policy.
|
95
|
-
class ChildPickerWrapper : public RefCounted<ChildPickerWrapper> {
|
96
|
-
public:
|
97
|
-
ChildPickerWrapper(std::string name,
|
98
|
-
std::unique_ptr<SubchannelPicker> picker)
|
99
|
-
: name_(std::move(name)), picker_(std::move(picker)) {}
|
100
|
-
PickResult Pick(PickArgs args) { return picker_->Pick(args); }
|
101
|
-
|
102
|
-
const std::string& name() const { return name_; }
|
103
|
-
|
104
|
-
private:
|
105
|
-
std::string name_;
|
106
|
-
std::unique_ptr<SubchannelPicker> picker_;
|
107
|
-
};
|
108
|
-
|
109
|
-
// Picks a child using prefix or path matching and then delegates to that
|
110
|
-
// child's picker.
|
111
|
-
class RoutePicker : public SubchannelPicker {
|
112
|
-
public:
|
113
|
-
struct Route {
|
114
|
-
const XdsApi::RdsUpdate::RdsRoute::Matchers* matchers;
|
115
|
-
RefCountedPtr<ChildPickerWrapper> picker;
|
116
|
-
};
|
117
|
-
|
118
|
-
// Maintains an ordered xds route table as provided by RDS response.
|
119
|
-
using RouteTable = std::vector<Route>;
|
120
|
-
|
121
|
-
RoutePicker(RouteTable route_table,
|
122
|
-
RefCountedPtr<XdsRoutingLbConfig> config)
|
123
|
-
: route_table_(std::move(route_table)), config_(std::move(config)) {}
|
124
|
-
|
125
|
-
PickResult Pick(PickArgs args) override;
|
126
|
-
|
127
|
-
private:
|
128
|
-
RouteTable route_table_;
|
129
|
-
// Take a reference to config so that we can use
|
130
|
-
// XdsApi::RdsUpdate::RdsRoute::Matchers from it.
|
131
|
-
RefCountedPtr<XdsRoutingLbConfig> config_;
|
132
|
-
};
|
133
|
-
|
134
|
-
// Each XdsRoutingChild holds a ref to its parent XdsRoutingLb.
|
135
|
-
class XdsRoutingChild : public InternallyRefCounted<XdsRoutingChild> {
|
136
|
-
public:
|
137
|
-
XdsRoutingChild(RefCountedPtr<XdsRoutingLb> xds_routing_policy,
|
138
|
-
const std::string& name);
|
139
|
-
~XdsRoutingChild();
|
140
|
-
|
141
|
-
void Orphan() override;
|
142
|
-
|
143
|
-
void UpdateLocked(RefCountedPtr<LoadBalancingPolicy::Config> config,
|
144
|
-
const ServerAddressList& addresses,
|
145
|
-
const grpc_channel_args* args);
|
146
|
-
void ExitIdleLocked();
|
147
|
-
void ResetBackoffLocked();
|
148
|
-
void DeactivateLocked();
|
149
|
-
|
150
|
-
grpc_connectivity_state connectivity_state() const {
|
151
|
-
return connectivity_state_;
|
152
|
-
}
|
153
|
-
RefCountedPtr<ChildPickerWrapper> picker_wrapper() const {
|
154
|
-
return picker_wrapper_;
|
155
|
-
}
|
156
|
-
|
157
|
-
private:
|
158
|
-
class Helper : public ChannelControlHelper {
|
159
|
-
public:
|
160
|
-
explicit Helper(RefCountedPtr<XdsRoutingChild> xds_routing_child)
|
161
|
-
: xds_routing_child_(std::move(xds_routing_child)) {}
|
162
|
-
|
163
|
-
~Helper() { xds_routing_child_.reset(DEBUG_LOCATION, "Helper"); }
|
164
|
-
|
165
|
-
RefCountedPtr<SubchannelInterface> CreateSubchannel(
|
166
|
-
const grpc_channel_args& args) override;
|
167
|
-
void UpdateState(grpc_connectivity_state state,
|
168
|
-
std::unique_ptr<SubchannelPicker> picker) override;
|
169
|
-
void RequestReresolution() override;
|
170
|
-
void AddTraceEvent(TraceSeverity severity,
|
171
|
-
absl::string_view message) override;
|
172
|
-
|
173
|
-
private:
|
174
|
-
RefCountedPtr<XdsRoutingChild> xds_routing_child_;
|
175
|
-
};
|
176
|
-
|
177
|
-
// Methods for dealing with the child policy.
|
178
|
-
OrphanablePtr<LoadBalancingPolicy> CreateChildPolicyLocked(
|
179
|
-
const grpc_channel_args* args);
|
180
|
-
|
181
|
-
static void OnDelayedRemovalTimer(void* arg, grpc_error* error);
|
182
|
-
void OnDelayedRemovalTimerLocked(grpc_error* error);
|
183
|
-
|
184
|
-
// The owning LB policy.
|
185
|
-
RefCountedPtr<XdsRoutingLb> xds_routing_policy_;
|
186
|
-
|
187
|
-
// Points to the corresponding key in XdsRoutingLb::actions_.
|
188
|
-
const std::string& name_;
|
189
|
-
|
190
|
-
OrphanablePtr<LoadBalancingPolicy> child_policy_;
|
191
|
-
|
192
|
-
RefCountedPtr<ChildPickerWrapper> picker_wrapper_;
|
193
|
-
grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE;
|
194
|
-
bool seen_failure_since_ready_ = false;
|
195
|
-
|
196
|
-
// States for delayed removal.
|
197
|
-
grpc_timer delayed_removal_timer_;
|
198
|
-
grpc_closure on_delayed_removal_timer_;
|
199
|
-
bool delayed_removal_timer_callback_pending_ = false;
|
200
|
-
bool shutdown_ = false;
|
201
|
-
};
|
202
|
-
|
203
|
-
~XdsRoutingLb();
|
204
|
-
|
205
|
-
void ShutdownLocked() override;
|
206
|
-
|
207
|
-
void UpdateStateLocked();
|
208
|
-
|
209
|
-
// Current config from the resolver.
|
210
|
-
RefCountedPtr<XdsRoutingLbConfig> config_;
|
211
|
-
|
212
|
-
// Internal state.
|
213
|
-
bool shutting_down_ = false;
|
214
|
-
|
215
|
-
// Children.
|
216
|
-
std::map<std::string, OrphanablePtr<XdsRoutingChild>> actions_;
|
217
|
-
};
|
218
|
-
|
219
|
-
//
|
220
|
-
// XdsRoutingLb::RoutePicker
|
221
|
-
//
|
222
|
-
|
223
|
-
bool PathMatch(
|
224
|
-
const absl::string_view& path,
|
225
|
-
const XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher& path_matcher) {
|
226
|
-
switch (path_matcher.type) {
|
227
|
-
case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType::
|
228
|
-
PREFIX:
|
229
|
-
return absl::StartsWith(path, path_matcher.string_matcher);
|
230
|
-
case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType::
|
231
|
-
PATH:
|
232
|
-
return path == path_matcher.string_matcher;
|
233
|
-
case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType::
|
234
|
-
REGEX:
|
235
|
-
return RE2::FullMatch(path.data(), *path_matcher.regex_matcher);
|
236
|
-
default:
|
237
|
-
return false;
|
238
|
-
}
|
239
|
-
}
|
240
|
-
|
241
|
-
absl::optional<absl::string_view> GetMetadataValue(
|
242
|
-
const std::string& key,
|
243
|
-
LoadBalancingPolicy::MetadataInterface* initial_metadata,
|
244
|
-
std::string* concatenated_value) {
|
245
|
-
// Find all values for the specified key.
|
246
|
-
GPR_DEBUG_ASSERT(initial_metadata != nullptr);
|
247
|
-
absl::InlinedVector<absl::string_view, 1> values;
|
248
|
-
for (const auto p : *initial_metadata) {
|
249
|
-
if (p.first == key) values.push_back(p.second);
|
250
|
-
}
|
251
|
-
// If none found, no match.
|
252
|
-
if (values.empty()) return absl::nullopt;
|
253
|
-
// If exactly one found, return it as-is.
|
254
|
-
if (values.size() == 1) return values.front();
|
255
|
-
// If more than one found, concatenate the values, using
|
256
|
-
// *concatenated_values as a temporary holding place for the
|
257
|
-
// concatenated string.
|
258
|
-
*concatenated_value = absl::StrJoin(values, ",");
|
259
|
-
return *concatenated_value;
|
260
|
-
}
|
261
|
-
|
262
|
-
bool HeaderMatchHelper(
|
263
|
-
const XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher& header_matcher,
|
264
|
-
LoadBalancingPolicy::MetadataInterface* initial_metadata) {
|
265
|
-
std::string concatenated_value;
|
266
|
-
absl::optional<absl::string_view> value;
|
267
|
-
// Note: If we ever allow binary headers here, we still need to
|
268
|
-
// special-case ignore "grpc-tags-bin" and "grpc-trace-bin", since
|
269
|
-
// they are not visible to the LB policy in grpc-go.
|
270
|
-
if (absl::EndsWith(header_matcher.name, "-bin") ||
|
271
|
-
header_matcher.name == "grpc-previous-rpc-attempts") {
|
272
|
-
value = absl::nullopt;
|
273
|
-
} else if (header_matcher.name == "content-type") {
|
274
|
-
value = "application/grpc";
|
275
|
-
} else {
|
276
|
-
value = GetMetadataValue(header_matcher.name, initial_metadata,
|
277
|
-
&concatenated_value);
|
278
|
-
}
|
279
|
-
if (!value.has_value()) {
|
280
|
-
if (header_matcher.type == XdsApi::RdsUpdate::RdsRoute::Matchers::
|
281
|
-
HeaderMatcher::HeaderMatcherType::PRESENT) {
|
282
|
-
return !header_matcher.present_match;
|
283
|
-
} else {
|
284
|
-
// For all other header matcher types, we need the header value to
|
285
|
-
// exist to consider matches.
|
286
|
-
return false;
|
287
|
-
}
|
288
|
-
}
|
289
|
-
switch (header_matcher.type) {
|
290
|
-
case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::
|
291
|
-
HeaderMatcherType::EXACT:
|
292
|
-
return value.value() == header_matcher.string_matcher;
|
293
|
-
case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::
|
294
|
-
HeaderMatcherType::REGEX:
|
295
|
-
return RE2::FullMatch(value.value().data(), *header_matcher.regex_match);
|
296
|
-
case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::
|
297
|
-
HeaderMatcherType::RANGE:
|
298
|
-
int64_t int_value;
|
299
|
-
if (!absl::SimpleAtoi(value.value(), &int_value)) {
|
300
|
-
return false;
|
301
|
-
}
|
302
|
-
return int_value >= header_matcher.range_start &&
|
303
|
-
int_value < header_matcher.range_end;
|
304
|
-
case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::
|
305
|
-
HeaderMatcherType::PREFIX:
|
306
|
-
return absl::StartsWith(value.value(), header_matcher.string_matcher);
|
307
|
-
case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::
|
308
|
-
HeaderMatcherType::SUFFIX:
|
309
|
-
return absl::EndsWith(value.value(), header_matcher.string_matcher);
|
310
|
-
default:
|
311
|
-
return false;
|
312
|
-
}
|
313
|
-
}
|
314
|
-
|
315
|
-
bool HeadersMatch(
|
316
|
-
const std::vector<XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher>&
|
317
|
-
header_matchers,
|
318
|
-
LoadBalancingPolicy::MetadataInterface* initial_metadata) {
|
319
|
-
for (const auto& header_matcher : header_matchers) {
|
320
|
-
bool match = HeaderMatchHelper(header_matcher, initial_metadata);
|
321
|
-
if (header_matcher.invert_match) match = !match;
|
322
|
-
if (!match) return false;
|
323
|
-
}
|
324
|
-
return true;
|
325
|
-
}
|
326
|
-
|
327
|
-
bool UnderFraction(const uint32_t fraction_per_million) {
|
328
|
-
// Generate a random number in [0, 1000000).
|
329
|
-
const uint32_t random_number = rand() % 1000000;
|
330
|
-
return random_number < fraction_per_million;
|
331
|
-
}
|
332
|
-
|
333
|
-
XdsRoutingLb::PickResult XdsRoutingLb::RoutePicker::Pick(PickArgs args) {
|
334
|
-
for (const Route& route : route_table_) {
|
335
|
-
// Path matching.
|
336
|
-
if (!PathMatch(args.path, route.matchers->path_matcher)) continue;
|
337
|
-
// Header Matching.
|
338
|
-
if (!HeadersMatch(route.matchers->header_matchers, args.initial_metadata)) {
|
339
|
-
continue;
|
340
|
-
}
|
341
|
-
// Match fraction check
|
342
|
-
if (route.matchers->fraction_per_million.has_value() &&
|
343
|
-
!UnderFraction(route.matchers->fraction_per_million.value())) {
|
344
|
-
continue;
|
345
|
-
}
|
346
|
-
// Found a match
|
347
|
-
return route.picker->Pick(args);
|
348
|
-
}
|
349
|
-
PickResult result;
|
350
|
-
result.type = PickResult::PICK_FAILED;
|
351
|
-
result.error =
|
352
|
-
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
353
|
-
"xds routing picker: no matching route"),
|
354
|
-
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL);
|
355
|
-
return result;
|
356
|
-
}
|
357
|
-
|
358
|
-
//
|
359
|
-
// XdsRoutingLb
|
360
|
-
//
|
361
|
-
|
362
|
-
XdsRoutingLb::XdsRoutingLb(Args args) : LoadBalancingPolicy(std::move(args)) {}
|
363
|
-
|
364
|
-
XdsRoutingLb::~XdsRoutingLb() {
|
365
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
366
|
-
gpr_log(GPR_INFO, "[xds_routing_lb %p] destroying xds_routing LB policy",
|
367
|
-
this);
|
368
|
-
}
|
369
|
-
}
|
370
|
-
|
371
|
-
void XdsRoutingLb::ShutdownLocked() {
|
372
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
373
|
-
gpr_log(GPR_INFO, "[xds_routing_lb %p] shutting down", this);
|
374
|
-
}
|
375
|
-
shutting_down_ = true;
|
376
|
-
actions_.clear();
|
377
|
-
}
|
378
|
-
|
379
|
-
void XdsRoutingLb::ExitIdleLocked() {
|
380
|
-
for (auto& p : actions_) p.second->ExitIdleLocked();
|
381
|
-
}
|
382
|
-
|
383
|
-
void XdsRoutingLb::ResetBackoffLocked() {
|
384
|
-
for (auto& p : actions_) p.second->ResetBackoffLocked();
|
385
|
-
}
|
386
|
-
|
387
|
-
void XdsRoutingLb::UpdateLocked(UpdateArgs args) {
|
388
|
-
if (shutting_down_) return;
|
389
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
390
|
-
gpr_log(GPR_INFO, "[xds_routing_lb %p] Received update", this);
|
391
|
-
}
|
392
|
-
// Update config.
|
393
|
-
config_ = std::move(args.config);
|
394
|
-
// Deactivate the actions not in the new config.
|
395
|
-
for (const auto& p : actions_) {
|
396
|
-
const std::string& name = p.first;
|
397
|
-
XdsRoutingChild* child = p.second.get();
|
398
|
-
if (config_->action_map().find(name) == config_->action_map().end()) {
|
399
|
-
child->DeactivateLocked();
|
400
|
-
}
|
401
|
-
}
|
402
|
-
// Add or update the actions in the new config.
|
403
|
-
for (const auto& p : config_->action_map()) {
|
404
|
-
const std::string& name = p.first;
|
405
|
-
const RefCountedPtr<LoadBalancingPolicy::Config>& config = p.second;
|
406
|
-
auto it = actions_.find(name);
|
407
|
-
if (it == actions_.end()) {
|
408
|
-
it = actions_.emplace(std::make_pair(name, nullptr)).first;
|
409
|
-
it->second = MakeOrphanable<XdsRoutingChild>(
|
410
|
-
Ref(DEBUG_LOCATION, "XdsRoutingChild"), it->first);
|
411
|
-
}
|
412
|
-
it->second->UpdateLocked(config, args.addresses, args.args);
|
413
|
-
}
|
414
|
-
}
|
415
|
-
|
416
|
-
void XdsRoutingLb::UpdateStateLocked() {
|
417
|
-
// Also count the number of children in each state, to determine the
|
418
|
-
// overall state.
|
419
|
-
size_t num_ready = 0;
|
420
|
-
size_t num_connecting = 0;
|
421
|
-
size_t num_idle = 0;
|
422
|
-
size_t num_transient_failures = 0;
|
423
|
-
for (const auto& p : actions_) {
|
424
|
-
const auto& child_name = p.first;
|
425
|
-
const XdsRoutingChild* child = p.second.get();
|
426
|
-
// Skip the actions that are not in the latest update.
|
427
|
-
if (config_->action_map().find(child_name) == config_->action_map().end()) {
|
428
|
-
continue;
|
429
|
-
}
|
430
|
-
switch (child->connectivity_state()) {
|
431
|
-
case GRPC_CHANNEL_READY: {
|
432
|
-
++num_ready;
|
433
|
-
break;
|
434
|
-
}
|
435
|
-
case GRPC_CHANNEL_CONNECTING: {
|
436
|
-
++num_connecting;
|
437
|
-
break;
|
438
|
-
}
|
439
|
-
case GRPC_CHANNEL_IDLE: {
|
440
|
-
++num_idle;
|
441
|
-
break;
|
442
|
-
}
|
443
|
-
case GRPC_CHANNEL_TRANSIENT_FAILURE: {
|
444
|
-
++num_transient_failures;
|
445
|
-
break;
|
446
|
-
}
|
447
|
-
default:
|
448
|
-
GPR_UNREACHABLE_CODE(return );
|
449
|
-
}
|
450
|
-
}
|
451
|
-
// Determine aggregated connectivity state.
|
452
|
-
grpc_connectivity_state connectivity_state;
|
453
|
-
if (num_ready > 0) {
|
454
|
-
connectivity_state = GRPC_CHANNEL_READY;
|
455
|
-
} else if (num_connecting > 0) {
|
456
|
-
connectivity_state = GRPC_CHANNEL_CONNECTING;
|
457
|
-
} else if (num_idle > 0) {
|
458
|
-
connectivity_state = GRPC_CHANNEL_IDLE;
|
459
|
-
} else {
|
460
|
-
connectivity_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
|
461
|
-
}
|
462
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
463
|
-
gpr_log(GPR_INFO, "[xds_routing_lb %p] connectivity changed to %s", this,
|
464
|
-
ConnectivityStateName(connectivity_state));
|
465
|
-
}
|
466
|
-
std::unique_ptr<SubchannelPicker> picker;
|
467
|
-
switch (connectivity_state) {
|
468
|
-
case GRPC_CHANNEL_READY: {
|
469
|
-
RoutePicker::RouteTable route_table;
|
470
|
-
for (const auto& config_route : config_->route_table()) {
|
471
|
-
RoutePicker::Route route;
|
472
|
-
route.matchers = &config_route.matchers;
|
473
|
-
route.picker = actions_[config_route.action]->picker_wrapper();
|
474
|
-
if (route.picker == nullptr) {
|
475
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
476
|
-
gpr_log(GPR_INFO,
|
477
|
-
"[xds_routing_lb %p] child %s has not yet returned a "
|
478
|
-
"picker; creating a QueuePicker.",
|
479
|
-
this, config_route.action.c_str());
|
480
|
-
}
|
481
|
-
route.picker = MakeRefCounted<ChildPickerWrapper>(
|
482
|
-
config_route.action, absl::make_unique<QueuePicker>(
|
483
|
-
Ref(DEBUG_LOCATION, "QueuePicker")));
|
484
|
-
}
|
485
|
-
route_table.push_back(std::move(route));
|
486
|
-
}
|
487
|
-
picker = absl::make_unique<RoutePicker>(std::move(route_table), config_);
|
488
|
-
break;
|
489
|
-
}
|
490
|
-
case GRPC_CHANNEL_CONNECTING:
|
491
|
-
case GRPC_CHANNEL_IDLE:
|
492
|
-
picker =
|
493
|
-
absl::make_unique<QueuePicker>(Ref(DEBUG_LOCATION, "QueuePicker"));
|
494
|
-
break;
|
495
|
-
default:
|
496
|
-
picker = absl::make_unique<TransientFailurePicker>(grpc_error_set_int(
|
497
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
498
|
-
"TRANSIENT_FAILURE from XdsRoutingLb"),
|
499
|
-
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
|
500
|
-
}
|
501
|
-
channel_control_helper()->UpdateState(connectivity_state, std::move(picker));
|
502
|
-
}
|
503
|
-
|
504
|
-
//
|
505
|
-
// XdsRoutingLb::XdsRoutingChild
|
506
|
-
//
|
507
|
-
|
508
|
-
XdsRoutingLb::XdsRoutingChild::XdsRoutingChild(
|
509
|
-
RefCountedPtr<XdsRoutingLb> xds_routing_policy, const std::string& name)
|
510
|
-
: xds_routing_policy_(std::move(xds_routing_policy)), name_(name) {
|
511
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
512
|
-
gpr_log(GPR_INFO, "[xds_routing_lb %p] created XdsRoutingChild %p for %s",
|
513
|
-
xds_routing_policy_.get(), this, name_.c_str());
|
514
|
-
}
|
515
|
-
GRPC_CLOSURE_INIT(&on_delayed_removal_timer_, OnDelayedRemovalTimer, this,
|
516
|
-
grpc_schedule_on_exec_ctx);
|
517
|
-
}
|
518
|
-
|
519
|
-
XdsRoutingLb::XdsRoutingChild::~XdsRoutingChild() {
|
520
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
521
|
-
gpr_log(GPR_INFO,
|
522
|
-
"[xds_routing_lb %p] XdsRoutingChild %p: destroying child",
|
523
|
-
xds_routing_policy_.get(), this);
|
524
|
-
}
|
525
|
-
xds_routing_policy_.reset(DEBUG_LOCATION, "XdsRoutingChild");
|
526
|
-
}
|
527
|
-
|
528
|
-
void XdsRoutingLb::XdsRoutingChild::Orphan() {
|
529
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
530
|
-
gpr_log(GPR_INFO,
|
531
|
-
"[xds_routing_lb %p] XdsRoutingChild %p %s: shutting down child",
|
532
|
-
xds_routing_policy_.get(), this, name_.c_str());
|
533
|
-
}
|
534
|
-
// Remove the child policy's interested_parties pollset_set from the
|
535
|
-
// xDS policy.
|
536
|
-
grpc_pollset_set_del_pollset_set(child_policy_->interested_parties(),
|
537
|
-
xds_routing_policy_->interested_parties());
|
538
|
-
child_policy_.reset();
|
539
|
-
// Drop our ref to the child's picker, in case it's holding a ref to
|
540
|
-
// the child.
|
541
|
-
picker_wrapper_.reset();
|
542
|
-
if (delayed_removal_timer_callback_pending_) {
|
543
|
-
grpc_timer_cancel(&delayed_removal_timer_);
|
544
|
-
}
|
545
|
-
shutdown_ = true;
|
546
|
-
Unref();
|
547
|
-
}
|
548
|
-
|
549
|
-
OrphanablePtr<LoadBalancingPolicy>
|
550
|
-
XdsRoutingLb::XdsRoutingChild::CreateChildPolicyLocked(
|
551
|
-
const grpc_channel_args* args) {
|
552
|
-
LoadBalancingPolicy::Args lb_policy_args;
|
553
|
-
lb_policy_args.work_serializer = xds_routing_policy_->work_serializer();
|
554
|
-
lb_policy_args.args = args;
|
555
|
-
lb_policy_args.channel_control_helper =
|
556
|
-
absl::make_unique<Helper>(this->Ref(DEBUG_LOCATION, "Helper"));
|
557
|
-
OrphanablePtr<LoadBalancingPolicy> lb_policy =
|
558
|
-
MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args),
|
559
|
-
&grpc_xds_routing_lb_trace);
|
560
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
561
|
-
gpr_log(GPR_INFO,
|
562
|
-
"[xds_routing_lb %p] XdsRoutingChild %p %s: Created new child "
|
563
|
-
"policy handler %p",
|
564
|
-
xds_routing_policy_.get(), this, name_.c_str(), lb_policy.get());
|
565
|
-
}
|
566
|
-
// Add the xDS's interested_parties pollset_set to that of the newly created
|
567
|
-
// child policy. This will make the child policy progress upon activity on
|
568
|
-
// xDS LB, which in turn is tied to the application's call.
|
569
|
-
grpc_pollset_set_add_pollset_set(lb_policy->interested_parties(),
|
570
|
-
xds_routing_policy_->interested_parties());
|
571
|
-
return lb_policy;
|
572
|
-
}
|
573
|
-
|
574
|
-
void XdsRoutingLb::XdsRoutingChild::UpdateLocked(
|
575
|
-
RefCountedPtr<LoadBalancingPolicy::Config> config,
|
576
|
-
const ServerAddressList& addresses, const grpc_channel_args* args) {
|
577
|
-
if (xds_routing_policy_->shutting_down_) return;
|
578
|
-
// Update child weight.
|
579
|
-
// Reactivate if needed.
|
580
|
-
if (delayed_removal_timer_callback_pending_) {
|
581
|
-
delayed_removal_timer_callback_pending_ = false;
|
582
|
-
grpc_timer_cancel(&delayed_removal_timer_);
|
583
|
-
}
|
584
|
-
// Create child policy if needed.
|
585
|
-
if (child_policy_ == nullptr) {
|
586
|
-
child_policy_ = CreateChildPolicyLocked(args);
|
587
|
-
}
|
588
|
-
// Construct update args.
|
589
|
-
UpdateArgs update_args;
|
590
|
-
update_args.config = std::move(config);
|
591
|
-
update_args.addresses = addresses;
|
592
|
-
update_args.args = grpc_channel_args_copy(args);
|
593
|
-
// Update the policy.
|
594
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
595
|
-
gpr_log(GPR_INFO,
|
596
|
-
"[xds_routing_lb %p] XdsRoutingChild %p %s: Updating child "
|
597
|
-
"policy handler %p",
|
598
|
-
xds_routing_policy_.get(), this, name_.c_str(),
|
599
|
-
child_policy_.get());
|
600
|
-
}
|
601
|
-
child_policy_->UpdateLocked(std::move(update_args));
|
602
|
-
}
|
603
|
-
|
604
|
-
void XdsRoutingLb::XdsRoutingChild::ExitIdleLocked() {
|
605
|
-
child_policy_->ExitIdleLocked();
|
606
|
-
}
|
607
|
-
|
608
|
-
void XdsRoutingLb::XdsRoutingChild::ResetBackoffLocked() {
|
609
|
-
child_policy_->ResetBackoffLocked();
|
610
|
-
}
|
611
|
-
|
612
|
-
void XdsRoutingLb::XdsRoutingChild::DeactivateLocked() {
|
613
|
-
// If already deactivated, don't do that again.
|
614
|
-
if (delayed_removal_timer_callback_pending_ == true) return;
|
615
|
-
// Set the child weight to 0 so that future picker won't contain this child.
|
616
|
-
// Start a timer to delete the child.
|
617
|
-
Ref(DEBUG_LOCATION, "XdsRoutingChild+timer").release();
|
618
|
-
grpc_timer_init(
|
619
|
-
&delayed_removal_timer_,
|
620
|
-
ExecCtx::Get()->Now() + GRPC_XDS_ROUTING_CHILD_RETENTION_INTERVAL_MS,
|
621
|
-
&on_delayed_removal_timer_);
|
622
|
-
delayed_removal_timer_callback_pending_ = true;
|
623
|
-
}
|
624
|
-
|
625
|
-
void XdsRoutingLb::XdsRoutingChild::OnDelayedRemovalTimer(void* arg,
|
626
|
-
grpc_error* error) {
|
627
|
-
XdsRoutingChild* self = static_cast<XdsRoutingChild*>(arg);
|
628
|
-
GRPC_ERROR_REF(error); // Ref owned by the lambda
|
629
|
-
self->xds_routing_policy_->work_serializer()->Run(
|
630
|
-
[self, error]() { self->OnDelayedRemovalTimerLocked(error); },
|
631
|
-
DEBUG_LOCATION);
|
632
|
-
}
|
633
|
-
|
634
|
-
void XdsRoutingLb::XdsRoutingChild::OnDelayedRemovalTimerLocked(
|
635
|
-
grpc_error* error) {
|
636
|
-
delayed_removal_timer_callback_pending_ = false;
|
637
|
-
if (error == GRPC_ERROR_NONE && !shutdown_) {
|
638
|
-
xds_routing_policy_->actions_.erase(name_);
|
639
|
-
}
|
640
|
-
Unref(DEBUG_LOCATION, "XdsRoutingChild+timer");
|
641
|
-
GRPC_ERROR_UNREF(error);
|
642
|
-
}
|
643
|
-
|
644
|
-
//
|
645
|
-
// XdsRoutingLb::XdsRoutingChild::Helper
|
646
|
-
//
|
647
|
-
|
648
|
-
RefCountedPtr<SubchannelInterface>
|
649
|
-
XdsRoutingLb::XdsRoutingChild::Helper::CreateSubchannel(
|
650
|
-
const grpc_channel_args& args) {
|
651
|
-
if (xds_routing_child_->xds_routing_policy_->shutting_down_) return nullptr;
|
652
|
-
return xds_routing_child_->xds_routing_policy_->channel_control_helper()
|
653
|
-
->CreateSubchannel(args);
|
654
|
-
}
|
655
|
-
|
656
|
-
void XdsRoutingLb::XdsRoutingChild::Helper::UpdateState(
|
657
|
-
grpc_connectivity_state state, std::unique_ptr<SubchannelPicker> picker) {
|
658
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_routing_lb_trace)) {
|
659
|
-
gpr_log(GPR_INFO,
|
660
|
-
"[xds_routing_lb %p] child %s: received update: state=%s picker=%p",
|
661
|
-
xds_routing_child_->xds_routing_policy_.get(),
|
662
|
-
xds_routing_child_->name_.c_str(), ConnectivityStateName(state),
|
663
|
-
picker.get());
|
664
|
-
}
|
665
|
-
if (xds_routing_child_->xds_routing_policy_->shutting_down_) return;
|
666
|
-
// Cache the picker in the XdsRoutingChild.
|
667
|
-
xds_routing_child_->picker_wrapper_ = MakeRefCounted<ChildPickerWrapper>(
|
668
|
-
xds_routing_child_->name_, std::move(picker));
|
669
|
-
// Decide what state to report for aggregation purposes.
|
670
|
-
// If we haven't seen a failure since the last time we were in state
|
671
|
-
// READY, then we report the state change as-is. However, once we do see
|
672
|
-
// a failure, we report TRANSIENT_FAILURE and ignore any subsequent state
|
673
|
-
// changes until we go back into state READY.
|
674
|
-
if (!xds_routing_child_->seen_failure_since_ready_) {
|
675
|
-
if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
|
676
|
-
xds_routing_child_->seen_failure_since_ready_ = true;
|
677
|
-
}
|
678
|
-
} else {
|
679
|
-
if (state != GRPC_CHANNEL_READY) return;
|
680
|
-
xds_routing_child_->seen_failure_since_ready_ = false;
|
681
|
-
}
|
682
|
-
xds_routing_child_->connectivity_state_ = state;
|
683
|
-
// Notify the LB policy.
|
684
|
-
xds_routing_child_->xds_routing_policy_->UpdateStateLocked();
|
685
|
-
}
|
686
|
-
|
687
|
-
void XdsRoutingLb::XdsRoutingChild::Helper::RequestReresolution() {
|
688
|
-
if (xds_routing_child_->xds_routing_policy_->shutting_down_) return;
|
689
|
-
xds_routing_child_->xds_routing_policy_->channel_control_helper()
|
690
|
-
->RequestReresolution();
|
691
|
-
}
|
692
|
-
|
693
|
-
void XdsRoutingLb::XdsRoutingChild::Helper::AddTraceEvent(
|
694
|
-
TraceSeverity severity, absl::string_view message) {
|
695
|
-
if (xds_routing_child_->xds_routing_policy_->shutting_down_) return;
|
696
|
-
xds_routing_child_->xds_routing_policy_->channel_control_helper()
|
697
|
-
->AddTraceEvent(severity, message);
|
698
|
-
}
|
699
|
-
|
700
|
-
//
|
701
|
-
// factory
|
702
|
-
//
|
703
|
-
|
704
|
-
class XdsRoutingLbFactory : public LoadBalancingPolicyFactory {
|
705
|
-
public:
|
706
|
-
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
|
707
|
-
LoadBalancingPolicy::Args args) const override {
|
708
|
-
return MakeOrphanable<XdsRoutingLb>(std::move(args));
|
709
|
-
}
|
710
|
-
|
711
|
-
const char* name() const override { return kXdsRouting; }
|
712
|
-
|
713
|
-
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
|
714
|
-
const Json& json, grpc_error** error) const override {
|
715
|
-
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
|
716
|
-
if (json.type() == Json::Type::JSON_NULL) {
|
717
|
-
// xds_routing was mentioned as a policy in the deprecated
|
718
|
-
// loadBalancingPolicy field or in the client API.
|
719
|
-
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
720
|
-
"field:loadBalancingPolicy error:xds_routing policy requires "
|
721
|
-
"configuration. Please use loadBalancingConfig field of service "
|
722
|
-
"config instead.");
|
723
|
-
return nullptr;
|
724
|
-
}
|
725
|
-
std::vector<grpc_error*> error_list;
|
726
|
-
// action map.
|
727
|
-
XdsRoutingLbConfig::ActionMap action_map;
|
728
|
-
std::set<std::string /*action_name*/> actions_to_be_used;
|
729
|
-
auto it = json.object_value().find("actions");
|
730
|
-
if (it == json.object_value().end()) {
|
731
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
732
|
-
"field:actions error:required field not present"));
|
733
|
-
} else if (it->second.type() != Json::Type::OBJECT) {
|
734
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
735
|
-
"field:actions error:type should be object"));
|
736
|
-
} else {
|
737
|
-
for (const auto& p : it->second.object_value()) {
|
738
|
-
if (p.first.empty()) {
|
739
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
740
|
-
"field:actions element error: name cannot be empty"));
|
741
|
-
continue;
|
742
|
-
}
|
743
|
-
RefCountedPtr<LoadBalancingPolicy::Config> child_config;
|
744
|
-
std::vector<grpc_error*> child_errors =
|
745
|
-
ParseChildConfig(p.second, &child_config);
|
746
|
-
if (!child_errors.empty()) {
|
747
|
-
// Can't use GRPC_ERROR_CREATE_FROM_VECTOR() here, because the error
|
748
|
-
// string is not static in this case.
|
749
|
-
grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
750
|
-
absl::StrCat("field:actions name:", p.first).c_str());
|
751
|
-
for (grpc_error* child_error : child_errors) {
|
752
|
-
error = grpc_error_add_child(error, child_error);
|
753
|
-
}
|
754
|
-
error_list.push_back(error);
|
755
|
-
} else {
|
756
|
-
action_map[p.first] = std::move(child_config);
|
757
|
-
actions_to_be_used.insert(p.first);
|
758
|
-
}
|
759
|
-
}
|
760
|
-
}
|
761
|
-
if (action_map.empty()) {
|
762
|
-
error_list.push_back(
|
763
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("no valid actions configured"));
|
764
|
-
}
|
765
|
-
XdsRoutingLbConfig::RouteTable route_table;
|
766
|
-
it = json.object_value().find("routes");
|
767
|
-
if (it == json.object_value().end()) {
|
768
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
769
|
-
"field:routes error:required field not present"));
|
770
|
-
} else if (it->second.type() != Json::Type::ARRAY) {
|
771
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
772
|
-
"field:routes error:type should be array"));
|
773
|
-
} else {
|
774
|
-
const Json::Array& array = it->second.array_value();
|
775
|
-
for (size_t i = 0; i < array.size(); ++i) {
|
776
|
-
XdsRoutingLbConfig::Route route;
|
777
|
-
std::vector<grpc_error*> route_errors =
|
778
|
-
ParseRoute(array[i], action_map, &route, &actions_to_be_used);
|
779
|
-
if (!route_errors.empty()) {
|
780
|
-
// Can't use GRPC_ERROR_CREATE_FROM_VECTOR() here, because the error
|
781
|
-
// string is not static in this case.
|
782
|
-
grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
783
|
-
absl::StrCat("field:routes element: ", i, " error").c_str());
|
784
|
-
for (grpc_error* route_error : route_errors) {
|
785
|
-
error = grpc_error_add_child(error, route_error);
|
786
|
-
}
|
787
|
-
error_list.push_back(error);
|
788
|
-
}
|
789
|
-
route_table.emplace_back(std::move(route));
|
790
|
-
}
|
791
|
-
}
|
792
|
-
if (route_table.empty()) {
|
793
|
-
grpc_error* error =
|
794
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("no valid routes configured");
|
795
|
-
error_list.push_back(error);
|
796
|
-
}
|
797
|
-
if (!actions_to_be_used.empty()) {
|
798
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
799
|
-
"some actions were not referenced by any route"));
|
800
|
-
}
|
801
|
-
if (!error_list.empty()) {
|
802
|
-
*error = GRPC_ERROR_CREATE_FROM_VECTOR(
|
803
|
-
"xds_routing_experimental LB policy config", &error_list);
|
804
|
-
return nullptr;
|
805
|
-
}
|
806
|
-
return MakeRefCounted<XdsRoutingLbConfig>(std::move(action_map),
|
807
|
-
std::move(route_table));
|
808
|
-
}
|
809
|
-
|
810
|
-
private:
|
811
|
-
static std::vector<grpc_error*> ParseChildConfig(
|
812
|
-
const Json& json,
|
813
|
-
RefCountedPtr<LoadBalancingPolicy::Config>* child_config) {
|
814
|
-
std::vector<grpc_error*> error_list;
|
815
|
-
if (json.type() != Json::Type::OBJECT) {
|
816
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
817
|
-
"value should be of type object"));
|
818
|
-
return error_list;
|
819
|
-
}
|
820
|
-
auto it = json.object_value().find("childPolicy");
|
821
|
-
if (it == json.object_value().end()) {
|
822
|
-
error_list.push_back(
|
823
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("did not find childPolicy"));
|
824
|
-
} else {
|
825
|
-
grpc_error* parse_error = GRPC_ERROR_NONE;
|
826
|
-
*child_config = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
|
827
|
-
it->second, &parse_error);
|
828
|
-
if (*child_config == nullptr) {
|
829
|
-
GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE);
|
830
|
-
std::vector<grpc_error*> child_errors;
|
831
|
-
child_errors.push_back(parse_error);
|
832
|
-
error_list.push_back(
|
833
|
-
GRPC_ERROR_CREATE_FROM_VECTOR("field:childPolicy", &child_errors));
|
834
|
-
}
|
835
|
-
}
|
836
|
-
return error_list;
|
837
|
-
}
|
838
|
-
|
839
|
-
static std::vector<grpc_error*> ParseRoute(
|
840
|
-
const Json& json, const XdsRoutingLbConfig::ActionMap& action_map,
|
841
|
-
XdsRoutingLbConfig::Route* route,
|
842
|
-
std::set<std::string /*action_name*/>* actions_to_be_used) {
|
843
|
-
std::vector<grpc_error*> error_list;
|
844
|
-
if (json.type() != Json::Type::OBJECT) {
|
845
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
846
|
-
"value should be of type object"));
|
847
|
-
return error_list;
|
848
|
-
}
|
849
|
-
// Parse and ensure one and only one path matcher is set: prefix, path, or
|
850
|
-
// regex.
|
851
|
-
bool path_matcher_seen = false;
|
852
|
-
auto it = json.object_value().find("prefix");
|
853
|
-
if (it != json.object_value().end()) {
|
854
|
-
if (it->second.type() != Json::Type::STRING) {
|
855
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
856
|
-
"field:prefix error: should be string"));
|
857
|
-
} else {
|
858
|
-
path_matcher_seen = true;
|
859
|
-
route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
|
860
|
-
Matchers::PathMatcher::PathMatcherType::PREFIX;
|
861
|
-
route->matchers.path_matcher.string_matcher = it->second.string_value();
|
862
|
-
}
|
863
|
-
}
|
864
|
-
it = json.object_value().find("path");
|
865
|
-
if (it != json.object_value().end()) {
|
866
|
-
if (path_matcher_seen) {
|
867
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
868
|
-
"field:path error: other path matcher already specified"));
|
869
|
-
} else {
|
870
|
-
path_matcher_seen = true;
|
871
|
-
if (it->second.type() != Json::Type::STRING) {
|
872
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
873
|
-
"field:path error: should be string"));
|
874
|
-
} else {
|
875
|
-
route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
|
876
|
-
Matchers::PathMatcher::PathMatcherType::PATH;
|
877
|
-
route->matchers.path_matcher.string_matcher =
|
878
|
-
it->second.string_value();
|
879
|
-
}
|
880
|
-
}
|
881
|
-
}
|
882
|
-
it = json.object_value().find("regex");
|
883
|
-
if (it != json.object_value().end()) {
|
884
|
-
if (path_matcher_seen) {
|
885
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
886
|
-
"field:regex error: other path matcher already specified"));
|
887
|
-
} else {
|
888
|
-
path_matcher_seen = true;
|
889
|
-
if (it->second.type() != Json::Type::STRING) {
|
890
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
891
|
-
"field:regex error: should be string"));
|
892
|
-
} else {
|
893
|
-
route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
|
894
|
-
Matchers::PathMatcher::PathMatcherType::REGEX;
|
895
|
-
route->matchers.path_matcher.regex_matcher =
|
896
|
-
absl::make_unique<RE2>(it->second.string_value());
|
897
|
-
}
|
898
|
-
}
|
899
|
-
}
|
900
|
-
if (!path_matcher_seen) {
|
901
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
902
|
-
"one path matcher: prefix, path, or regex is required"));
|
903
|
-
}
|
904
|
-
// Parse Header Matcher: headers.
|
905
|
-
it = json.object_value().find("headers");
|
906
|
-
if (it != json.object_value().end()) {
|
907
|
-
if (it->second.type() != Json::Type::ARRAY) {
|
908
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
909
|
-
"field:headers error: should be array"));
|
910
|
-
} else {
|
911
|
-
const Json::Array& array = it->second.array_value();
|
912
|
-
for (size_t i = 0; i < array.size(); ++i) {
|
913
|
-
const Json& header_json = array[i];
|
914
|
-
if (header_json.type() != Json::Type::OBJECT) {
|
915
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
916
|
-
"value should be of type object"));
|
917
|
-
} else {
|
918
|
-
route->matchers.header_matchers.emplace_back();
|
919
|
-
XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher&
|
920
|
-
header_matcher = route->matchers.header_matchers.back();
|
921
|
-
auto header_it = header_json.object_value().find("name");
|
922
|
-
if (header_it == header_json.object_value().end()) {
|
923
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
924
|
-
"field:name error:required field missing"));
|
925
|
-
} else {
|
926
|
-
if (header_it->second.type() != Json::Type::STRING) {
|
927
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
928
|
-
"field:name error: should be string"));
|
929
|
-
} else {
|
930
|
-
header_matcher.name = header_it->second.string_value();
|
931
|
-
}
|
932
|
-
}
|
933
|
-
header_it = header_json.object_value().find("invert_match");
|
934
|
-
if (header_it != header_json.object_value().end()) {
|
935
|
-
if (header_it->second.type() == Json::Type::JSON_TRUE) {
|
936
|
-
header_matcher.invert_match = true;
|
937
|
-
} else if (header_it->second.type() == Json::Type::JSON_FALSE) {
|
938
|
-
header_matcher.invert_match = false;
|
939
|
-
} else {
|
940
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
941
|
-
"field:present_match error: should be boolean"));
|
942
|
-
}
|
943
|
-
}
|
944
|
-
// Parse and ensure one and only one header matcher is set per
|
945
|
-
// header matcher.
|
946
|
-
bool header_matcher_seen = false;
|
947
|
-
header_it = header_json.object_value().find("exact_match");
|
948
|
-
if (header_it != header_json.object_value().end()) {
|
949
|
-
header_matcher_seen = true;
|
950
|
-
if (header_it->second.type() != Json::Type::STRING) {
|
951
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
952
|
-
"field:exact_match error: should be string"));
|
953
|
-
} else {
|
954
|
-
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
955
|
-
HeaderMatcher::HeaderMatcherType::EXACT;
|
956
|
-
header_matcher.string_matcher =
|
957
|
-
header_it->second.string_value();
|
958
|
-
}
|
959
|
-
}
|
960
|
-
header_it = header_json.object_value().find("regex_match");
|
961
|
-
if (header_it != header_json.object_value().end()) {
|
962
|
-
if (header_matcher_seen) {
|
963
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
964
|
-
"field:regex_match error: other header matcher already "
|
965
|
-
"specified"));
|
966
|
-
} else {
|
967
|
-
header_matcher_seen = true;
|
968
|
-
if (header_it->second.type() != Json::Type::STRING) {
|
969
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
970
|
-
"field:regex_match error: should be string"));
|
971
|
-
} else {
|
972
|
-
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
973
|
-
HeaderMatcher::HeaderMatcherType::REGEX;
|
974
|
-
header_matcher.regex_match =
|
975
|
-
absl::make_unique<RE2>(header_it->second.string_value());
|
976
|
-
}
|
977
|
-
}
|
978
|
-
}
|
979
|
-
header_it = header_json.object_value().find("range_match");
|
980
|
-
if (header_it != header_json.object_value().end()) {
|
981
|
-
if (header_matcher_seen) {
|
982
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
983
|
-
"field:range_match error: other header matcher already "
|
984
|
-
"specified"));
|
985
|
-
} else {
|
986
|
-
header_matcher_seen = true;
|
987
|
-
if (header_it->second.type() != Json::Type::OBJECT) {
|
988
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
989
|
-
"field:range_match error: should be object"));
|
990
|
-
} else {
|
991
|
-
auto range_it =
|
992
|
-
header_it->second.object_value().find("start");
|
993
|
-
if (range_it != header_it->second.object_value().end()) {
|
994
|
-
if (range_it->second.type() != Json::Type::NUMBER) {
|
995
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
996
|
-
"field:start error: should be of number"));
|
997
|
-
} else {
|
998
|
-
header_matcher.range_start = gpr_parse_nonnegative_int(
|
999
|
-
range_it->second.string_value().c_str());
|
1000
|
-
}
|
1001
|
-
} else {
|
1002
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1003
|
-
"field:start missing"));
|
1004
|
-
}
|
1005
|
-
range_it = header_it->second.object_value().find("end");
|
1006
|
-
if (range_it != header_it->second.object_value().end()) {
|
1007
|
-
if (range_it->second.type() != Json::Type::NUMBER) {
|
1008
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1009
|
-
"field:end error: should be of number"));
|
1010
|
-
} else {
|
1011
|
-
header_matcher.range_end = gpr_parse_nonnegative_int(
|
1012
|
-
range_it->second.string_value().c_str());
|
1013
|
-
}
|
1014
|
-
} else {
|
1015
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1016
|
-
"field:end missing"));
|
1017
|
-
}
|
1018
|
-
if (header_matcher.range_end > header_matcher.range_start) {
|
1019
|
-
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::
|
1020
|
-
Matchers::HeaderMatcher::HeaderMatcherType::RANGE;
|
1021
|
-
}
|
1022
|
-
}
|
1023
|
-
}
|
1024
|
-
}
|
1025
|
-
header_it = header_json.object_value().find("present_match");
|
1026
|
-
if (header_it != header_json.object_value().end()) {
|
1027
|
-
if (header_matcher_seen) {
|
1028
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1029
|
-
"field:present_match error: other header matcher already "
|
1030
|
-
"specified"));
|
1031
|
-
} else {
|
1032
|
-
header_matcher_seen = true;
|
1033
|
-
if (header_it->second.type() == Json::Type::JSON_TRUE) {
|
1034
|
-
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1035
|
-
HeaderMatcher::HeaderMatcherType::PRESENT;
|
1036
|
-
header_matcher.present_match = true;
|
1037
|
-
} else if (header_it->second.type() == Json::Type::JSON_FALSE) {
|
1038
|
-
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1039
|
-
HeaderMatcher::HeaderMatcherType::PRESENT;
|
1040
|
-
header_matcher.present_match = false;
|
1041
|
-
} else {
|
1042
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1043
|
-
"field:present_match error: should be boolean"));
|
1044
|
-
}
|
1045
|
-
}
|
1046
|
-
}
|
1047
|
-
header_it = header_json.object_value().find("prefix_match");
|
1048
|
-
if (header_it != header_json.object_value().end()) {
|
1049
|
-
if (header_matcher_seen) {
|
1050
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1051
|
-
"field:prefix_match error: other header matcher already "
|
1052
|
-
"specified"));
|
1053
|
-
} else {
|
1054
|
-
header_matcher_seen = true;
|
1055
|
-
if (header_it->second.type() != Json::Type::STRING) {
|
1056
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1057
|
-
"field:prefix_match error: should be string"));
|
1058
|
-
} else {
|
1059
|
-
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1060
|
-
HeaderMatcher::HeaderMatcherType::PREFIX;
|
1061
|
-
header_matcher.string_matcher =
|
1062
|
-
header_it->second.string_value();
|
1063
|
-
}
|
1064
|
-
}
|
1065
|
-
}
|
1066
|
-
header_it = header_json.object_value().find("suffix_match");
|
1067
|
-
if (header_it != header_json.object_value().end()) {
|
1068
|
-
if (header_matcher_seen) {
|
1069
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1070
|
-
"field:suffix_match error: other header matcher already "
|
1071
|
-
"specified"));
|
1072
|
-
} else {
|
1073
|
-
header_matcher_seen = true;
|
1074
|
-
if (header_it->second.type() != Json::Type::STRING) {
|
1075
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1076
|
-
"field:suffix_match error: should be string"));
|
1077
|
-
} else {
|
1078
|
-
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1079
|
-
HeaderMatcher::HeaderMatcherType::SUFFIX;
|
1080
|
-
header_matcher.string_matcher =
|
1081
|
-
header_it->second.string_value();
|
1082
|
-
}
|
1083
|
-
}
|
1084
|
-
}
|
1085
|
-
}
|
1086
|
-
}
|
1087
|
-
}
|
1088
|
-
}
|
1089
|
-
// Parse Fraction numerator.
|
1090
|
-
it = json.object_value().find("match_fraction");
|
1091
|
-
if (it != json.object_value().end()) {
|
1092
|
-
if (it->second.type() != Json::Type::NUMBER) {
|
1093
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1094
|
-
"field:match_fraction error:must be of type number"));
|
1095
|
-
} else {
|
1096
|
-
route->matchers.fraction_per_million =
|
1097
|
-
gpr_parse_nonnegative_int(it->second.string_value().c_str());
|
1098
|
-
}
|
1099
|
-
}
|
1100
|
-
// Parse action.
|
1101
|
-
it = json.object_value().find("action");
|
1102
|
-
if (it == json.object_value().end()) {
|
1103
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1104
|
-
"field:action error:required field missing"));
|
1105
|
-
} else if (it->second.type() != Json::Type::STRING) {
|
1106
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1107
|
-
"field:action error:should be of type string"));
|
1108
|
-
} else {
|
1109
|
-
route->action = it->second.string_value();
|
1110
|
-
if (route->action.empty()) {
|
1111
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1112
|
-
"field:action error:cannot be empty"));
|
1113
|
-
} else {
|
1114
|
-
// Validate action exists and mark it as used.
|
1115
|
-
if (action_map.find(route->action) == action_map.end()) {
|
1116
|
-
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1117
|
-
absl::StrCat("field:action error:", route->action,
|
1118
|
-
" does not exist")
|
1119
|
-
.c_str()));
|
1120
|
-
}
|
1121
|
-
actions_to_be_used->erase(route->action);
|
1122
|
-
}
|
1123
|
-
}
|
1124
|
-
return error_list;
|
1125
|
-
}
|
1126
|
-
};
|
1127
|
-
|
1128
|
-
} // namespace
|
1129
|
-
|
1130
|
-
} // namespace grpc_core
|
1131
|
-
|
1132
|
-
//
|
1133
|
-
// Plugin registration
|
1134
|
-
//
|
1135
|
-
|
1136
|
-
void grpc_lb_policy_xds_routing_init() {
|
1137
|
-
grpc_core::LoadBalancingPolicyRegistry::Builder::
|
1138
|
-
RegisterLoadBalancingPolicyFactory(
|
1139
|
-
absl::make_unique<grpc_core::XdsRoutingLbFactory>());
|
1140
|
-
}
|
1141
|
-
|
1142
|
-
void grpc_lb_policy_xds_routing_shutdown() {}
|