grpc 1.74.1 → 1.75.0.pre1
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 +83 -41
- data/include/grpc/credentials.h +7 -1
- data/src/core/call/client_call.cc +4 -4
- data/src/core/call/filter_fusion.h +1230 -0
- data/src/core/call/metadata.cc +22 -0
- data/src/core/call/metadata.h +24 -2
- data/src/core/channelz/channelz.cc +10 -17
- data/src/core/channelz/channelz.h +58 -19
- data/src/core/channelz/channelz_registry.cc +0 -162
- data/src/core/channelz/channelz_registry.h +14 -7
- data/src/core/channelz/property_list.cc +19 -23
- data/src/core/channelz/property_list.h +3 -1
- data/src/core/channelz/v2tov1/convert.cc +683 -0
- data/src/core/channelz/v2tov1/convert.h +58 -0
- data/src/core/channelz/v2tov1/legacy_api.cc +425 -0
- data/src/core/channelz/v2tov1/legacy_api.h +32 -0
- data/src/core/channelz/v2tov1/property_list.cc +118 -0
- data/src/core/channelz/v2tov1/property_list.h +52 -0
- data/src/core/client_channel/client_channel_filter.cc +5 -4
- data/src/core/client_channel/client_channel_filter.h +2 -2
- data/src/core/client_channel/client_channel_internal.h +2 -1
- data/src/core/client_channel/load_balanced_call_destination.cc +6 -5
- data/src/core/client_channel/subchannel.cc +14 -6
- data/src/core/client_channel/subchannel.h +2 -0
- data/src/core/config/core_configuration.cc +3 -1
- data/src/core/config/core_configuration.h +12 -0
- data/src/core/credentials/transport/alts/alts_credentials.cc +5 -0
- data/src/core/credentials/transport/alts/check_gcp_environment_windows.cc +2 -0
- data/src/core/credentials/transport/channel_creds_registry_init.cc +3 -1
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +1 -1
- data/src/core/credentials/transport/ssl/ssl_security_connector.cc +8 -3
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -24
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +19 -8
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +96 -54
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +15 -2
- data/src/core/credentials/transport/tls/spiffe_utils.cc +371 -0
- data/src/core/credentials/transport/tls/spiffe_utils.h +171 -0
- data/src/core/credentials/transport/tls/ssl_utils.cc +11 -10
- data/src/core/credentials/transport/tls/ssl_utils.h +4 -2
- data/src/core/credentials/transport/tls/tls_credentials.cc +2 -0
- data/src/core/credentials/transport/tls/tls_security_connector.cc +11 -26
- data/src/core/credentials/transport/tls/tls_security_connector.h +12 -12
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +3 -6
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +8 -8
- data/src/core/ext/filters/http/server/http_server_filter.cc +3 -6
- data/src/core/ext/filters/message_size/message_size_filter.cc +4 -4
- data/src/core/ext/filters/rbac/rbac_filter.cc +1 -1
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame.cc +89 -6
- data/src/core/ext/transport/chttp2/transport/frame.h +38 -0
- data/src/core/ext/transport/chttp2/transport/header_assembler.h +5 -14
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +294 -78
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +128 -9
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +11 -38
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +52 -35
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc +61 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.h +142 -0
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +81 -3
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +12 -1
- data/src/core/ext/transport/chttp2/transport/message_assembler.h +2 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +22 -5
- data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +607 -0
- data/src/core/ext/transport/chttp2/transport/writable_streams.h +254 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +6 -4
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb.h +4959 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.c +1111 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.h +108 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +142 -54
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +18 -14
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +2 -2
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +716 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.h +227 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +86 -88
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +2 -2
- data/src/core/filter/auth/auth_filters.h +2 -2
- data/src/core/filter/fused_filters.cc +154 -0
- data/src/core/handshaker/security/legacy_secure_endpoint.cc +1 -1
- data/src/core/handshaker/security/pipelined_secure_endpoint.cc +965 -0
- data/src/core/handshaker/security/secure_endpoint.cc +28 -13
- data/src/core/handshaker/security/secure_endpoint.h +8 -0
- data/src/core/lib/channel/promise_based_filter.cc +15 -25
- data/src/core/lib/channel/promise_based_filter.h +6 -5
- data/src/core/lib/event_engine/ares_resolver.h +3 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -5
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +2 -1
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +263 -0
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.h +107 -0
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +31 -3
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +12 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +12 -10
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +6 -4
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +15 -14
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -5
- data/src/core/lib/event_engine/posix_engine/event_poller.h +0 -8
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +11 -5
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +3 -2
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +1 -0
- data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +4 -4
- data/src/core/lib/event_engine/posix_engine/lockfree_event.h +3 -4
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +2 -2
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +188 -199
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +30 -45
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +1 -1
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +1 -1
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +2 -1
- data/src/core/lib/experiments/experiments.cc +120 -6
- data/src/core/lib/experiments/experiments.h +46 -3
- data/src/core/lib/iomgr/combiner.cc +1 -1
- data/src/core/lib/iomgr/exec_ctx.h +3 -9
- data/src/core/lib/iomgr/socket_mutator.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +1 -1
- data/src/core/lib/iomgr/tcp_client_posix.cc +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +3 -3
- data/src/core/lib/promise/activity.h +2 -2
- data/src/core/lib/promise/mpsc.cc +8 -8
- data/src/core/lib/promise/party.cc +7 -7
- data/src/core/lib/promise/party.h +4 -4
- data/src/core/lib/promise/poll.h +10 -0
- data/src/core/lib/resource_quota/memory_quota.cc +90 -3
- data/src/core/lib/resource_quota/memory_quota.h +20 -9
- data/src/core/lib/resource_quota/periodic_update.cc +14 -0
- data/src/core/lib/resource_quota/periodic_update.h +8 -0
- data/src/core/lib/resource_quota/resource_quota.cc +15 -4
- data/src/core/lib/resource_quota/resource_quota.h +3 -0
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -2
- data/src/core/lib/surface/call.cc +5 -5
- data/src/core/lib/surface/call.h +6 -5
- data/src/core/lib/surface/completion_queue.cc +2 -4
- data/src/core/lib/surface/filter_stack_call.cc +1 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.h +3 -3
- data/src/core/load_balancing/endpoint_list.cc +29 -2
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +3 -3
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.h +1 -1
- data/src/core/load_balancing/pick_first/pick_first.cc +12 -5
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +5 -3
- data/src/core/net/socket_mutator.cc +19 -0
- data/src/core/net/socket_mutator.h +25 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +6 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +2 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +8 -5
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
- data/src/core/resolver/xds/xds_dependency_manager.cc +1 -1
- data/src/core/server/server.cc +1 -1
- data/src/core/server/server_call_tracer_filter.cc +0 -66
- data/src/core/server/server_call_tracer_filter.h +64 -0
- data/src/core/server/server_config_selector_filter.cc +1 -1
- data/src/core/service_config/service_config_channel_arg_filter.cc +3 -60
- data/src/core/service_config/service_config_channel_arg_filter.h +82 -0
- data/src/core/telemetry/call_tracer.cc +20 -14
- data/src/core/telemetry/call_tracer.h +22 -17
- data/src/core/telemetry/metrics.h +8 -8
- data/src/core/telemetry/stats_data.cc +151 -151
- data/src/core/telemetry/stats_data.h +87 -87
- data/src/core/transport/auth_context.cc +20 -0
- data/src/core/transport/auth_context.h +4 -0
- data/src/core/transport/auth_context_comparator_registry.h +69 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -3
- data/src/core/tsi/ssl_transport_security.cc +202 -32
- data/src/core/tsi/ssl_transport_security.h +19 -10
- data/src/core/tsi/ssl_transport_security_utils.cc +21 -0
- data/src/core/tsi/ssl_transport_security_utils.h +4 -0
- data/src/core/util/http_client/httpcli_security_connector.cc +3 -1
- data/src/core/util/latent_see.cc +178 -146
- data/src/core/util/latent_see.h +245 -188
- data/src/core/util/single_set_ptr.h +5 -2
- data/src/core/util/useful.h +91 -0
- data/src/core/util/windows/directory_reader.cc +1 -0
- data/src/core/util/windows/thd.cc +1 -3
- data/src/core/util/work_serializer.cc +1 -1
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +32 -5
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +5 -0
- data/src/core/xds/grpc/xds_certificate_provider.cc +5 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/cares/cares/include/ares.h +925 -460
- data/third_party/cares/cares/include/ares_dns.h +86 -71
- data/third_party/cares/cares/include/ares_dns_record.h +1118 -0
- data/third_party/cares/cares/include/ares_nameser.h +215 -189
- data/third_party/cares/cares/include/ares_version.h +37 -14
- data/third_party/cares/cares/src/lib/ares_addrinfo2hostent.c +305 -0
- data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +245 -0
- data/third_party/cares/cares/src/lib/ares_android.c +216 -164
- data/third_party/cares/cares/src/lib/ares_android.h +25 -14
- data/third_party/cares/cares/src/lib/ares_cancel.c +68 -44
- data/third_party/cares/cares/src/lib/ares_close_sockets.c +137 -0
- data/third_party/cares/cares/src/lib/ares_conn.c +511 -0
- data/third_party/cares/cares/src/lib/ares_conn.h +196 -0
- data/third_party/cares/cares/src/lib/ares_cookie.c +461 -0
- data/third_party/cares/cares/src/lib/ares_data.c +93 -181
- data/third_party/cares/cares/src/lib/ares_data.h +50 -39
- data/third_party/cares/cares/src/lib/ares_destroy.c +127 -89
- data/third_party/cares/cares/src/lib/ares_free_hostent.c +35 -24
- data/third_party/cares/cares/src/lib/ares_free_string.c +24 -16
- data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +45 -38
- data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +549 -663
- data/third_party/cares/cares/src/lib/ares_getenv.c +25 -15
- data/third_party/cares/cares/src/lib/ares_getenv.h +26 -18
- data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +163 -221
- data/third_party/cares/cares/src/lib/ares_gethostbyname.c +222 -223
- data/third_party/cares/cares/src/lib/ares_getnameinfo.c +328 -338
- data/third_party/cares/cares/src/lib/ares_hosts_file.c +952 -0
- data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +25 -19
- data/third_party/cares/cares/src/lib/ares_init.c +425 -2091
- data/third_party/cares/cares/src/lib/ares_ipv6.h +63 -33
- data/third_party/cares/cares/src/lib/ares_library_init.c +110 -54
- data/third_party/cares/cares/src/lib/ares_metrics.c +261 -0
- data/third_party/cares/cares/src/lib/ares_options.c +418 -332
- data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +179 -0
- data/third_party/cares/cares/src/lib/ares_private.h +558 -356
- data/third_party/cares/cares/src/lib/ares_process.c +1224 -1369
- data/third_party/cares/cares/src/lib/ares_qcache.c +430 -0
- data/third_party/cares/cares/src/lib/ares_query.c +126 -121
- data/third_party/cares/cares/src/lib/ares_search.c +564 -262
- data/third_party/cares/cares/src/lib/ares_send.c +264 -93
- data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +588 -0
- data/third_party/cares/cares/src/lib/ares_setup.h +115 -111
- data/third_party/cares/cares/src/lib/ares_socket.c +425 -0
- data/third_party/cares/cares/src/lib/ares_socket.h +163 -0
- data/third_party/cares/cares/src/lib/ares_sortaddrinfo.c +447 -0
- data/third_party/cares/cares/src/lib/ares_strerror.c +83 -48
- data/third_party/cares/cares/src/lib/ares_sysconfig.c +639 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +839 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_mac.c +373 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +621 -0
- data/third_party/cares/cares/src/lib/ares_timeout.c +136 -73
- data/third_party/cares/cares/src/lib/ares_update_servers.c +1362 -0
- data/third_party/cares/cares/src/lib/ares_version.c +29 -4
- data/third_party/cares/cares/src/lib/config-dos.h +88 -89
- data/third_party/cares/cares/src/lib/config-win32.h +122 -77
- data/third_party/cares/cares/src/lib/dsa/ares_array.c +394 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.c +447 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.h +174 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_asvp.c +224 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +228 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_strvp.c +210 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_szvp.c +188 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpstr.c +186 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpvp.c +194 -0
- data/third_party/cares/cares/src/lib/dsa/ares_llist.c +382 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.c +479 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.h +207 -0
- data/third_party/cares/cares/src/lib/event/ares_event.h +191 -0
- data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +743 -0
- data/third_party/cares/cares/src/lib/event/ares_event_epoll.c +192 -0
- data/third_party/cares/cares/src/lib/event/ares_event_kqueue.c +248 -0
- data/third_party/cares/cares/src/lib/event/ares_event_poll.c +140 -0
- data/third_party/cares/cares/src/lib/event/ares_event_select.c +159 -0
- data/third_party/cares/cares/src/lib/event/ares_event_thread.c +567 -0
- data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +166 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.c +978 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.h +161 -0
- data/third_party/cares/cares/src/lib/include/ares_array.h +276 -0
- data/third_party/cares/cares/src/lib/include/ares_buf.h +732 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_asvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_dict.h +123 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_strvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_szvp.h +118 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpstr.h +111 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpvp.h +128 -0
- data/third_party/cares/cares/src/lib/include/ares_llist.h +239 -0
- data/third_party/cares/cares/src/lib/include/ares_mem.h +38 -0
- data/third_party/cares/cares/src/lib/include/ares_str.h +244 -0
- data/third_party/cares/cares/src/lib/inet_net_pton.c +202 -157
- data/third_party/cares/cares/src/lib/inet_ntop.c +87 -69
- data/third_party/cares/cares/src/lib/legacy/ares_create_query.c +78 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +99 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_string.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_fds.c +80 -0
- data/third_party/cares/cares/src/lib/legacy/ares_getsock.c +85 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +982 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +307 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.h +72 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_name.c +673 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +1329 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_private.h +273 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_record.c +1661 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_write.c +1229 -0
- data/third_party/cares/cares/src/lib/str/ares_buf.c +1498 -0
- data/third_party/cares/cares/src/lib/str/ares_str.c +508 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.c +90 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.h +51 -0
- data/third_party/cares/cares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +628 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +139 -0
- data/third_party/cares/cares/src/lib/util/ares_math.c +158 -0
- data/third_party/cares/cares/src/lib/util/ares_math.h +45 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.c +389 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.h +36 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.c +614 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.h +60 -0
- data/third_party/cares/cares/src/lib/util/ares_time.h +48 -0
- data/third_party/cares/cares/src/lib/util/ares_timeval.c +95 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.c +1626 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.h +252 -0
- data/third_party/cares/cares/src/lib/windows_port.c +16 -9
- metadata +121 -49
- data/src/core/util/ring_buffer.h +0 -122
- data/third_party/cares/cares/include/ares_rules.h +0 -125
- data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +0 -266
- data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +0 -240
- data/third_party/cares/cares/src/lib/ares__close_sockets.c +0 -61
- data/third_party/cares/cares/src/lib/ares__get_hostent.c +0 -260
- data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +0 -229
- data/third_party/cares/cares/src/lib/ares__read_line.c +0 -73
- data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +0 -258
- data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +0 -507
- data/third_party/cares/cares/src/lib/ares__timeval.c +0 -111
- data/third_party/cares/cares/src/lib/ares_create_query.c +0 -197
- data/third_party/cares/cares/src/lib/ares_expand_name.c +0 -311
- data/third_party/cares/cares/src/lib/ares_expand_string.c +0 -67
- data/third_party/cares/cares/src/lib/ares_fds.c +0 -59
- data/third_party/cares/cares/src/lib/ares_getsock.c +0 -66
- data/third_party/cares/cares/src/lib/ares_iphlpapi.h +0 -221
- data/third_party/cares/cares/src/lib/ares_llist.c +0 -63
- data/third_party/cares/cares/src/lib/ares_llist.h +0 -39
- data/third_party/cares/cares/src/lib/ares_mkquery.c +0 -24
- data/third_party/cares/cares/src/lib/ares_nowarn.c +0 -260
- data/third_party/cares/cares/src/lib/ares_nowarn.h +0 -61
- data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +0 -90
- data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +0 -92
- data/third_party/cares/cares/src/lib/ares_parse_caa_reply.c +0 -199
- data/third_party/cares/cares/src/lib/ares_parse_mx_reply.c +0 -164
- data/third_party/cares/cares/src/lib/ares_parse_naptr_reply.c +0 -183
- data/third_party/cares/cares/src/lib/ares_parse_ns_reply.c +0 -177
- data/third_party/cares/cares/src/lib/ares_parse_ptr_reply.c +0 -228
- data/third_party/cares/cares/src/lib/ares_parse_soa_reply.c +0 -179
- data/third_party/cares/cares/src/lib/ares_parse_srv_reply.c +0 -168
- data/third_party/cares/cares/src/lib/ares_parse_txt_reply.c +0 -214
- data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +0 -184
- data/third_party/cares/cares/src/lib/ares_platform.c +0 -11042
- data/third_party/cares/cares/src/lib/ares_platform.h +0 -43
- data/third_party/cares/cares/src/lib/ares_rand.c +0 -279
- data/third_party/cares/cares/src/lib/ares_strcasecmp.c +0 -66
- data/third_party/cares/cares/src/lib/ares_strcasecmp.h +0 -30
- data/third_party/cares/cares/src/lib/ares_strdup.c +0 -42
- data/third_party/cares/cares/src/lib/ares_strdup.h +0 -24
- data/third_party/cares/cares/src/lib/ares_strsplit.c +0 -94
- data/third_party/cares/cares/src/lib/ares_strsplit.h +0 -42
- data/third_party/cares/cares/src/lib/ares_writev.c +0 -79
- data/third_party/cares/cares/src/lib/ares_writev.h +0 -36
- data/third_party/cares/cares/src/lib/bitncmp.c +0 -59
- data/third_party/cares/cares/src/lib/bitncmp.h +0 -26
- data/third_party/cares/cares/src/lib/setup_once.h +0 -554
- data/third_party/cares/cares/src/tools/ares_getopt.h +0 -53
@@ -0,0 +1,58 @@
|
|
1
|
+
// Copyright 2025 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#ifndef GRPC_SRC_CORE_CHANNELZ_V2TOV1_CONVERT_H
|
16
|
+
#define GRPC_SRC_CORE_CHANNELZ_V2TOV1_CONVERT_H
|
17
|
+
|
18
|
+
#include <string>
|
19
|
+
#include <vector>
|
20
|
+
|
21
|
+
#include "absl/status/statusor.h"
|
22
|
+
|
23
|
+
namespace grpc_core {
|
24
|
+
namespace channelz {
|
25
|
+
namespace v2tov1 {
|
26
|
+
|
27
|
+
class EntityFetcher {
|
28
|
+
public:
|
29
|
+
virtual ~EntityFetcher() = default;
|
30
|
+
// returns serialized grpc::channelz::v2::Entity
|
31
|
+
virtual absl::StatusOr<std::string> GetEntity(int64_t id) = 0;
|
32
|
+
// returns list of serialized grpc::channelz::v2::Entity
|
33
|
+
virtual absl::StatusOr<std::vector<std::string>> GetEntitiesWithParent(
|
34
|
+
int64_t parent_id) = 0;
|
35
|
+
};
|
36
|
+
|
37
|
+
// Converts a v2 entity to a v1 entity.
|
38
|
+
// `serialized_entity` is the serialized v2 entity.
|
39
|
+
// `fetcher` is used to fetch child entities.
|
40
|
+
// `json` is true if the output should be a json string, false if it should be
|
41
|
+
// a serialized proto. The serialized proto will be of the appropriate channelz
|
42
|
+
// v1 proto type.
|
43
|
+
absl::StatusOr<std::string> ConvertServer(const std::string& serialized_entity,
|
44
|
+
EntityFetcher& fetcher, bool json);
|
45
|
+
absl::StatusOr<std::string> ConvertSocket(const std::string& serialized_entity,
|
46
|
+
EntityFetcher& fetcher, bool json);
|
47
|
+
absl::StatusOr<std::string> ConvertChannel(const std::string& serialized_entity,
|
48
|
+
EntityFetcher& fetcher, bool json);
|
49
|
+
absl::StatusOr<std::string> ConvertSubchannel(
|
50
|
+
const std::string& serialized_entity, EntityFetcher& fetcher, bool json);
|
51
|
+
absl::StatusOr<std::string> ConvertListenSocket(
|
52
|
+
const std::string& serialized_entity, EntityFetcher& fetcher, bool json);
|
53
|
+
|
54
|
+
} // namespace v2tov1
|
55
|
+
} // namespace channelz
|
56
|
+
} // namespace grpc_core
|
57
|
+
|
58
|
+
#endif // GRPC_SRC_CORE_CHANNELZ_V2TOV1_CONVERT_H
|
@@ -0,0 +1,425 @@
|
|
1
|
+
// Copyright 2025 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#include <grpc/grpc.h>
|
16
|
+
#include <grpc/support/alloc.h>
|
17
|
+
#include <grpc/support/log.h>
|
18
|
+
#include <grpc/support/string_util.h>
|
19
|
+
|
20
|
+
#include <string>
|
21
|
+
#include <vector>
|
22
|
+
|
23
|
+
#include "absl/log/log.h"
|
24
|
+
#include "absl/status/statusor.h"
|
25
|
+
#include "absl/strings/str_cat.h"
|
26
|
+
#include "src/core/channelz/channelz_registry.h"
|
27
|
+
#include "src/core/channelz/v2tov1/convert.h"
|
28
|
+
#include "src/core/lib/experiments/experiments.h"
|
29
|
+
#include "src/core/lib/iomgr/exec_ctx.h"
|
30
|
+
#include "src/core/util/json/json.h"
|
31
|
+
#include "src/core/util/json/json_reader.h"
|
32
|
+
#include "src/core/util/json/json_writer.h"
|
33
|
+
|
34
|
+
// This file is a temporary compatibility layer between the v2 channelz data
|
35
|
+
// model and the v1 C-API. It should be removed when the v1 C-API is removed.
|
36
|
+
|
37
|
+
namespace grpc_core {
|
38
|
+
namespace channelz {
|
39
|
+
namespace v2tov1 {
|
40
|
+
namespace {
|
41
|
+
|
42
|
+
class RegistryEntityFetcher : public EntityFetcher {
|
43
|
+
public:
|
44
|
+
absl::StatusOr<std::string> GetEntity(int64_t id) override {
|
45
|
+
auto node = ChannelzRegistry::GetNode(id);
|
46
|
+
if (node == nullptr) {
|
47
|
+
return absl::NotFoundError(absl::StrCat("Entity not found: ", id));
|
48
|
+
}
|
49
|
+
return node->SerializeEntityToString();
|
50
|
+
}
|
51
|
+
|
52
|
+
absl::StatusOr<std::vector<std::string>> GetEntitiesWithParent(
|
53
|
+
int64_t parent_id) override {
|
54
|
+
auto node = ChannelzRegistry::GetNode(parent_id);
|
55
|
+
if (node == nullptr) {
|
56
|
+
return absl::NotFoundError(
|
57
|
+
absl::StrCat("Parent entity not found: ", parent_id));
|
58
|
+
}
|
59
|
+
auto [nodes, end] = ChannelzRegistry::GetChildren(
|
60
|
+
node.get(), 0, std::numeric_limits<size_t>::max());
|
61
|
+
DCHECK(end);
|
62
|
+
std::vector<std::string> children_str;
|
63
|
+
for (const auto& child_node : nodes) {
|
64
|
+
if (child_node == nullptr) continue;
|
65
|
+
children_str.push_back(child_node->SerializeEntityToString());
|
66
|
+
}
|
67
|
+
return children_str;
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
template <typename T>
|
72
|
+
std::string RenderArray(std::tuple<T, bool> values_and_end,
|
73
|
+
const std::string& key) {
|
74
|
+
auto& [values, end] = values_and_end;
|
75
|
+
Json::Object object;
|
76
|
+
if (!values.empty()) {
|
77
|
+
// Create list of channels.
|
78
|
+
Json::Array array;
|
79
|
+
for (size_t i = 0; i < values.size(); ++i) {
|
80
|
+
array.emplace_back(values[i]->RenderJson());
|
81
|
+
}
|
82
|
+
object[key] = Json::FromArray(std::move(array));
|
83
|
+
}
|
84
|
+
if (end) {
|
85
|
+
object["end"] = Json::FromBool(true);
|
86
|
+
}
|
87
|
+
return JsonDump(Json::FromObject(std::move(object)));
|
88
|
+
}
|
89
|
+
|
90
|
+
Json RemoveAdditionalInfo(const Json& json) {
|
91
|
+
switch (json.type()) {
|
92
|
+
case Json::Type::kArray: {
|
93
|
+
Json::Array out;
|
94
|
+
for (const auto& node : json.array()) {
|
95
|
+
out.emplace_back(RemoveAdditionalInfo(node));
|
96
|
+
}
|
97
|
+
return Json::FromArray(std::move(out));
|
98
|
+
} break;
|
99
|
+
case Json::Type::kObject: {
|
100
|
+
Json::Object out;
|
101
|
+
for (const auto& [key, value] : json.object()) {
|
102
|
+
if (key == "additionalInfo") continue;
|
103
|
+
out[key] = RemoveAdditionalInfo(value);
|
104
|
+
}
|
105
|
+
return Json::FromObject(std::move(out));
|
106
|
+
} break;
|
107
|
+
default:
|
108
|
+
return json;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
} // namespace
|
113
|
+
|
114
|
+
std::string StripAdditionalInfoFromJson(absl::string_view json_str) {
|
115
|
+
auto json = JsonParse(json_str);
|
116
|
+
if (!json.ok()) return std::string(json_str);
|
117
|
+
return JsonDump(RemoveAdditionalInfo(*json));
|
118
|
+
}
|
119
|
+
|
120
|
+
// TODO(ctiller): Temporary hack to remove fields that are objectionable to the
|
121
|
+
// protobuf parser (because we've not published them in protobuf yet).
|
122
|
+
char* ApplyHacks(const std::string& json_str) {
|
123
|
+
return gpr_strdup(StripAdditionalInfoFromJson(json_str).c_str());
|
124
|
+
}
|
125
|
+
|
126
|
+
} // namespace v2tov1
|
127
|
+
} // namespace channelz
|
128
|
+
} // namespace grpc_core
|
129
|
+
|
130
|
+
using grpc_core::channelz::ChannelzRegistry;
|
131
|
+
using grpc_core::channelz::v2tov1::RegistryEntityFetcher;
|
132
|
+
|
133
|
+
char* grpc_channelz_get_top_channels(intptr_t start_channel_id) {
|
134
|
+
grpc_core::ExecCtx exec_ctx;
|
135
|
+
if (grpc_core::IsChannelzUseV2ForV1ApiEnabled()) {
|
136
|
+
RegistryEntityFetcher fetcher;
|
137
|
+
auto [channels, end] = ChannelzRegistry::GetTopChannels(start_channel_id);
|
138
|
+
grpc_core::Json::Array array;
|
139
|
+
for (const auto& channel_node : channels) {
|
140
|
+
if (channel_node == nullptr) continue;
|
141
|
+
auto serialized_v2 = channel_node->SerializeEntityToString();
|
142
|
+
auto serialized_v1 = grpc_core::channelz::v2tov1::ConvertChannel(
|
143
|
+
serialized_v2, fetcher, true);
|
144
|
+
if (!serialized_v1.ok()) {
|
145
|
+
LOG(ERROR) << "Failed to convert channel: " << serialized_v1.status();
|
146
|
+
continue;
|
147
|
+
}
|
148
|
+
auto json = grpc_core::JsonParse(*serialized_v1);
|
149
|
+
if (!json.ok()) {
|
150
|
+
LOG(ERROR) << "Failed to parse converted channel json: "
|
151
|
+
<< json.status();
|
152
|
+
continue;
|
153
|
+
}
|
154
|
+
array.emplace_back(std::move(*json));
|
155
|
+
}
|
156
|
+
grpc_core::Json json = grpc_core::Json::FromObject({
|
157
|
+
{"channel", grpc_core::Json::FromArray(std::move(array))},
|
158
|
+
{"end", grpc_core::Json::FromBool(end)},
|
159
|
+
});
|
160
|
+
std::string json_str = grpc_core::JsonDump(json);
|
161
|
+
return gpr_strdup(json_str.c_str());
|
162
|
+
} else {
|
163
|
+
return grpc_core::channelz::v2tov1::ApplyHacks(
|
164
|
+
grpc_core::channelz::v2tov1::RenderArray(
|
165
|
+
grpc_core::channelz::ChannelzRegistry::GetTopChannels(
|
166
|
+
start_channel_id),
|
167
|
+
"channel"));
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
char* grpc_channelz_get_servers(intptr_t start_server_id) {
|
172
|
+
grpc_core::ExecCtx exec_ctx;
|
173
|
+
if (grpc_core::IsChannelzUseV2ForV1ApiEnabled()) {
|
174
|
+
RegistryEntityFetcher fetcher;
|
175
|
+
auto [servers, end] = ChannelzRegistry::GetServers(start_server_id);
|
176
|
+
grpc_core::Json::Array array;
|
177
|
+
for (const auto& server_node : servers) {
|
178
|
+
if (server_node == nullptr) continue;
|
179
|
+
auto serialized_v2 = server_node->SerializeEntityToString();
|
180
|
+
auto serialized_v1 = grpc_core::channelz::v2tov1::ConvertServer(
|
181
|
+
serialized_v2, fetcher, true);
|
182
|
+
if (!serialized_v1.ok()) {
|
183
|
+
LOG(ERROR) << "Failed to convert server: " << serialized_v1.status();
|
184
|
+
continue;
|
185
|
+
}
|
186
|
+
auto json = grpc_core::JsonParse(*serialized_v1);
|
187
|
+
if (!json.ok()) {
|
188
|
+
LOG(ERROR) << "Failed to parse converted server json: "
|
189
|
+
<< json.status();
|
190
|
+
continue;
|
191
|
+
}
|
192
|
+
array.emplace_back(std::move(*json));
|
193
|
+
}
|
194
|
+
grpc_core::Json json = grpc_core::Json::FromObject({
|
195
|
+
{"server", grpc_core::Json::FromArray(std::move(array))},
|
196
|
+
{"end", grpc_core::Json::FromBool(end)},
|
197
|
+
});
|
198
|
+
std::string json_str = grpc_core::JsonDump(json);
|
199
|
+
return gpr_strdup(json_str.c_str());
|
200
|
+
} else {
|
201
|
+
return grpc_core::channelz::v2tov1::ApplyHacks(
|
202
|
+
grpc_core::channelz::v2tov1::RenderArray(
|
203
|
+
grpc_core::channelz::ChannelzRegistry::GetServers(start_server_id),
|
204
|
+
"server"));
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
char* grpc_channelz_get_server(intptr_t server_id) {
|
209
|
+
grpc_core::ExecCtx exec_ctx;
|
210
|
+
if (grpc_core::IsChannelzUseV2ForV1ApiEnabled()) {
|
211
|
+
auto server_node = ChannelzRegistry::GetServer(server_id);
|
212
|
+
if (server_node == nullptr) return nullptr;
|
213
|
+
RegistryEntityFetcher fetcher;
|
214
|
+
auto serialized_v2 = server_node->SerializeEntityToString();
|
215
|
+
auto serialized_v1 = grpc_core::channelz::v2tov1::ConvertServer(
|
216
|
+
serialized_v2, fetcher, true);
|
217
|
+
if (!serialized_v1.ok()) {
|
218
|
+
LOG(ERROR) << "Failed to convert server: " << serialized_v1.status();
|
219
|
+
return nullptr;
|
220
|
+
}
|
221
|
+
auto json = grpc_core::JsonParse(*serialized_v1);
|
222
|
+
if (!json.ok()) {
|
223
|
+
LOG(ERROR) << "Failed to parse converted server json: " << json.status();
|
224
|
+
return nullptr;
|
225
|
+
}
|
226
|
+
grpc_core::Json wrapped_json = grpc_core::Json::FromObject({
|
227
|
+
{"server", std::move(*json)},
|
228
|
+
});
|
229
|
+
std::string json_str = grpc_core::JsonDump(wrapped_json);
|
230
|
+
return gpr_strdup(json_str.c_str());
|
231
|
+
} else {
|
232
|
+
grpc_core::WeakRefCountedPtr<grpc_core::channelz::BaseNode> server_node =
|
233
|
+
grpc_core::channelz::ChannelzRegistry::Get(server_id);
|
234
|
+
if (server_node == nullptr ||
|
235
|
+
server_node->type() !=
|
236
|
+
grpc_core::channelz::BaseNode::EntityType::kServer) {
|
237
|
+
return nullptr;
|
238
|
+
}
|
239
|
+
grpc_core::Json json = grpc_core::Json::FromObject({
|
240
|
+
{"server", server_node->RenderJson()},
|
241
|
+
});
|
242
|
+
return grpc_core::channelz::v2tov1::ApplyHacks(
|
243
|
+
grpc_core::JsonDump(json).c_str());
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
char* grpc_channelz_get_server_sockets(intptr_t server_id,
|
248
|
+
intptr_t start_socket_id,
|
249
|
+
intptr_t max_results) {
|
250
|
+
grpc_core::ExecCtx exec_ctx;
|
251
|
+
if (grpc_core::IsChannelzUseV2ForV1ApiEnabled()) {
|
252
|
+
auto server_node = ChannelzRegistry::GetServer(server_id);
|
253
|
+
if (server_node == nullptr) return nullptr;
|
254
|
+
size_t max =
|
255
|
+
max_results == 0 ? std::numeric_limits<size_t>::max() : max_results;
|
256
|
+
auto [sockets, end] = ChannelzRegistry::GetChildrenOfType(
|
257
|
+
start_socket_id, server_node.get(),
|
258
|
+
grpc_core::channelz::BaseNode::EntityType::kSocket, max);
|
259
|
+
grpc_core::Json::Array array;
|
260
|
+
for (const auto& socket_node : sockets) {
|
261
|
+
if (socket_node == nullptr) continue;
|
262
|
+
array.emplace_back(grpc_core::Json::FromObject({
|
263
|
+
{"socketId",
|
264
|
+
grpc_core::Json::FromString(absl::StrCat(socket_node->uuid()))},
|
265
|
+
{"name", grpc_core::Json::FromString(socket_node->name())},
|
266
|
+
}));
|
267
|
+
}
|
268
|
+
grpc_core::Json json = grpc_core::Json::FromObject({
|
269
|
+
{"socketRef", grpc_core::Json::FromArray(std::move(array))},
|
270
|
+
{"end", grpc_core::Json::FromBool(end)},
|
271
|
+
});
|
272
|
+
std::string json_str = grpc_core::JsonDump(json);
|
273
|
+
return gpr_strdup(json_str.c_str());
|
274
|
+
} else {
|
275
|
+
// Validate inputs before handing them of to the renderer.
|
276
|
+
grpc_core::WeakRefCountedPtr<grpc_core::channelz::BaseNode> base_node =
|
277
|
+
grpc_core::channelz::ChannelzRegistry::Get(server_id);
|
278
|
+
if (base_node == nullptr ||
|
279
|
+
base_node->type() !=
|
280
|
+
grpc_core::channelz::BaseNode::EntityType::kServer ||
|
281
|
+
start_socket_id < 0 || max_results < 0) {
|
282
|
+
return nullptr;
|
283
|
+
}
|
284
|
+
// This cast is ok since we have just checked to make sure base_node is
|
285
|
+
// actually a server node.
|
286
|
+
grpc_core::channelz::ServerNode* server_node =
|
287
|
+
static_cast<grpc_core::channelz::ServerNode*>(base_node.get());
|
288
|
+
return grpc_core::channelz::v2tov1::ApplyHacks(
|
289
|
+
server_node->RenderServerSockets(start_socket_id, max_results).c_str());
|
290
|
+
}
|
291
|
+
}
|
292
|
+
|
293
|
+
char* grpc_channelz_get_channel(intptr_t channel_id) {
|
294
|
+
grpc_core::ExecCtx exec_ctx;
|
295
|
+
if (grpc_core::IsChannelzUseV2ForV1ApiEnabled()) {
|
296
|
+
auto channel_node = ChannelzRegistry::GetChannel(channel_id);
|
297
|
+
if (channel_node == nullptr) return nullptr;
|
298
|
+
RegistryEntityFetcher fetcher;
|
299
|
+
auto serialized_v2 = channel_node->SerializeEntityToString();
|
300
|
+
auto serialized_v1 = grpc_core::channelz::v2tov1::ConvertChannel(
|
301
|
+
serialized_v2, fetcher, true);
|
302
|
+
if (!serialized_v1.ok()) {
|
303
|
+
LOG(ERROR) << "Failed to convert channel: " << serialized_v1.status();
|
304
|
+
return nullptr;
|
305
|
+
}
|
306
|
+
auto json = grpc_core::JsonParse(*serialized_v1);
|
307
|
+
if (!json.ok()) {
|
308
|
+
LOG(ERROR) << "Failed to parse converted channel json: " << json.status();
|
309
|
+
return nullptr;
|
310
|
+
}
|
311
|
+
grpc_core::Json wrapped_json = grpc_core::Json::FromObject({
|
312
|
+
{"channel", std::move(*json)},
|
313
|
+
});
|
314
|
+
std::string json_str = grpc_core::JsonDump(wrapped_json);
|
315
|
+
return gpr_strdup(json_str.c_str());
|
316
|
+
} else {
|
317
|
+
grpc_core::WeakRefCountedPtr<grpc_core::channelz::BaseNode> channel_node =
|
318
|
+
grpc_core::channelz::ChannelzRegistry::Get(channel_id);
|
319
|
+
if (channel_node == nullptr ||
|
320
|
+
(channel_node->type() !=
|
321
|
+
grpc_core::channelz::BaseNode::EntityType::kTopLevelChannel &&
|
322
|
+
channel_node->type() !=
|
323
|
+
grpc_core::channelz::BaseNode::EntityType::kInternalChannel)) {
|
324
|
+
return nullptr;
|
325
|
+
}
|
326
|
+
grpc_core::Json json = grpc_core::Json::FromObject({
|
327
|
+
{"channel", channel_node->RenderJson()},
|
328
|
+
});
|
329
|
+
return grpc_core::channelz::v2tov1::ApplyHacks(
|
330
|
+
grpc_core::JsonDump(json).c_str());
|
331
|
+
}
|
332
|
+
}
|
333
|
+
|
334
|
+
char* grpc_channelz_get_subchannel(intptr_t subchannel_id) {
|
335
|
+
grpc_core::ExecCtx exec_ctx;
|
336
|
+
if (grpc_core::IsChannelzUseV2ForV1ApiEnabled()) {
|
337
|
+
auto subchannel_node = ChannelzRegistry::GetSubchannel(subchannel_id);
|
338
|
+
if (subchannel_node == nullptr) return nullptr;
|
339
|
+
RegistryEntityFetcher fetcher;
|
340
|
+
auto serialized_v2 = subchannel_node->SerializeEntityToString();
|
341
|
+
auto serialized_v1 = grpc_core::channelz::v2tov1::ConvertSubchannel(
|
342
|
+
serialized_v2, fetcher, true);
|
343
|
+
if (!serialized_v1.ok()) {
|
344
|
+
LOG(ERROR) << "Failed to convert subchannel: " << serialized_v1.status();
|
345
|
+
return nullptr;
|
346
|
+
}
|
347
|
+
auto json = grpc_core::JsonParse(*serialized_v1);
|
348
|
+
if (!json.ok()) {
|
349
|
+
LOG(ERROR) << "Failed to parse converted subchannel json: "
|
350
|
+
<< json.status();
|
351
|
+
return nullptr;
|
352
|
+
}
|
353
|
+
grpc_core::Json wrapped_json = grpc_core::Json::FromObject({
|
354
|
+
{"subchannel", std::move(*json)},
|
355
|
+
});
|
356
|
+
std::string json_str = grpc_core::JsonDump(wrapped_json);
|
357
|
+
return gpr_strdup(json_str.c_str());
|
358
|
+
} else {
|
359
|
+
grpc_core::WeakRefCountedPtr<grpc_core::channelz::BaseNode>
|
360
|
+
subchannel_node =
|
361
|
+
grpc_core::channelz::ChannelzRegistry::Get(subchannel_id);
|
362
|
+
if (subchannel_node == nullptr ||
|
363
|
+
subchannel_node->type() !=
|
364
|
+
grpc_core::channelz::BaseNode::EntityType::kSubchannel) {
|
365
|
+
return nullptr;
|
366
|
+
}
|
367
|
+
grpc_core::Json json = grpc_core::Json::FromObject({
|
368
|
+
{"subchannel", subchannel_node->RenderJson()},
|
369
|
+
});
|
370
|
+
return grpc_core::channelz::v2tov1::ApplyHacks(
|
371
|
+
grpc_core::JsonDump(json).c_str());
|
372
|
+
}
|
373
|
+
}
|
374
|
+
|
375
|
+
char* grpc_channelz_get_socket(intptr_t socket_id) {
|
376
|
+
grpc_core::ExecCtx exec_ctx;
|
377
|
+
if (grpc_core::IsChannelzUseV2ForV1ApiEnabled()) {
|
378
|
+
auto node = ChannelzRegistry::GetNode(socket_id);
|
379
|
+
if (node == nullptr) return nullptr;
|
380
|
+
RegistryEntityFetcher fetcher;
|
381
|
+
auto serialized_v2 = node->SerializeEntityToString();
|
382
|
+
absl::StatusOr<std::string> serialized_v1;
|
383
|
+
if (node->type() == grpc_core::channelz::BaseNode::EntityType::kSocket) {
|
384
|
+
serialized_v1 = grpc_core::channelz::v2tov1::ConvertSocket(serialized_v2,
|
385
|
+
fetcher, true);
|
386
|
+
} else if (node->type() ==
|
387
|
+
grpc_core::channelz::BaseNode::EntityType::kListenSocket) {
|
388
|
+
serialized_v1 = grpc_core::channelz::v2tov1::ConvertListenSocket(
|
389
|
+
serialized_v2, fetcher, true);
|
390
|
+
} else {
|
391
|
+
return nullptr;
|
392
|
+
}
|
393
|
+
if (!serialized_v1.ok()) {
|
394
|
+
LOG(ERROR) << "Failed to convert socket: " << serialized_v1.status();
|
395
|
+
return nullptr;
|
396
|
+
}
|
397
|
+
// The old API returned a JSON object with a "socket" key.
|
398
|
+
// The new converter returns the socket JSON directly. We need to wrap it.
|
399
|
+
auto json = grpc_core::JsonParse(*serialized_v1);
|
400
|
+
if (!json.ok()) {
|
401
|
+
LOG(ERROR) << "Failed to parse converted socket json: " << json.status();
|
402
|
+
return nullptr;
|
403
|
+
}
|
404
|
+
grpc_core::Json wrapped_json = grpc_core::Json::FromObject({
|
405
|
+
{"socket", std::move(*json)},
|
406
|
+
});
|
407
|
+
std::string json_str = grpc_core::JsonDump(wrapped_json);
|
408
|
+
return gpr_strdup(json_str.c_str());
|
409
|
+
} else {
|
410
|
+
grpc_core::WeakRefCountedPtr<grpc_core::channelz::BaseNode> socket_node =
|
411
|
+
grpc_core::channelz::ChannelzRegistry::Get(socket_id);
|
412
|
+
if (socket_node == nullptr ||
|
413
|
+
(socket_node->type() !=
|
414
|
+
grpc_core::channelz::BaseNode::EntityType::kSocket &&
|
415
|
+
socket_node->type() !=
|
416
|
+
grpc_core::channelz::BaseNode::EntityType::kListenSocket)) {
|
417
|
+
return nullptr;
|
418
|
+
}
|
419
|
+
grpc_core::Json json = grpc_core::Json::FromObject({
|
420
|
+
{"socket", socket_node->RenderJson()},
|
421
|
+
});
|
422
|
+
return grpc_core::channelz::v2tov1::ApplyHacks(
|
423
|
+
grpc_core::JsonDump(json).c_str());
|
424
|
+
}
|
425
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// Copyright 2025 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#ifndef GRPC_SRC_CORE_CHANNELZ_V2TOV1_LEGACY_API_H
|
16
|
+
#define GRPC_SRC_CORE_CHANNELZ_V2TOV1_LEGACY_API_H
|
17
|
+
|
18
|
+
#include <string>
|
19
|
+
|
20
|
+
#include "absl/strings/string_view.h"
|
21
|
+
|
22
|
+
namespace grpc_core {
|
23
|
+
namespace channelz {
|
24
|
+
namespace v2tov1 {
|
25
|
+
|
26
|
+
std::string StripAdditionalInfoFromJson(absl::string_view json_str);
|
27
|
+
|
28
|
+
} // namespace v2tov1
|
29
|
+
} // namespace channelz
|
30
|
+
} // namespace grpc_core
|
31
|
+
|
32
|
+
#endif // GRPC_SRC_CORE_CHANNELZ_V2TOV1_LEGACY_API_H
|
@@ -0,0 +1,118 @@
|
|
1
|
+
// Copyright 2025 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#include "src/core/channelz/v2tov1/property_list.h"
|
16
|
+
|
17
|
+
#include <cstdint>
|
18
|
+
#include <optional>
|
19
|
+
#include <string>
|
20
|
+
|
21
|
+
#include "absl/strings/string_view.h"
|
22
|
+
#include "google/protobuf/any.upb.h"
|
23
|
+
#include "google/protobuf/duration.upb.h"
|
24
|
+
#include "google/protobuf/timestamp.upb.h"
|
25
|
+
#include "src/core/util/upb_utils.h"
|
26
|
+
#include "src/proto/grpc/channelz/v2/property_list.upb.h"
|
27
|
+
#include "upb/mem/arena.hpp"
|
28
|
+
|
29
|
+
namespace grpc_core {
|
30
|
+
namespace channelz {
|
31
|
+
namespace v2tov1 {
|
32
|
+
|
33
|
+
namespace {
|
34
|
+
|
35
|
+
const grpc_channelz_v2_PropertyValue* FindProperty(
|
36
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name) {
|
37
|
+
size_t size;
|
38
|
+
const grpc_channelz_v2_PropertyList_Element* const* elements =
|
39
|
+
grpc_channelz_v2_PropertyList_properties(pl, &size);
|
40
|
+
for (size_t i = 0; i < size; i++) {
|
41
|
+
const grpc_channelz_v2_PropertyList_Element* element = elements[i];
|
42
|
+
upb_StringView label = grpc_channelz_v2_PropertyList_Element_key(element);
|
43
|
+
if (absl::string_view(label.data, label.size) == name) {
|
44
|
+
return grpc_channelz_v2_PropertyList_Element_value(element);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
return nullptr;
|
48
|
+
}
|
49
|
+
|
50
|
+
} // namespace
|
51
|
+
|
52
|
+
std::optional<int64_t> Int64FromPropertyList(
|
53
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name) {
|
54
|
+
const auto* prop = FindProperty(pl, name);
|
55
|
+
if (prop == nullptr) return std::nullopt;
|
56
|
+
if (grpc_channelz_v2_PropertyValue_has_int64_value(prop)) {
|
57
|
+
return grpc_channelz_v2_PropertyValue_int64_value(prop);
|
58
|
+
}
|
59
|
+
if (grpc_channelz_v2_PropertyValue_has_uint64_value(prop)) {
|
60
|
+
uint64_t val = grpc_channelz_v2_PropertyValue_uint64_value(prop);
|
61
|
+
if (val <= static_cast<uint64_t>(std::numeric_limits<int64_t>::max())) {
|
62
|
+
return static_cast<int64_t>(val);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return std::nullopt;
|
66
|
+
}
|
67
|
+
|
68
|
+
std::optional<std::string> StringFromPropertyList(
|
69
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name) {
|
70
|
+
const auto* prop = FindProperty(pl, name);
|
71
|
+
if (prop == nullptr) return std::nullopt;
|
72
|
+
if (grpc_channelz_v2_PropertyValue_has_string_value(prop)) {
|
73
|
+
return UpbStringToStdString(
|
74
|
+
grpc_channelz_v2_PropertyValue_string_value(prop));
|
75
|
+
}
|
76
|
+
return std::nullopt;
|
77
|
+
}
|
78
|
+
|
79
|
+
const google_protobuf_Timestamp* TimestampFromPropertyList(
|
80
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name) {
|
81
|
+
const auto* prop = FindProperty(pl, name);
|
82
|
+
if (prop == nullptr) return nullptr;
|
83
|
+
if (grpc_channelz_v2_PropertyValue_has_timestamp_value(prop)) {
|
84
|
+
return grpc_channelz_v2_PropertyValue_timestamp_value(prop);
|
85
|
+
}
|
86
|
+
return nullptr;
|
87
|
+
}
|
88
|
+
|
89
|
+
const grpc_channelz_v2_PropertyList* PropertyListFromPropertyList(
|
90
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name,
|
91
|
+
upb_Arena* arena) {
|
92
|
+
const auto* prop = FindProperty(pl, name);
|
93
|
+
if (prop == nullptr) return nullptr;
|
94
|
+
if (grpc_channelz_v2_PropertyValue_has_any_value(prop)) {
|
95
|
+
const auto* any = grpc_channelz_v2_PropertyValue_any_value(prop);
|
96
|
+
auto type_url = UpbStringToAbsl(google_protobuf_Any_type_url(any));
|
97
|
+
if (type_url != "type.googleapis.com/grpc.channelz.v2.PropertyList") {
|
98
|
+
return nullptr;
|
99
|
+
}
|
100
|
+
upb_StringView value = google_protobuf_Any_value(any);
|
101
|
+
return grpc_channelz_v2_PropertyList_parse(value.data, value.size, arena);
|
102
|
+
}
|
103
|
+
return nullptr;
|
104
|
+
}
|
105
|
+
|
106
|
+
const google_protobuf_Duration* DurationFromPropertyList(
|
107
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name) {
|
108
|
+
const auto* prop = FindProperty(pl, name);
|
109
|
+
if (prop == nullptr) return nullptr;
|
110
|
+
if (grpc_channelz_v2_PropertyValue_has_duration_value(prop)) {
|
111
|
+
return grpc_channelz_v2_PropertyValue_duration_value(prop);
|
112
|
+
}
|
113
|
+
return nullptr;
|
114
|
+
}
|
115
|
+
|
116
|
+
} // namespace v2tov1
|
117
|
+
} // namespace channelz
|
118
|
+
} // namespace grpc_core
|
@@ -0,0 +1,52 @@
|
|
1
|
+
// Copyright 2025 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#ifndef GRPC_SRC_CORE_CHANNELZ_V2TOV1_PROPERTY_LIST_H
|
16
|
+
#define GRPC_SRC_CORE_CHANNELZ_V2TOV1_PROPERTY_LIST_H
|
17
|
+
|
18
|
+
#include <cstdint>
|
19
|
+
#include <optional>
|
20
|
+
#include <string>
|
21
|
+
#include <utility>
|
22
|
+
|
23
|
+
#include "absl/strings/string_view.h"
|
24
|
+
|
25
|
+
// Forward declarations for UPB types.
|
26
|
+
struct grpc_channelz_v2_PropertyList;
|
27
|
+
struct upb_Arena;
|
28
|
+
struct google_protobuf_Timestamp;
|
29
|
+
struct google_protobuf_Duration;
|
30
|
+
|
31
|
+
namespace grpc_core {
|
32
|
+
namespace channelz {
|
33
|
+
namespace v2tov1 {
|
34
|
+
|
35
|
+
// Helpers for extracting values from a PropertyList.
|
36
|
+
std::optional<int64_t> Int64FromPropertyList(
|
37
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name);
|
38
|
+
std::optional<std::string> StringFromPropertyList(
|
39
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name);
|
40
|
+
const google_protobuf_Timestamp* TimestampFromPropertyList(
|
41
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name);
|
42
|
+
const grpc_channelz_v2_PropertyList* PropertyListFromPropertyList(
|
43
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name,
|
44
|
+
upb_Arena* arena);
|
45
|
+
const google_protobuf_Duration* DurationFromPropertyList(
|
46
|
+
const grpc_channelz_v2_PropertyList* pl, absl::string_view name);
|
47
|
+
|
48
|
+
} // namespace v2tov1
|
49
|
+
} // namespace channelz
|
50
|
+
} // namespace grpc_core
|
51
|
+
|
52
|
+
#endif // GRPC_SRC_CORE_CHANNELZ_V2TOV1_PROPERTY_LIST_H
|