grpc 1.73.0 → 1.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +38 -17
- data/include/grpc/create_channel_from_endpoint.h +54 -0
- data/include/grpc/credentials.h +11 -5
- data/include/grpc/event_engine/event_engine.h +74 -17
- data/include/grpc/grpc_posix.h +20 -1
- data/include/grpc/impl/channel_arg_names.h +2 -4
- data/include/grpc/module.modulemap +1 -0
- data/include/grpc/support/json.h +24 -0
- data/src/core/call/interception_chain.h +7 -11
- data/src/core/channelz/channel_trace.cc +213 -115
- data/src/core/channelz/channel_trace.h +380 -86
- data/src/core/channelz/channelz.cc +270 -181
- data/src/core/channelz/channelz.h +168 -55
- data/src/core/channelz/channelz_registry.cc +2 -1
- data/src/core/channelz/channelz_registry.h +24 -0
- data/src/core/channelz/property_list.cc +357 -0
- data/src/core/channelz/property_list.h +202 -0
- data/src/core/channelz/ztrace_collector.h +3 -2
- data/src/core/client_channel/backup_poller.cc +17 -2
- data/src/core/client_channel/client_channel.cc +17 -28
- data/src/core/client_channel/client_channel_filter.cc +19 -29
- data/src/core/client_channel/config_selector.h +8 -2
- data/src/core/client_channel/dynamic_filters.cc +5 -6
- data/src/core/client_channel/dynamic_filters.h +1 -1
- data/src/core/client_channel/global_subchannel_pool.cc +4 -1
- data/src/core/client_channel/retry_filter.cc +21 -27
- data/src/core/client_channel/retry_filter.h +10 -7
- data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -5
- data/src/core/client_channel/retry_filter_legacy_call_data.h +1 -1
- data/src/core/client_channel/retry_interceptor.cc +30 -44
- data/src/core/client_channel/retry_interceptor.h +18 -17
- data/src/core/client_channel/retry_throttle.cc +46 -61
- data/src/core/client_channel/retry_throttle.h +17 -39
- data/src/core/client_channel/subchannel.cc +43 -19
- data/src/core/client_channel/subchannel.h +8 -0
- data/src/core/config/config_vars.cc +2 -0
- data/src/core/config/core_configuration.cc +1 -0
- data/src/core/config/core_configuration.h +11 -0
- data/src/core/credentials/call/call_creds_registry.h +125 -0
- data/src/core/credentials/call/call_creds_registry_init.cc +91 -0
- data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +6 -48
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +86 -0
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h +74 -0
- data/src/core/credentials/call/jwt_util.cc +70 -0
- data/src/core/credentials/call/jwt_util.h +32 -0
- data/src/core/credentials/transport/channel_creds_registry_init.cc +1 -1
- data/src/core/credentials/transport/google_default/google_default_credentials.cc +72 -4
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +0 -1
- data/src/core/credentials/transport/tls/load_system_roots_supported.cc +1 -0
- data/src/core/credentials/transport/xds/xds_credentials.cc +0 -3
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +8 -8
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +16 -16
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/compression_filter.h +25 -22
- data/src/core/ext/filters/http/server/http_server_filter.h +12 -11
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +120 -35
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +162 -115
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +0 -3
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +1239 -3514
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1008 -1486
- data/src/core/ext/transport/chttp2/transport/flow_control.h +22 -17
- data/src/core/ext/transport/chttp2/transport/frame.cc +10 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/header_assembler.h +299 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +11 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +12 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +1017 -0
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +593 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +19 -22
- data/{third_party/abseil-cpp/absl/strings/cord_buffer.cc → src/core/ext/transport/chttp2/transport/http2_stats_collector.cc} +14 -14
- data/src/core/ext/transport/chttp2/transport/http2_stats_collector.h +33 -0
- data/src/core/ext/transport/chttp2/transport/http2_status.h +6 -1
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +43 -0
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +65 -0
- data/src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h +0 -29
- data/src/core/ext/transport/chttp2/transport/internal.h +18 -8
- data/src/core/ext/transport/chttp2/transport/keepalive.cc +105 -0
- data/src/core/ext/transport/chttp2/transport/keepalive.h +138 -0
- data/src/core/ext/transport/chttp2/transport/message_assembler.h +185 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -4
- data/src/core/ext/transport/chttp2/transport/ping_callbacks.h +19 -0
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +151 -0
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +180 -0
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +5 -9
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +11 -0
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +39 -1
- data/src/core/ext/transport/chttp2/transport/transport_common.cc +19 -0
- data/src/core/ext/transport/chttp2/transport/transport_common.h +27 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +37 -11
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb.h +571 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb_minitable.c +120 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb_minitable.h +36 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb.h +1272 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb_minitable.c +312 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb_minitable.h +50 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +984 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +226 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +44 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/promise.upbdefs.c +175 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/promise.upbdefs.h +82 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +135 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +67 -0
- data/src/core/filter/auth/auth_filters.h +0 -25
- data/src/core/filter/auth/client_auth_filter.cc +0 -118
- data/src/core/filter/filter_args.h +9 -23
- data/src/core/handshaker/handshaker.cc +23 -14
- data/src/core/handshaker/handshaker.h +3 -0
- data/src/core/handshaker/http_connect/http_connect_handshaker.cc +3 -1
- data/src/core/handshaker/security/legacy_secure_endpoint.cc +6 -5
- data/src/core/handshaker/security/secure_endpoint.cc +70 -25
- data/src/core/handshaker/security/security_handshaker.cc +4 -1
- data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +7 -1
- data/src/core/lib/channel/channel_args.cc +15 -0
- data/src/core/lib/channel/channel_args.h +3 -0
- data/src/core/lib/channel/channel_stack.cc +22 -23
- data/src/core/lib/channel/channel_stack.h +9 -7
- data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -1
- data/src/core/lib/channel/channel_stack_builder_impl.h +2 -7
- data/src/core/lib/channel/promise_based_filter.h +5 -5
- data/src/core/lib/debug/trace_impl.h +0 -1
- data/src/core/lib/event_engine/ares_resolver.cc +165 -46
- data/src/core/lib/event_engine/ares_resolver.h +48 -2
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +3 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +1 -4
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +2 -6
- data/src/core/lib/event_engine/endpoint_channel_arg_wrapper.cc +40 -0
- data/src/core/lib/event_engine/endpoint_channel_arg_wrapper.h +60 -0
- data/src/core/lib/event_engine/event_engine.cc +7 -0
- data/src/core/lib/event_engine/extensions/channelz.h +10 -6
- data/src/core/lib/event_engine/grpc_polled_fd.h +5 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +130 -162
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +11 -15
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +75 -117
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -9
- data/src/core/lib/event_engine/posix_engine/event_poller.h +18 -15
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +0 -18
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +124 -0
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.h +243 -0
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +29 -19
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.cc +6 -2
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.h +6 -1
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +145 -92
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -19
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +333 -116
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +61 -18
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +45 -37
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +6 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +32 -142
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h +6 -5
- data/src/core/lib/event_engine/posix_engine/posix_interface.h +211 -0
- data/src/core/lib/event_engine/posix_engine/posix_interface_posix.cc +1083 -0
- data/src/core/lib/event_engine/posix_engine/posix_interface_windows.cc +281 -0
- data/src/core/lib/event_engine/posix_engine/posix_write_event_sink.cc +154 -0
- data/src/core/lib/event_engine/posix_engine/posix_write_event_sink.h +174 -0
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -719
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +10 -170
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +33 -22
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +13 -11
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +117 -151
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +26 -94
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc +26 -25
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h +6 -2
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc +36 -62
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h +6 -2
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h +7 -6
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc +12 -6
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h +3 -1
- data/src/core/lib/event_engine/shim.cc +9 -0
- data/src/core/lib/event_engine/shim.h +3 -0
- data/src/core/lib/event_engine/thread_pool/thread_pool.h +7 -3
- data/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +0 -17
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +4 -2
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +3 -2
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +4 -0
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h +4 -0
- data/src/core/lib/event_engine/windows/windows_endpoint.h +2 -6
- data/src/core/lib/event_engine/windows/windows_engine.cc +0 -1
- data/src/core/lib/event_engine/windows/windows_engine.h +1 -3
- data/src/core/lib/event_engine/windows/windows_listener.cc +14 -2
- data/src/core/lib/experiments/experiments.cc +45 -93
- data/src/core/lib/experiments/experiments.h +21 -51
- data/src/core/lib/iomgr/endpoint.cc +4 -3
- data/src/core/lib/iomgr/endpoint.h +7 -4
- data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +7 -2
- data/src/core/lib/iomgr/ev_poll_posix.cc +7 -2
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +4 -6
- data/src/core/lib/iomgr/tcp_posix.cc +12 -6
- data/src/core/lib/iomgr/tcp_windows.cc +3 -2
- data/src/core/lib/promise/activity.h +1 -0
- data/src/core/lib/promise/arena_promise.h +23 -7
- data/src/core/lib/promise/detail/promise_factory.h +10 -0
- data/src/core/lib/promise/detail/promise_like.h +118 -11
- data/src/core/lib/promise/detail/promise_variant.h +50 -0
- data/src/core/lib/promise/detail/seq_state.h +687 -548
- data/src/core/lib/promise/if.h +20 -0
- data/src/core/lib/promise/inter_activity_latch.h +147 -0
- data/src/core/lib/promise/inter_activity_mutex.h +547 -0
- data/src/core/lib/promise/loop.h +65 -3
- data/src/core/lib/promise/map.h +24 -0
- data/src/core/lib/promise/match_promise.h +103 -0
- data/src/core/lib/promise/mpsc.cc +425 -0
- data/src/core/lib/promise/mpsc.h +490 -0
- data/src/core/lib/promise/party.cc +50 -1
- data/src/core/lib/promise/party.h +66 -1
- data/src/core/lib/promise/race.h +31 -0
- data/src/core/lib/promise/seq.h +4 -1
- data/src/core/lib/promise/status_flag.h +7 -0
- data/src/core/lib/promise/try_seq.h +4 -1
- data/src/core/lib/promise/wait_set.cc +28 -0
- data/src/core/lib/promise/wait_set.h +86 -0
- data/src/core/lib/resource_quota/arena.h +19 -0
- data/src/core/lib/slice/slice.h +5 -0
- data/src/core/lib/surface/channel_create.cc +88 -13
- data/src/core/lib/surface/channel_create.h +4 -0
- data/src/core/lib/surface/channel_init.cc +164 -47
- data/src/core/lib/surface/channel_init.h +64 -1
- data/src/core/lib/surface/filter_stack_call.cc +18 -9
- data/src/core/lib/surface/init.cc +6 -15
- data/src/core/lib/surface/legacy_channel.cc +3 -5
- data/src/core/lib/surface/legacy_channel.h +3 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.cc +110 -0
- data/src/core/lib/transport/promise_endpoint.h +307 -0
- data/src/core/load_balancing/child_policy_handler.cc +2 -4
- data/src/core/load_balancing/delegating_helper.h +2 -3
- data/src/core/load_balancing/health_check_client.cc +1 -5
- data/src/core/load_balancing/lb_policy.h +1 -3
- data/src/core/load_balancing/oob_backend_metric.cc +1 -5
- data/src/core/load_balancing/pick_first/pick_first.cc +3 -0
- data/src/core/load_balancing/xds/cds.cc +10 -1
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
- data/src/core/resolver/xds/xds_config.cc +6 -3
- data/src/core/resolver/xds/xds_config.h +9 -4
- data/src/core/resolver/xds/xds_dependency_manager.cc +21 -6
- data/src/core/resolver/xds/xds_dependency_manager.h +2 -1
- data/src/core/resolver/xds/xds_resolver.cc +31 -11
- data/src/core/server/server.cc +83 -12
- data/src/core/server/server.h +21 -2
- data/src/core/server/xds_server_config_fetcher.cc +63 -25
- data/src/core/service_config/service_config.h +1 -1
- data/src/core/service_config/service_config_impl.h +1 -1
- data/src/core/telemetry/context_list_entry.cc +38 -0
- data/src/core/telemetry/context_list_entry.h +42 -12
- data/src/core/telemetry/stats_data.cc +233 -207
- data/src/core/telemetry/stats_data.h +250 -153
- data/src/core/telemetry/tcp_tracer.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +11 -3
- data/src/core/tsi/fake_transport_security.cc +17 -0
- data/src/core/tsi/ssl_transport_security.cc +2 -0
- data/src/core/tsi/transport_security_grpc.cc +8 -0
- data/src/core/tsi/transport_security_grpc.h +15 -0
- data/src/core/util/backoff.cc +1 -5
- data/src/core/util/backoff.h +1 -0
- data/src/core/util/down_cast.h +1 -1
- data/src/core/util/function_signature.h +15 -1
- data/src/core/util/http_client/httpcli.cc +12 -5
- data/src/core/util/http_client/httpcli.h +4 -1
- data/src/core/util/latent_see.h +8 -5
- data/src/core/util/log.cc +4 -0
- data/src/core/util/memory_usage.h +268 -0
- data/src/core/util/per_cpu.cc +2 -0
- data/src/core/util/per_cpu.h +7 -0
- data/src/core/util/shared_bit_gen.h +20 -0
- data/src/core/util/single_set_ptr.h +2 -2
- data/src/core/util/upb_utils.h +42 -0
- data/src/core/util/uri.cc +3 -2
- data/src/core/util/useful.h +53 -2
- data/src/core/util/wait_for_single_owner.cc +31 -0
- data/src/core/util/wait_for_single_owner.h +24 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc.h +5 -0
- data/src/core/xds/grpc/xds_client_grpc.cc +6 -2
- data/src/core/xds/grpc/xds_common_types_parser.cc +138 -50
- data/src/core/xds/grpc/xds_common_types_parser.h +12 -0
- data/src/core/xds/grpc/xds_http_filter.h +7 -0
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +22 -0
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -0
- data/src/core/xds/grpc/xds_route_config_parser.cc +15 -38
- data/src/core/xds/grpc/xds_server_grpc.cc +63 -13
- data/src/core/xds/grpc/xds_server_grpc.h +10 -2
- data/src/core/xds/grpc/xds_server_grpc_interface.h +4 -0
- data/src/core/xds/grpc/xds_transport_grpc.cc +18 -0
- data/src/core/xds/xds_client/xds_bootstrap.h +2 -0
- data/src/core/xds/xds_client/xds_client.cc +26 -5
- data/src/ruby/ext/grpc/extconf.rb +2 -0
- data/src/ruby/ext/grpc/rb_call.c +1 -8
- data/src/ruby/ext/grpc/rb_channel.c +72 -568
- data/src/ruby/ext/grpc/rb_channel.h +0 -3
- data/src/ruby/ext/grpc/rb_completion_queue.c +26 -14
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -7
- data/src/ruby/ext/grpc/rb_grpc.c +9 -5
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/ext/grpc/rb_loader.c +0 -4
- data/src/ruby/ext/grpc/rb_server.c +31 -50
- data/src/ruby/lib/grpc/generic/client_stub.rb +4 -4
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/core_spec.rb +22 -0
- data/src/ruby/spec/generic/active_call_spec.rb +1 -1
- data/third_party/abseil-cpp/absl/algorithm/container.h +2 -19
- data/third_party/abseil-cpp/absl/base/attributes.h +76 -7
- data/third_party/abseil-cpp/absl/base/call_once.h +11 -12
- data/third_party/abseil-cpp/absl/base/config.h +20 -129
- data/third_party/abseil-cpp/absl/base/{internal/fast_type_id.h → fast_type_id.h} +11 -16
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +0 -5
- data/third_party/abseil-cpp/absl/base/internal/cycleclock_config.h +7 -7
- data/third_party/abseil-cpp/absl/base/internal/endian.h +34 -38
- data/third_party/abseil-cpp/absl/base/internal/iterator_traits.h +71 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +6 -5
- data/third_party/abseil-cpp/absl/base/internal/{nullability_impl.h → nullability_deprecated.h} +45 -8
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +0 -9
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +3 -13
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +6 -6
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +8 -3
- data/third_party/abseil-cpp/absl/base/no_destructor.h +11 -32
- data/third_party/abseil-cpp/absl/base/nullability.h +84 -72
- data/third_party/abseil-cpp/absl/base/options.h +3 -80
- data/third_party/abseil-cpp/absl/base/policy_checks.h +7 -7
- data/third_party/abseil-cpp/absl/cleanup/cleanup.h +1 -3
- data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -4
- data/third_party/abseil-cpp/absl/container/btree_map.h +4 -2
- data/third_party/abseil-cpp/absl/container/btree_set.h +4 -2
- data/third_party/abseil-cpp/absl/container/fixed_array.h +7 -14
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +5 -0
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +6 -1
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +8 -5
- data/third_party/abseil-cpp/absl/container/internal/btree.h +132 -29
- data/third_party/abseil-cpp/absl/container/internal/btree_container.h +175 -71
- data/third_party/abseil-cpp/absl/container/internal/common.h +43 -0
- data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -2
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +9 -10
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +1 -8
- data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +0 -4
- data/third_party/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +527 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +20 -4
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +31 -12
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +2 -7
- data/third_party/abseil-cpp/absl/container/internal/layout.h +26 -42
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +199 -68
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +1354 -183
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +881 -1424
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set_resize_impl.h +80 -0
- data/third_party/abseil-cpp/absl/crc/crc32c.cc +0 -4
- data/third_party/abseil-cpp/absl/crc/crc32c.h +7 -5
- data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +0 -22
- data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +45 -74
- data/third_party/abseil-cpp/absl/debugging/internal/addresses.h +57 -0
- data/third_party/abseil-cpp/absl/debugging/internal/decode_rust_punycode.cc +1 -1
- data/third_party/abseil-cpp/absl/debugging/internal/decode_rust_punycode.h +5 -5
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +8 -35
- data/third_party/abseil-cpp/absl/debugging/internal/demangle_rust.cc +16 -16
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +40 -37
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +16 -7
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +14 -5
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +10 -4
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +27 -16
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +13 -4
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +4 -3
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +15 -28
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +19 -9
- data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +144 -27
- data/third_party/abseil-cpp/absl/debugging/stacktrace.h +73 -5
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +19 -9
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +3 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +25 -6
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +2 -2
- data/third_party/abseil-cpp/absl/flags/flag.h +4 -3
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +2 -2
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +2 -1
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +7 -6
- data/third_party/abseil-cpp/absl/flags/internal/registry.h +4 -3
- data/third_party/abseil-cpp/absl/flags/reflection.cc +2 -3
- data/third_party/abseil-cpp/absl/functional/any_invocable.h +8 -10
- data/third_party/abseil-cpp/absl/functional/function_ref.h +2 -9
- data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +110 -226
- data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +10 -12
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +2 -5
- data/third_party/abseil-cpp/absl/hash/hash.h +18 -0
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +1 -5
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -61
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +25 -68
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.h +2 -6
- data/third_party/abseil-cpp/absl/hash/internal/weakly_mixed_integer.h +38 -0
- data/third_party/abseil-cpp/absl/log/check.h +2 -1
- data/third_party/abseil-cpp/absl/log/globals.h +4 -5
- data/third_party/abseil-cpp/absl/log/internal/append_truncated.h +28 -0
- data/third_party/abseil-cpp/absl/log/internal/check_op.cc +22 -22
- data/third_party/abseil-cpp/absl/log/internal/check_op.h +65 -62
- data/third_party/abseil-cpp/absl/log/internal/conditions.cc +5 -3
- data/third_party/abseil-cpp/absl/log/internal/conditions.h +7 -2
- data/third_party/abseil-cpp/absl/log/internal/log_message.cc +85 -43
- data/third_party/abseil-cpp/absl/log/internal/log_message.h +84 -59
- data/third_party/abseil-cpp/absl/log/internal/nullstream.h +1 -0
- data/third_party/abseil-cpp/absl/log/internal/proto.cc +3 -2
- data/third_party/abseil-cpp/absl/log/internal/proto.h +3 -3
- data/third_party/abseil-cpp/absl/log/internal/strip.h +4 -12
- data/third_party/abseil-cpp/absl/log/internal/vlog_config.h +8 -6
- data/third_party/abseil-cpp/absl/log/internal/voidify.h +10 -4
- data/third_party/abseil-cpp/absl/log/log.h +48 -35
- data/third_party/abseil-cpp/absl/log/log_sink_registry.h +2 -2
- data/third_party/abseil-cpp/absl/meta/type_traits.h +46 -175
- data/third_party/abseil-cpp/absl/numeric/bits.h +68 -2
- data/third_party/abseil-cpp/absl/numeric/int128.cc +0 -52
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +7 -3
- data/third_party/abseil-cpp/absl/profiling/internal/exponential_biased.cc +1 -1
- data/third_party/abseil-cpp/absl/random/bit_gen_ref.h +10 -11
- data/third_party/abseil-cpp/absl/random/distributions.h +6 -8
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +5 -6
- data/third_party/abseil-cpp/absl/random/internal/{pool_urbg.cc → entropy_pool.cc} +22 -90
- data/third_party/abseil-cpp/absl/random/internal/entropy_pool.h +35 -0
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +5 -6
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +1 -1
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +20 -12
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +5 -5
- data/third_party/abseil-cpp/absl/random/random.h +88 -53
- data/third_party/abseil-cpp/absl/random/seed_sequences.cc +6 -2
- data/third_party/abseil-cpp/absl/status/internal/status_internal.cc +3 -4
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +3 -4
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -3
- data/third_party/abseil-cpp/absl/status/status.cc +4 -8
- data/third_party/abseil-cpp/absl/status/status.h +8 -8
- data/third_party/abseil-cpp/absl/status/status_payload_printer.h +2 -2
- data/third_party/abseil-cpp/absl/status/statusor.cc +2 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +6 -6
- data/third_party/abseil-cpp/absl/strings/ascii.cc +9 -9
- data/third_party/abseil-cpp/absl/strings/ascii.h +18 -18
- data/third_party/abseil-cpp/absl/strings/charconv.cc +21 -22
- data/third_party/abseil-cpp/absl/strings/charconv.h +5 -5
- data/third_party/abseil-cpp/absl/strings/cord.cc +54 -58
- data/third_party/abseil-cpp/absl/strings/cord.h +94 -83
- data/third_party/abseil-cpp/absl/strings/cord_analysis.cc +11 -11
- data/third_party/abseil-cpp/absl/strings/cord_analysis.h +3 -3
- data/third_party/abseil-cpp/absl/strings/escaping.cc +130 -149
- data/third_party/abseil-cpp/absl/strings/escaping.h +9 -10
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +6 -8
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +0 -4
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +0 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +7 -63
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +1 -11
- data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +0 -22
- data/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc +5 -3
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +4 -2
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +3 -3
- data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +0 -5
- data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +96 -1
- data/third_party/abseil-cpp/absl/strings/internal/utf8.h +15 -1
- data/third_party/abseil-cpp/absl/strings/numbers.cc +53 -32
- data/third_party/abseil-cpp/absl/strings/numbers.h +87 -58
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +6 -7
- data/third_party/abseil-cpp/absl/strings/str_cat.h +32 -32
- data/third_party/abseil-cpp/absl/strings/str_format.h +18 -18
- data/third_party/abseil-cpp/absl/strings/str_replace.cc +3 -3
- data/third_party/abseil-cpp/absl/strings/str_replace.h +6 -6
- data/third_party/abseil-cpp/absl/strings/string_view.cc +4 -9
- data/third_party/abseil-cpp/absl/strings/string_view.h +27 -32
- data/third_party/abseil-cpp/absl/strings/strip.h +4 -4
- data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -4
- data/third_party/abseil-cpp/absl/strings/substitute.h +66 -64
- data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc +0 -5
- data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +1 -1
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +97 -69
- data/third_party/abseil-cpp/absl/synchronization/notification.h +1 -1
- data/third_party/abseil-cpp/absl/time/civil_time.cc +1 -0
- data/third_party/abseil-cpp/absl/time/duration.cc +12 -7
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +90 -111
- data/third_party/abseil-cpp/absl/time/time.h +20 -15
- data/third_party/abseil-cpp/absl/types/optional.h +7 -747
- data/third_party/abseil-cpp/absl/types/span.h +13 -11
- data/third_party/abseil-cpp/absl/types/variant.h +5 -784
- data/third_party/abseil-cpp/absl/utility/utility.h +10 -185
- metadata +72 -20
- data/src/core/lib/event_engine/forkable.cc +0 -105
- data/src/core/lib/event_engine/forkable.h +0 -67
- data/src/core/lib/iomgr/python_util.h +0 -46
- data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +0 -108
- data/third_party/abseil-cpp/absl/base/internal/invoke.h +0 -241
- data/third_party/abseil-cpp/absl/log/log_entry.cc +0 -41
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +0 -131
- data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +0 -66
- data/third_party/abseil-cpp/absl/types/bad_optional_access.h +0 -78
- data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +0 -82
- data/third_party/abseil-cpp/absl/types/bad_variant_access.h +0 -82
- data/third_party/abseil-cpp/absl/types/internal/optional.h +0 -352
- data/third_party/abseil-cpp/absl/types/internal/variant.h +0 -1622
@@ -18,14 +18,9 @@
|
|
18
18
|
|
19
19
|
#include "src/core/client_channel/retry_throttle.h"
|
20
20
|
|
21
|
-
#include <grpc/support/port_platform.h>
|
22
|
-
|
23
21
|
#include <atomic>
|
24
22
|
#include <cstdint>
|
25
23
|
#include <limits>
|
26
|
-
#include <map>
|
27
|
-
#include <string>
|
28
|
-
#include <utility>
|
29
24
|
|
30
25
|
#include "src/core/util/useful.h"
|
31
26
|
|
@@ -33,6 +28,7 @@ namespace grpc_core {
|
|
33
28
|
namespace internal {
|
34
29
|
|
35
30
|
namespace {
|
31
|
+
|
36
32
|
template <typename T>
|
37
33
|
T ClampedAdd(std::atomic<T>& value, T delta, T min, T max) {
|
38
34
|
T prev_value = value.load(std::memory_order_relaxed);
|
@@ -43,45 +39,74 @@ T ClampedAdd(std::atomic<T>& value, T delta, T min, T max) {
|
|
43
39
|
std::memory_order_relaxed));
|
44
40
|
return new_value;
|
45
41
|
}
|
42
|
+
|
46
43
|
} // namespace
|
47
44
|
|
48
45
|
//
|
49
|
-
//
|
46
|
+
// RetryThrottler
|
50
47
|
//
|
51
48
|
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
RefCountedPtr<RetryThrottler> RetryThrottler::Create(
|
50
|
+
uintptr_t max_milli_tokens, uintptr_t milli_token_ratio,
|
51
|
+
RefCountedPtr<RetryThrottler> previous) {
|
52
|
+
if (previous != nullptr && previous->max_milli_tokens_ == max_milli_tokens &&
|
53
|
+
previous->milli_token_ratio_ == milli_token_ratio) {
|
54
|
+
return previous;
|
55
|
+
}
|
56
|
+
// previous is null or has different parameters. Create a new one.
|
57
|
+
uintptr_t initial_milli_tokens = max_milli_tokens;
|
58
|
+
// If there was a pre-existing entry for this server name, initialize
|
59
|
+
// the token count by scaling proportionately to the old data. This
|
60
|
+
// ensures that if we're already throttling retries on the old scale,
|
61
|
+
// we will start out doing the same thing on the new one.
|
62
|
+
if (previous != nullptr) {
|
63
|
+
double token_fraction = static_cast<double>(previous->milli_tokens_) /
|
64
|
+
static_cast<double>(previous->max_milli_tokens_);
|
65
|
+
initial_milli_tokens =
|
66
|
+
static_cast<uintptr_t>(token_fraction * max_milli_tokens);
|
67
|
+
}
|
68
|
+
auto throttle_data = MakeRefCounted<RetryThrottler>(
|
69
|
+
max_milli_tokens, milli_token_ratio, initial_milli_tokens);
|
70
|
+
if (previous != nullptr) previous->SetReplacement(throttle_data);
|
71
|
+
return throttle_data;
|
72
|
+
}
|
73
|
+
|
74
|
+
UniqueTypeName RetryThrottler::Type() {
|
75
|
+
static UniqueTypeName::Factory factory("retry_throttle");
|
76
|
+
return factory.Create();
|
77
|
+
}
|
78
|
+
|
79
|
+
RetryThrottler::RetryThrottler(uintptr_t max_milli_tokens,
|
80
|
+
uintptr_t milli_token_ratio,
|
81
|
+
uintptr_t milli_tokens)
|
55
82
|
: max_milli_tokens_(max_milli_tokens),
|
56
83
|
milli_token_ratio_(milli_token_ratio),
|
57
84
|
milli_tokens_(milli_tokens) {}
|
58
85
|
|
59
|
-
|
60
|
-
|
61
|
-
replacement_.load(std::memory_order_acquire);
|
86
|
+
RetryThrottler::~RetryThrottler() {
|
87
|
+
RetryThrottler* replacement = replacement_.load(std::memory_order_acquire);
|
62
88
|
if (replacement != nullptr) {
|
63
89
|
replacement->Unref();
|
64
90
|
}
|
65
91
|
}
|
66
92
|
|
67
|
-
void
|
68
|
-
RefCountedPtr<ServerRetryThrottleData> replacement) {
|
93
|
+
void RetryThrottler::SetReplacement(RefCountedPtr<RetryThrottler> replacement) {
|
69
94
|
replacement_.store(replacement.release(), std::memory_order_release);
|
70
95
|
}
|
71
96
|
|
72
|
-
void
|
73
|
-
|
97
|
+
void RetryThrottler::GetReplacementThrottleDataIfNeeded(
|
98
|
+
RetryThrottler** throttle_data) {
|
74
99
|
while (true) {
|
75
|
-
|
100
|
+
RetryThrottler* new_throttle_data =
|
76
101
|
(*throttle_data)->replacement_.load(std::memory_order_acquire);
|
77
102
|
if (new_throttle_data == nullptr) return;
|
78
103
|
*throttle_data = new_throttle_data;
|
79
104
|
}
|
80
105
|
}
|
81
106
|
|
82
|
-
bool
|
107
|
+
bool RetryThrottler::RecordFailure() {
|
83
108
|
// First, check if we are stale and need to be replaced.
|
84
|
-
|
109
|
+
RetryThrottler* throttle_data = this;
|
85
110
|
GetReplacementThrottleDataIfNeeded(&throttle_data);
|
86
111
|
// We decrement milli_tokens by 1000 (1 token) for each failure.
|
87
112
|
const uintptr_t new_value = ClampedAdd<intptr_t>(
|
@@ -93,9 +118,9 @@ bool ServerRetryThrottleData::RecordFailure() {
|
|
93
118
|
return new_value > throttle_data->max_milli_tokens_ / 2;
|
94
119
|
}
|
95
120
|
|
96
|
-
void
|
121
|
+
void RetryThrottler::RecordSuccess() {
|
97
122
|
// First, check if we are stale and need to be replaced.
|
98
|
-
|
123
|
+
RetryThrottler* throttle_data = this;
|
99
124
|
GetReplacementThrottleDataIfNeeded(&throttle_data);
|
100
125
|
// We increment milli_tokens by milli_token_ratio for each success.
|
101
126
|
ClampedAdd<intptr_t>(
|
@@ -105,45 +130,5 @@ void ServerRetryThrottleData::RecordSuccess() {
|
|
105
130
|
std::numeric_limits<intptr_t>::max())));
|
106
131
|
}
|
107
132
|
|
108
|
-
//
|
109
|
-
// ServerRetryThrottleMap
|
110
|
-
//
|
111
|
-
|
112
|
-
ServerRetryThrottleMap* ServerRetryThrottleMap::Get() {
|
113
|
-
static ServerRetryThrottleMap* m = new ServerRetryThrottleMap();
|
114
|
-
return m;
|
115
|
-
}
|
116
|
-
|
117
|
-
RefCountedPtr<ServerRetryThrottleData> ServerRetryThrottleMap::GetDataForServer(
|
118
|
-
const std::string& server_name, uintptr_t max_milli_tokens,
|
119
|
-
uintptr_t milli_token_ratio) {
|
120
|
-
MutexLock lock(&mu_);
|
121
|
-
auto& throttle_data = map_[server_name];
|
122
|
-
if (throttle_data == nullptr ||
|
123
|
-
throttle_data->max_milli_tokens() != max_milli_tokens ||
|
124
|
-
throttle_data->milli_token_ratio() != milli_token_ratio) {
|
125
|
-
// Entry not found, or found with old parameters. Create a new one.
|
126
|
-
auto old_throttle_data = std::move(throttle_data);
|
127
|
-
uintptr_t initial_milli_tokens = max_milli_tokens;
|
128
|
-
// If there was a pre-existing entry for this server name, initialize
|
129
|
-
// the token count by scaling proportionately to the old data. This
|
130
|
-
// ensures that if we're already throttling retries on the old scale,
|
131
|
-
// we will start out doing the same thing on the new one.
|
132
|
-
if (old_throttle_data != nullptr) {
|
133
|
-
double token_fraction =
|
134
|
-
static_cast<double>(old_throttle_data->milli_tokens()) /
|
135
|
-
static_cast<double>(old_throttle_data->max_milli_tokens());
|
136
|
-
initial_milli_tokens =
|
137
|
-
static_cast<uintptr_t>(token_fraction * max_milli_tokens);
|
138
|
-
}
|
139
|
-
throttle_data = MakeRefCounted<ServerRetryThrottleData>(
|
140
|
-
max_milli_tokens, milli_token_ratio, initial_milli_tokens);
|
141
|
-
if (old_throttle_data != nullptr) {
|
142
|
-
old_throttle_data->SetReplacement(throttle_data);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
return throttle_data;
|
146
|
-
}
|
147
|
-
|
148
133
|
} // namespace internal
|
149
134
|
} // namespace grpc_core
|
@@ -19,30 +19,29 @@
|
|
19
19
|
#ifndef GRPC_SRC_CORE_CLIENT_CHANNEL_RETRY_THROTTLE_H
|
20
20
|
#define GRPC_SRC_CORE_CLIENT_CHANNEL_RETRY_THROTTLE_H
|
21
21
|
|
22
|
-
#include <grpc/support/port_platform.h>
|
23
22
|
#include <stdint.h>
|
24
23
|
|
25
24
|
#include <atomic>
|
26
|
-
#include <map>
|
27
|
-
#include <string>
|
28
25
|
|
29
|
-
#include "
|
30
|
-
#include "src/core/util/ref_counted.h"
|
26
|
+
#include "src/core/filter/blackboard.h"
|
31
27
|
#include "src/core/util/ref_counted_ptr.h"
|
32
|
-
#include "src/core/util/sync.h"
|
33
28
|
|
34
29
|
namespace grpc_core {
|
35
30
|
namespace internal {
|
36
31
|
|
37
|
-
class ServerRetryThrottleMap;
|
38
|
-
|
39
32
|
/// Tracks retry throttling data for an individual server name.
|
40
|
-
class
|
41
|
-
: public RefCounted<ServerRetryThrottleData> {
|
33
|
+
class RetryThrottler final : public Blackboard::Entry {
|
42
34
|
public:
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
static RefCountedPtr<RetryThrottler> Create(
|
36
|
+
uintptr_t max_milli_tokens, uintptr_t milli_token_ratio,
|
37
|
+
RefCountedPtr<RetryThrottler> previous);
|
38
|
+
|
39
|
+
static UniqueTypeName Type();
|
40
|
+
|
41
|
+
// Do not instantiate directly -- use Create() instead.
|
42
|
+
RetryThrottler(uintptr_t max_milli_tokens, uintptr_t milli_token_ratio,
|
43
|
+
uintptr_t milli_tokens);
|
44
|
+
~RetryThrottler() override;
|
46
45
|
|
47
46
|
/// Records a failure. Returns true if it's okay to send a retry.
|
48
47
|
bool RecordFailure();
|
@@ -50,6 +49,7 @@ class ServerRetryThrottleData final
|
|
50
49
|
/// Records a success.
|
51
50
|
void RecordSuccess();
|
52
51
|
|
52
|
+
// Exposed for testing purposes only.
|
53
53
|
uintptr_t max_milli_tokens() const { return max_milli_tokens_; }
|
54
54
|
uintptr_t milli_token_ratio() const { return milli_token_ratio_; }
|
55
55
|
intptr_t milli_tokens() const {
|
@@ -57,39 +57,17 @@ class ServerRetryThrottleData final
|
|
57
57
|
}
|
58
58
|
|
59
59
|
private:
|
60
|
-
|
60
|
+
void SetReplacement(RefCountedPtr<RetryThrottler> replacement);
|
61
61
|
|
62
|
-
void
|
63
|
-
|
64
|
-
void GetReplacementThrottleDataIfNeeded(
|
65
|
-
ServerRetryThrottleData** throttle_data);
|
62
|
+
void GetReplacementThrottleDataIfNeeded(RetryThrottler** throttle_data);
|
66
63
|
|
67
64
|
const uintptr_t max_milli_tokens_;
|
68
65
|
const uintptr_t milli_token_ratio_;
|
69
66
|
std::atomic<intptr_t> milli_tokens_;
|
70
|
-
// A pointer to the replacement for this
|
67
|
+
// A pointer to the replacement for this RetryThrottler entry.
|
71
68
|
// If non-nullptr, then this entry is stale and must not be used.
|
72
69
|
// We hold a reference to the replacement.
|
73
|
-
std::atomic<
|
74
|
-
};
|
75
|
-
|
76
|
-
/// Global map of server name to retry throttle data.
|
77
|
-
class ServerRetryThrottleMap final {
|
78
|
-
public:
|
79
|
-
static ServerRetryThrottleMap* Get();
|
80
|
-
|
81
|
-
/// Returns the failure data for \a server_name, creating a new entry if
|
82
|
-
/// needed.
|
83
|
-
RefCountedPtr<ServerRetryThrottleData> GetDataForServer(
|
84
|
-
const std::string& server_name, uintptr_t max_milli_tokens,
|
85
|
-
uintptr_t milli_token_ratio);
|
86
|
-
|
87
|
-
private:
|
88
|
-
using StringToDataMap =
|
89
|
-
std::map<std::string, RefCountedPtr<ServerRetryThrottleData>>;
|
90
|
-
|
91
|
-
Mutex mu_;
|
92
|
-
StringToDataMap map_ ABSL_GUARDED_BY(mu_);
|
70
|
+
std::atomic<RetryThrottler*> replacement_{nullptr};
|
93
71
|
};
|
94
72
|
|
95
73
|
} // namespace internal
|
@@ -422,11 +422,21 @@ class Subchannel::ConnectedSubchannelStateWatcher final
|
|
422
422
|
if (c->channelz_node() != nullptr) {
|
423
423
|
c->channelz_node()->SetChildSocket(nullptr);
|
424
424
|
}
|
425
|
-
//
|
426
|
-
//
|
427
|
-
//
|
428
|
-
//
|
429
|
-
|
425
|
+
// If the subchannel was created from an endpoint, then we report
|
426
|
+
// TRANSIENT_FAILURE here instead of IDLE. The subchannel will never
|
427
|
+
// leave TRANSIENT_FAILURE state, because there is no way for us to
|
428
|
+
// establish a new connection.
|
429
|
+
//
|
430
|
+
// Otherwise, we report IDLE here. Note that even though we're not
|
431
|
+
// reporting TRANSIENT_FAILURE, we pass along the status from the
|
432
|
+
// transport, since it may have keepalive info attached to it that the
|
433
|
+
// channel needs.
|
434
|
+
// TODO(roth): Consider whether there's a cleaner way to propagate the
|
435
|
+
// keepalive info.
|
436
|
+
c->SetConnectivityStateLocked(c->created_from_endpoint_
|
437
|
+
? GRPC_CHANNEL_TRANSIENT_FAILURE
|
438
|
+
: GRPC_CHANNEL_IDLE,
|
439
|
+
status);
|
430
440
|
c->backoff_.Reset();
|
431
441
|
}
|
432
442
|
}
|
@@ -509,6 +519,7 @@ Subchannel::Subchannel(SubchannelKey key,
|
|
509
519
|
? "Subchannel"
|
510
520
|
: nullptr),
|
511
521
|
key_(std::move(key)),
|
522
|
+
created_from_endpoint_(args.Contains(GRPC_ARG_SUBCHANNEL_ENDPOINT)),
|
512
523
|
args_(args),
|
513
524
|
pollset_set_(grpc_pollset_set_create()),
|
514
525
|
connector_(std::move(connector)),
|
@@ -546,9 +557,7 @@ Subchannel::Subchannel(SubchannelKey key,
|
|
546
557
|
grpc_sockaddr_to_uri(&key_.address())
|
547
558
|
.value_or("<unknown address type>"),
|
548
559
|
channel_tracer_max_memory);
|
549
|
-
channelz_node_
|
550
|
-
channelz::ChannelTrace::Severity::Info,
|
551
|
-
grpc_slice_from_static_string("subchannel created"));
|
560
|
+
GRPC_CHANNELZ_LOG(channelz_node_) << "subchannel created";
|
552
561
|
channelz_node_->SetChannelArgs(args_);
|
553
562
|
args_ = args_.SetObject<channelz::BaseNode>(channelz_node_);
|
554
563
|
}
|
@@ -556,9 +565,7 @@ Subchannel::Subchannel(SubchannelKey key,
|
|
556
565
|
|
557
566
|
Subchannel::~Subchannel() {
|
558
567
|
if (channelz_node_ != nullptr) {
|
559
|
-
channelz_node_
|
560
|
-
channelz::ChannelTrace::Severity::Info,
|
561
|
-
grpc_slice_from_static_string("Subchannel destroyed"));
|
568
|
+
GRPC_CHANNELZ_LOG(channelz_node_) << "Subchannel destroyed";
|
562
569
|
channelz_node_->UpdateConnectivityState(GRPC_CHANNEL_SHUTDOWN);
|
563
570
|
}
|
564
571
|
connector_.reset();
|
@@ -578,6 +585,15 @@ RefCountedPtr<Subchannel> Subchannel::Create(
|
|
578
585
|
return c;
|
579
586
|
}
|
580
587
|
c = MakeRefCounted<Subchannel>(std::move(key), std::move(connector), args);
|
588
|
+
if (c->created_from_endpoint_) {
|
589
|
+
// We don't interact with the subchannel pool in this case.
|
590
|
+
// Instead, we unconditionally return the newly created subchannel.
|
591
|
+
// Before returning, we explicitly trigger a connection attempt
|
592
|
+
// by calling RequestConnection(), which sets the subchannel’s
|
593
|
+
// connectivity state to CONNECTING.
|
594
|
+
c->RequestConnection();
|
595
|
+
return c;
|
596
|
+
}
|
581
597
|
// Try to register the subchannel before setting the subchannel pool.
|
582
598
|
// Otherwise, in case of a registration race, unreffing c in
|
583
599
|
// RegisterSubchannel() will cause c to be tried to be unregistered, while
|
@@ -702,12 +718,15 @@ void Subchannel::SetConnectivityStateLocked(grpc_connectivity_state state,
|
|
702
718
|
}
|
703
719
|
if (channelz_node_ != nullptr) {
|
704
720
|
channelz_node_->UpdateConnectivityState(state);
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
721
|
+
if (status.ok()) {
|
722
|
+
GRPC_CHANNELZ_LOG(channelz_node_)
|
723
|
+
<< "Subchannel connectivity state changed to "
|
724
|
+
<< ConnectivityStateName(state);
|
725
|
+
} else {
|
726
|
+
GRPC_CHANNELZ_LOG(channelz_node_)
|
727
|
+
<< "Subchannel connectivity state changed to "
|
728
|
+
<< ConnectivityStateName(state) << ": " << status;
|
729
|
+
}
|
711
730
|
}
|
712
731
|
// Notify watchers.
|
713
732
|
watcher_list_.NotifyLocked(state, status_);
|
@@ -767,10 +786,15 @@ void Subchannel::OnConnectingFinishedLocked(grpc_error_handle error) {
|
|
767
786
|
next_attempt_time_ - Timestamp::Now();
|
768
787
|
GRPC_TRACE_LOG(subchannel, INFO)
|
769
788
|
<< "subchannel " << this << " " << key_.ToString()
|
770
|
-
<< ": connect failed (" << StatusToString(error)
|
771
|
-
<<
|
789
|
+
<< ": connect failed (" << StatusToString(error) << ")"
|
790
|
+
<< (created_from_endpoint_
|
791
|
+
? ", no retry will be attempted (created from endpoint); "
|
792
|
+
"remaining in TRANSIENT_FAILURE"
|
793
|
+
: ", backing off for " +
|
794
|
+
std::to_string(time_until_next_attempt.millis()) + " ms");
|
772
795
|
SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE,
|
773
796
|
grpc_error_to_absl_status(error));
|
797
|
+
if (created_from_endpoint_) return;
|
774
798
|
retry_timer_handle_ = event_engine_->RunAfter(
|
775
799
|
time_until_next_attempt,
|
776
800
|
[self = WeakRef(DEBUG_LOCATION, "RetryTimer")]() mutable {
|
@@ -58,6 +58,11 @@
|
|
58
58
|
#include "src/core/util/unique_type_name.h"
|
59
59
|
#include "src/core/util/work_serializer.h"
|
60
60
|
|
61
|
+
/** This arg is intended for internal use only, primarily
|
62
|
+
* for passing endpoint information during subchannel creation or connection.
|
63
|
+
*/
|
64
|
+
#define GRPC_ARG_SUBCHANNEL_ENDPOINT "grpc.internal.subchannel_endpoint"
|
65
|
+
|
61
66
|
namespace grpc_core {
|
62
67
|
|
63
68
|
class SubchannelCall;
|
@@ -328,6 +333,9 @@ class Subchannel final : public DualRefCounted<Subchannel> {
|
|
328
333
|
RefCountedPtr<SubchannelPoolInterface> subchannel_pool_;
|
329
334
|
// Subchannel key that identifies this subchannel in the subchannel pool.
|
330
335
|
const SubchannelKey key_;
|
336
|
+
// boolean value that identifies this subchannel is created from event engine
|
337
|
+
// endpoint.
|
338
|
+
const bool created_from_endpoint_;
|
331
339
|
// Actual address to connect to. May be different than the address in
|
332
340
|
// key_ if overridden by proxy mapper.
|
333
341
|
grpc_resolved_address address_for_connect_;
|
@@ -30,7 +30,9 @@
|
|
30
30
|
#endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING
|
31
31
|
|
32
32
|
#ifdef GRPC_ENABLE_FORK_SUPPORT
|
33
|
+
#ifndef GRPC_ENABLE_FORK_SUPPORT_DEFAULT
|
33
34
|
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true
|
35
|
+
#endif // !defined(GRPC_ENABLE_FORK_SUPPORT_DEFAULT)
|
34
36
|
#else
|
35
37
|
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false
|
36
38
|
#endif // GRPC_ENABLE_FORK_SUPPORT
|
@@ -43,6 +43,7 @@ CoreConfiguration::CoreConfiguration(Builder* builder)
|
|
43
43
|
channel_init_(builder->channel_init_.Build()),
|
44
44
|
handshaker_registry_(builder->handshaker_registry_.Build()),
|
45
45
|
channel_creds_registry_(builder->channel_creds_registry_.Build()),
|
46
|
+
call_creds_registry_(builder->call_creds_registry_.Build()),
|
46
47
|
service_config_parser_(builder->service_config_parser_.Build()),
|
47
48
|
resolver_registry_(builder->resolver_registry_.Build()),
|
48
49
|
lb_policy_registry_(builder->lb_policy_registry_.Build()),
|
@@ -22,6 +22,7 @@
|
|
22
22
|
|
23
23
|
#include "absl/functional/any_invocable.h"
|
24
24
|
#include "absl/log/check.h"
|
25
|
+
#include "src/core/credentials/call/call_creds_registry.h"
|
25
26
|
#include "src/core/credentials/transport/channel_creds_registry.h"
|
26
27
|
#include "src/core/credentials/transport/tls/certificate_provider_registry.h"
|
27
28
|
#include "src/core/handshaker/handshaker_registry.h"
|
@@ -82,6 +83,10 @@ class GRPC_DLL CoreConfiguration {
|
|
82
83
|
return &channel_creds_registry_;
|
83
84
|
}
|
84
85
|
|
86
|
+
CallCredsRegistry<>::Builder* call_creds_registry() {
|
87
|
+
return &call_creds_registry_;
|
88
|
+
}
|
89
|
+
|
85
90
|
ServiceConfigParser::Builder* service_config_parser() {
|
86
91
|
return &service_config_parser_;
|
87
92
|
}
|
@@ -113,6 +118,7 @@ class GRPC_DLL CoreConfiguration {
|
|
113
118
|
ChannelInit::Builder channel_init_;
|
114
119
|
HandshakerRegistry::Builder handshaker_registry_;
|
115
120
|
ChannelCredsRegistry<>::Builder channel_creds_registry_;
|
121
|
+
CallCredsRegistry<>::Builder call_creds_registry_;
|
116
122
|
ServiceConfigParser::Builder service_config_parser_;
|
117
123
|
ResolverRegistry::Builder resolver_registry_;
|
118
124
|
LoadBalancingPolicyRegistry::Builder lb_policy_registry_;
|
@@ -241,6 +247,10 @@ class GRPC_DLL CoreConfiguration {
|
|
241
247
|
return channel_creds_registry_;
|
242
248
|
}
|
243
249
|
|
250
|
+
const CallCredsRegistry<>& call_creds_registry() const {
|
251
|
+
return call_creds_registry_;
|
252
|
+
}
|
253
|
+
|
244
254
|
const ServiceConfigParser& service_config_parser() const {
|
245
255
|
return service_config_parser_;
|
246
256
|
}
|
@@ -292,6 +302,7 @@ class GRPC_DLL CoreConfiguration {
|
|
292
302
|
ChannelInit channel_init_;
|
293
303
|
HandshakerRegistry handshaker_registry_;
|
294
304
|
ChannelCredsRegistry<> channel_creds_registry_;
|
305
|
+
CallCredsRegistry<> call_creds_registry_;
|
295
306
|
ServiceConfigParser service_config_parser_;
|
296
307
|
ResolverRegistry resolver_registry_;
|
297
308
|
LoadBalancingPolicyRegistry lb_policy_registry_;
|
@@ -0,0 +1,125 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2025 gRPC authors.
|
3
|
+
//
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
// you may not use this file except in compliance with the License.
|
6
|
+
// You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
// See the License for the specific language governing permissions and
|
14
|
+
// limitations under the License.
|
15
|
+
//
|
16
|
+
|
17
|
+
#ifndef GRPC_SRC_CORE_CREDENTIALS_CALL_CALL_CREDS_REGISTRY_H
|
18
|
+
#define GRPC_SRC_CORE_CREDENTIALS_CALL_CALL_CREDS_REGISTRY_H
|
19
|
+
|
20
|
+
#include <map>
|
21
|
+
#include <memory>
|
22
|
+
#include <type_traits>
|
23
|
+
#include <utility>
|
24
|
+
|
25
|
+
#include "absl/strings/string_view.h"
|
26
|
+
#include "src/core/util/json/json.h"
|
27
|
+
#include "src/core/util/json/json_args.h"
|
28
|
+
#include "src/core/util/ref_counted.h"
|
29
|
+
#include "src/core/util/ref_counted_ptr.h"
|
30
|
+
#include "src/core/util/validation_errors.h"
|
31
|
+
|
32
|
+
struct grpc_call_credentials;
|
33
|
+
|
34
|
+
namespace grpc_core {
|
35
|
+
|
36
|
+
class CallCredsConfig : public RefCounted<CallCredsConfig> {
|
37
|
+
public:
|
38
|
+
virtual absl::string_view type() const = 0;
|
39
|
+
|
40
|
+
virtual bool Equals(const CallCredsConfig& other) const = 0;
|
41
|
+
|
42
|
+
virtual std::string ToString() const = 0;
|
43
|
+
};
|
44
|
+
|
45
|
+
template <typename T = grpc_call_credentials>
|
46
|
+
class CallCredsFactory final {
|
47
|
+
public:
|
48
|
+
virtual ~CallCredsFactory() {}
|
49
|
+
virtual absl::string_view type() const = delete;
|
50
|
+
virtual RefCountedPtr<CallCredsConfig> ParseConfig(
|
51
|
+
const Json& config, const JsonArgs& args,
|
52
|
+
ValidationErrors* errors) const = delete;
|
53
|
+
virtual RefCountedPtr<T> CreateCallCreds(
|
54
|
+
RefCountedPtr<CallCredsConfig> config) const = delete;
|
55
|
+
};
|
56
|
+
|
57
|
+
template <>
|
58
|
+
class CallCredsFactory<grpc_call_credentials> {
|
59
|
+
public:
|
60
|
+
virtual ~CallCredsFactory() {}
|
61
|
+
virtual absl::string_view type() const = 0;
|
62
|
+
virtual RefCountedPtr<CallCredsConfig> ParseConfig(
|
63
|
+
const Json& config, const JsonArgs& args,
|
64
|
+
ValidationErrors* errors) const = 0;
|
65
|
+
virtual RefCountedPtr<grpc_call_credentials> CreateCallCreds(
|
66
|
+
RefCountedPtr<CallCredsConfig> config) const = 0;
|
67
|
+
};
|
68
|
+
|
69
|
+
template <typename T = grpc_call_credentials>
|
70
|
+
class CallCredsRegistry {
|
71
|
+
private:
|
72
|
+
using FactoryMap =
|
73
|
+
std::map<absl::string_view, std::unique_ptr<CallCredsFactory<T>>>;
|
74
|
+
|
75
|
+
public:
|
76
|
+
static_assert(std::is_base_of<grpc_call_credentials, T>::value,
|
77
|
+
"CallCredsRegistry must be instantiated with "
|
78
|
+
"grpc_call_credentials.");
|
79
|
+
|
80
|
+
class Builder {
|
81
|
+
public:
|
82
|
+
void RegisterCallCredsFactory(
|
83
|
+
std::unique_ptr<CallCredsFactory<T>> factory) {
|
84
|
+
absl::string_view type = factory->type();
|
85
|
+
factories_[type] = std::move(factory);
|
86
|
+
}
|
87
|
+
CallCredsRegistry Build() {
|
88
|
+
return CallCredsRegistry<T>(std::move(factories_));
|
89
|
+
}
|
90
|
+
|
91
|
+
private:
|
92
|
+
FactoryMap factories_;
|
93
|
+
};
|
94
|
+
|
95
|
+
bool IsSupported(absl::string_view type) const {
|
96
|
+
return factories_.find(type) != factories_.end();
|
97
|
+
}
|
98
|
+
|
99
|
+
RefCountedPtr<CallCredsConfig> ParseConfig(absl::string_view type,
|
100
|
+
const Json& config,
|
101
|
+
const JsonArgs& args,
|
102
|
+
ValidationErrors* errors) const {
|
103
|
+
const auto it = factories_.find(type);
|
104
|
+
if (it == factories_.cend()) return nullptr;
|
105
|
+
return it->second->ParseConfig(config, args, errors);
|
106
|
+
}
|
107
|
+
|
108
|
+
RefCountedPtr<T> CreateCallCreds(
|
109
|
+
RefCountedPtr<CallCredsConfig> config) const {
|
110
|
+
if (config == nullptr) return nullptr;
|
111
|
+
const auto it = factories_.find(config->type());
|
112
|
+
if (it == factories_.cend()) return nullptr;
|
113
|
+
return it->second->CreateCallCreds(std::move(config));
|
114
|
+
}
|
115
|
+
|
116
|
+
private:
|
117
|
+
explicit CallCredsRegistry(FactoryMap factories)
|
118
|
+
: factories_(std::move(factories)) {}
|
119
|
+
|
120
|
+
FactoryMap factories_;
|
121
|
+
};
|
122
|
+
|
123
|
+
} // namespace grpc_core
|
124
|
+
|
125
|
+
#endif // GRPC_SRC_CORE_CREDENTIALS_CALL_CALL_CREDS_REGISTRY_H
|
@@ -0,0 +1,91 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2025 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/credentials.h>
|
18
|
+
#include <grpc/grpc.h>
|
19
|
+
#include <grpc/grpc_security.h>
|
20
|
+
#include <grpc/support/json.h>
|
21
|
+
|
22
|
+
#include <memory>
|
23
|
+
#include <string>
|
24
|
+
|
25
|
+
#include "absl/strings/str_cat.h"
|
26
|
+
#include "absl/strings/string_view.h"
|
27
|
+
#include "src/core/config/core_configuration.h"
|
28
|
+
#include "src/core/credentials/call/call_credentials.h"
|
29
|
+
#include "src/core/credentials/call/call_creds_registry.h"
|
30
|
+
#include "src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h"
|
31
|
+
#include "src/core/util/down_cast.h"
|
32
|
+
#include "src/core/util/json/json.h"
|
33
|
+
#include "src/core/util/json/json_args.h"
|
34
|
+
#include "src/core/util/json/json_object_loader.h"
|
35
|
+
#include "src/core/util/ref_counted_ptr.h"
|
36
|
+
#include "src/core/util/validation_errors.h"
|
37
|
+
|
38
|
+
namespace grpc_core {
|
39
|
+
|
40
|
+
class JwtTokenFileCallCredsFactory : public CallCredsFactory<> {
|
41
|
+
public:
|
42
|
+
absl::string_view type() const override { return Type(); }
|
43
|
+
|
44
|
+
RefCountedPtr<CallCredsConfig> ParseConfig(
|
45
|
+
const Json& config, const JsonArgs& args,
|
46
|
+
ValidationErrors* errors) const override {
|
47
|
+
return LoadFromJson<RefCountedPtr<Config>>(config, args, errors);
|
48
|
+
}
|
49
|
+
|
50
|
+
RefCountedPtr<grpc_call_credentials> CreateCallCreds(
|
51
|
+
RefCountedPtr<CallCredsConfig> base_config) const override {
|
52
|
+
auto* config = DownCast<const Config*>(base_config.get());
|
53
|
+
return MakeRefCounted<JwtTokenFileCallCredentials>(config->path());
|
54
|
+
}
|
55
|
+
|
56
|
+
private:
|
57
|
+
class Config : public CallCredsConfig {
|
58
|
+
public:
|
59
|
+
absl::string_view type() const override { return Type(); }
|
60
|
+
|
61
|
+
bool Equals(const CallCredsConfig& other) const override {
|
62
|
+
auto& o = DownCast<const Config&>(other);
|
63
|
+
return path_ == o.path_;
|
64
|
+
}
|
65
|
+
|
66
|
+
std::string ToString() const override {
|
67
|
+
return absl::StrCat("{path=\"", path_, "\"}");
|
68
|
+
}
|
69
|
+
|
70
|
+
const std::string& path() const { return path_; }
|
71
|
+
|
72
|
+
static const JsonLoaderInterface* JsonLoader(const JsonArgs&) {
|
73
|
+
static const auto* loader = JsonObjectLoader<Config>()
|
74
|
+
.Field("jwt_token_file", &Config::path_)
|
75
|
+
.Finish();
|
76
|
+
return loader;
|
77
|
+
}
|
78
|
+
|
79
|
+
private:
|
80
|
+
std::string path_;
|
81
|
+
};
|
82
|
+
|
83
|
+
static absl::string_view Type() { return "jwt_token_file"; }
|
84
|
+
};
|
85
|
+
|
86
|
+
void RegisterDefaultCallCreds(CoreConfiguration::Builder* builder) {
|
87
|
+
builder->call_creds_registry()->RegisterCallCredsFactory(
|
88
|
+
std::make_unique<JwtTokenFileCallCredsFactory>());
|
89
|
+
}
|
90
|
+
|
91
|
+
} // namespace grpc_core
|