grpc 1.49.1-x86_64-linux → 1.50.0.pre1-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +54 -153
- data/include/grpc/event_engine/endpoint_config.h +11 -5
- data/include/grpc/event_engine/event_engine.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
- data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
- data/include/grpc/impl/codegen/atm_windows.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
- data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
- data/src/core/ext/filters/client_channel/client_channel.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
- data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
- data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
- data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
- data/src/core/ext/filters/client_channel/subchannel.h +12 -3
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
- data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
- data/src/core/ext/xds/certificate_provider_store.cc +63 -3
- data/src/core/ext/xds/certificate_provider_store.h +9 -1
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/xds_api.cc +21 -17
- data/src/core/ext/xds/xds_api.h +7 -0
- data/src/core/ext/xds/xds_bootstrap.cc +5 -537
- data/src/core/ext/xds/xds_bootstrap.h +39 -111
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
- data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
- data/src/core/ext/xds/xds_client.cc +219 -145
- data/src/core/ext/xds/xds_client.h +19 -17
- data/src/core/ext/xds/xds_client_grpc.cc +18 -80
- data/src/core/ext/xds/xds_client_grpc.h +2 -25
- data/src/core/ext/xds/xds_client_stats.cc +4 -4
- data/src/core/ext/xds/xds_cluster.cc +87 -79
- data/src/core/ext/xds/xds_cluster.h +5 -5
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
- data/src/core/ext/xds/xds_common_types.cc +13 -5
- data/src/core/ext/xds/xds_endpoint.cc +8 -6
- data/src/core/ext/xds/xds_endpoint.h +3 -4
- data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
- data/src/core/ext/xds/xds_listener.cc +25 -20
- data/src/core/ext/xds/xds_listener.h +3 -4
- data/src/core/ext/xds/xds_resource_type.h +11 -8
- data/src/core/ext/xds/xds_route_config.cc +15 -16
- data/src/core/ext/xds/xds_route_config.h +3 -3
- data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
- data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
- data/src/core/lib/backoff/backoff.cc +2 -4
- data/src/core/lib/channel/call_finalization.h +1 -3
- data/src/core/lib/channel/channel_args.h +114 -14
- data/src/core/lib/channel/channel_trace.cc +3 -4
- data/src/core/lib/channel/promise_based_filter.cc +18 -19
- data/src/core/lib/channel/status_util.cc +27 -0
- data/src/core/lib/channel/status_util.h +10 -0
- data/src/core/lib/config/core_configuration.cc +5 -1
- data/src/core/lib/config/core_configuration.h +33 -0
- data/src/core/lib/debug/stats.cc +26 -30
- data/src/core/lib/debug/stats.h +2 -12
- data/src/core/lib/debug/stats_data.cc +118 -614
- data/src/core/lib/debug/stats_data.h +67 -465
- data/src/core/lib/debug/trace.cc +0 -2
- data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
- data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
- data/src/core/lib/event_engine/forkable.cc +1 -1
- data/src/core/lib/event_engine/poller.h +14 -12
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
- data/src/core/lib/event_engine/thread_pool.cc +131 -94
- data/src/core/lib/event_engine/thread_pool.h +56 -23
- data/src/core/lib/event_engine/time_util.cc +30 -0
- data/src/core/lib/event_engine/time_util.h +32 -0
- data/src/core/lib/event_engine/utils.cc +0 -5
- data/src/core/lib/event_engine/utils.h +0 -4
- data/src/core/lib/event_engine/windows/iocp.cc +13 -7
- data/src/core/lib/event_engine/windows/iocp.h +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
- data/src/core/lib/experiments/config.cc +146 -0
- data/src/core/lib/experiments/config.h +43 -0
- data/src/core/lib/experiments/experiments.cc +75 -0
- data/src/core/lib/experiments/experiments.h +56 -0
- data/src/core/lib/gpr/alloc.cc +1 -9
- data/src/core/lib/gpr/log_windows.cc +0 -1
- data/src/core/lib/gpr/string_util_windows.cc +3 -30
- data/src/core/lib/gpr/sync_abseil.cc +0 -14
- data/src/core/lib/gpr/sync_posix.cc +0 -14
- data/src/core/lib/gpr/time_posix.cc +0 -6
- data/src/core/lib/gpr/time_precise.h +1 -1
- data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
- data/src/core/lib/gpr/useful.h +11 -0
- data/src/core/lib/{gpr → gprpp}/env.h +25 -12
- data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
- data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
- data/src/core/lib/gprpp/env_windows.cc +56 -0
- data/src/core/lib/gprpp/fork.cc +14 -22
- data/src/core/lib/gprpp/fork.h +0 -8
- data/src/core/lib/gprpp/global_config_env.cc +7 -6
- data/src/core/lib/gprpp/notification.h +67 -0
- data/src/core/lib/gprpp/packed_table.h +40 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
- data/src/core/lib/gprpp/sorted_pack.h +98 -0
- data/src/core/lib/gprpp/status_helper.h +6 -0
- data/src/core/lib/gprpp/table.h +9 -1
- data/src/core/lib/gprpp/tchar.cc +49 -0
- data/src/core/lib/gprpp/tchar.h +33 -0
- data/src/core/lib/gprpp/time.cc +21 -0
- data/src/core/lib/gprpp/time.h +55 -0
- data/src/core/lib/gprpp/validation_errors.cc +61 -0
- data/src/core/lib/gprpp/validation_errors.h +110 -0
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
- data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
- data/src/core/lib/iomgr/call_combiner.cc +0 -8
- data/src/core/lib/iomgr/closure.h +0 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
- data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
- data/src/core/lib/iomgr/exec_ctx.cc +0 -10
- data/src/core/lib/iomgr/exec_ctx.h +7 -31
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +6 -8
- data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_set.h +0 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -0
- data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
- data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
- data/src/core/lib/iomgr/tcp_client.cc +6 -7
- data/src/core/lib/iomgr/tcp_client.h +11 -11
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
- data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
- data/src/core/lib/iomgr/tcp_posix.cc +131 -114
- data/src/core/lib/iomgr/tcp_posix.h +3 -1
- data/src/core/lib/iomgr/tcp_server.cc +5 -4
- data/src/core/lib/iomgr/tcp_server.h +9 -6
- data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
- data/src/core/lib/iomgr/tcp_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_windows.h +0 -1
- data/src/core/lib/iomgr/timer_generic.cc +4 -4
- data/src/core/lib/iomgr/timer_manager.cc +1 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
- data/src/core/lib/json/json_object_loader.cc +21 -52
- data/src/core/lib/json/json_object_loader.h +56 -76
- data/src/core/lib/json/json_util.cc +2 -1
- data/src/core/lib/load_balancing/lb_policy.h +5 -5
- data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
- data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
- data/src/core/lib/promise/activity.h +2 -3
- data/src/core/lib/promise/context.h +1 -1
- data/src/core/lib/promise/sleep.cc +16 -4
- data/src/core/lib/promise/sleep.h +8 -2
- data/src/core/lib/resolver/resolver.h +13 -3
- data/src/core/lib/resource_quota/api.cc +9 -0
- data/src/core/lib/resource_quota/api.h +6 -0
- data/src/core/lib/resource_quota/arena.cc +1 -3
- data/src/core/lib/resource_quota/memory_quota.cc +8 -24
- data/src/core/lib/resource_quota/memory_quota.h +6 -19
- data/src/core/lib/resource_quota/periodic_update.cc +2 -3
- data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
- data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
- data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
- data/src/core/lib/surface/call.cc +1 -11
- data/src/core/lib/surface/channel.cc +3 -2
- data/src/core/lib/surface/completion_queue.cc +16 -28
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +5 -0
- data/src/core/lib/surface/init.cc +16 -11
- data/src/core/lib/surface/init_internally.cc +24 -0
- data/src/core/lib/surface/init_internally.h +28 -0
- data/src/core/lib/surface/server.cc +1 -7
- data/src/core/lib/surface/server.h +4 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +1 -3
- data/src/core/lib/transport/metadata_batch.cc +2 -3
- data/src/core/lib/transport/metadata_batch.h +9 -7
- data/src/core/lib/transport/parsed_metadata.h +4 -2
- data/src/core/lib/transport/status_conversion.cc +1 -3
- data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
- data/src/core/lib/transport/transport.h +0 -1
- data/src/core/lib/transport/transport_impl.h +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
- data/src/ruby/lib/grpc/2.6/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.0/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.1/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_spec.rb +5 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
- data/src/ruby/spec/user_agent_spec.rb +1 -1
- metadata +33 -19
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
- data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
- data/src/core/ext/xds/certificate_provider_registry.h +0 -59
- data/src/core/lib/event_engine/promise.h +0 -78
- data/src/core/lib/gpr/env_windows.cc +0 -74
- data/src/core/lib/gpr/string_windows.h +0 -32
- data/src/core/lib/profiling/basic_timers.cc +0 -295
- data/src/core/lib/profiling/stap_timers.cc +0 -50
- data/src/core/lib/profiling/timers.h +0 -94
@@ -54,7 +54,7 @@ namespace grpc_core {
|
|
54
54
|
// ChannelArgs to automatically derive a vtable from a T*.
|
55
55
|
// To participate as a pointer, instances should expose the function:
|
56
56
|
// // Gets the vtable for this type
|
57
|
-
// static const
|
57
|
+
// static const grpc_arg_pointer_vtable* VTable();
|
58
58
|
// // Performs any mutations required for channel args to own a pointer
|
59
59
|
// // Only needed if ChannelArgs::Set is to be called with a raw pointer.
|
60
60
|
// static void* TakeUnownedPointer(T* p);
|
@@ -117,6 +117,32 @@ struct ChannelArgTypeTraits<
|
|
117
117
|
};
|
118
118
|
};
|
119
119
|
|
120
|
+
// Specialization for shared_ptr
|
121
|
+
// Incurs an allocation because shared_ptr.release is not a thing.
|
122
|
+
template <typename T>
|
123
|
+
struct is_shared_ptr : std::false_type {};
|
124
|
+
template <typename T>
|
125
|
+
struct is_shared_ptr<std::shared_ptr<T>> : std::true_type {};
|
126
|
+
template <typename T>
|
127
|
+
struct ChannelArgTypeTraits<T,
|
128
|
+
absl::enable_if_t<is_shared_ptr<T>::value, void>> {
|
129
|
+
static void* TakeUnownedPointer(T* p) { return p; }
|
130
|
+
static const grpc_arg_pointer_vtable* VTable() {
|
131
|
+
static const grpc_arg_pointer_vtable tbl = {
|
132
|
+
// copy
|
133
|
+
[](void* p) -> void* { return new T(*static_cast<T*>(p)); },
|
134
|
+
// destroy
|
135
|
+
[](void* p) { delete static_cast<T*>(p); },
|
136
|
+
// compare
|
137
|
+
[](void* p1, void* p2) {
|
138
|
+
return QsortCompare(static_cast<const T*>(p1)->get(),
|
139
|
+
static_cast<const T*>(p2)->get());
|
140
|
+
},
|
141
|
+
};
|
142
|
+
return &tbl;
|
143
|
+
};
|
144
|
+
};
|
145
|
+
|
120
146
|
// If a type declares some member 'struct RawPointerChannelArgTag {}' then
|
121
147
|
// we automatically generate a vtable for it that does not do any ownership
|
122
148
|
// management and compares the type by pointer identity.
|
@@ -139,6 +165,55 @@ struct ChannelArgTypeTraits<T,
|
|
139
165
|
};
|
140
166
|
};
|
141
167
|
|
168
|
+
// GetObject support for shared_ptr and RefCountedPtr
|
169
|
+
template <typename T>
|
170
|
+
struct WrapInSharedPtr
|
171
|
+
: std::integral_constant<
|
172
|
+
bool, std::is_base_of<std::enable_shared_from_this<T>, T>::value> {};
|
173
|
+
template <typename T, typename Ignored = void /* for SFINAE */>
|
174
|
+
struct GetObjectImpl;
|
175
|
+
// std::shared_ptr implementation
|
176
|
+
template <typename T>
|
177
|
+
struct GetObjectImpl<T, absl::enable_if_t<WrapInSharedPtr<T>::value, void>> {
|
178
|
+
using Result = T*;
|
179
|
+
using ReffedResult = std::shared_ptr<T>;
|
180
|
+
using StoredType = std::shared_ptr<T>*;
|
181
|
+
static Result Get(StoredType p) { return p->get(); };
|
182
|
+
static ReffedResult GetReffed(StoredType p) { return ReffedResult(*p); };
|
183
|
+
static ReffedResult GetReffed(StoredType p,
|
184
|
+
const DebugLocation& /* location */,
|
185
|
+
const char* /* reason */) {
|
186
|
+
return GetReffed(*p);
|
187
|
+
};
|
188
|
+
};
|
189
|
+
// RefCountedPtr
|
190
|
+
template <typename T>
|
191
|
+
struct GetObjectImpl<T, absl::enable_if_t<!WrapInSharedPtr<T>::value, void>> {
|
192
|
+
using Result = T*;
|
193
|
+
using ReffedResult = RefCountedPtr<T>;
|
194
|
+
using StoredType = Result;
|
195
|
+
static Result Get(StoredType p) { return p; };
|
196
|
+
static ReffedResult GetReffed(StoredType p) {
|
197
|
+
if (p == nullptr) return nullptr;
|
198
|
+
return p->Ref();
|
199
|
+
};
|
200
|
+
static ReffedResult GetReffed(StoredType p, const DebugLocation& location,
|
201
|
+
const char* reason) {
|
202
|
+
if (p == nullptr) return nullptr;
|
203
|
+
return p->Ref(location, reason);
|
204
|
+
};
|
205
|
+
};
|
206
|
+
|
207
|
+
// Provide the canonical name for a type's channel arg key
|
208
|
+
template <typename T>
|
209
|
+
struct ChannelArgNameTraits {
|
210
|
+
static absl::string_view ChannelArgName() { return T::ChannelArgName(); }
|
211
|
+
};
|
212
|
+
template <typename T>
|
213
|
+
struct ChannelArgNameTraits<std::shared_ptr<T>> {
|
214
|
+
static absl::string_view ChannelArgName() { return T::ChannelArgName(); }
|
215
|
+
};
|
216
|
+
|
142
217
|
class ChannelArgs {
|
143
218
|
public:
|
144
219
|
class Pointer {
|
@@ -243,6 +318,20 @@ class ChannelArgs {
|
|
243
318
|
ChannelArgTypeTraits<absl::remove_cvref_t<T>>::VTable()));
|
244
319
|
}
|
245
320
|
template <typename T>
|
321
|
+
GRPC_MUST_USE_RESULT absl::enable_if_t<
|
322
|
+
std::is_same<
|
323
|
+
const grpc_arg_pointer_vtable*,
|
324
|
+
decltype(ChannelArgTypeTraits<std::shared_ptr<T>>::VTable())>::value,
|
325
|
+
ChannelArgs>
|
326
|
+
Set(absl::string_view name, std::shared_ptr<T> value) const {
|
327
|
+
auto* store_value = new std::shared_ptr<T>(value);
|
328
|
+
return Set(
|
329
|
+
name,
|
330
|
+
Pointer(ChannelArgTypeTraits<std::shared_ptr<T>>::TakeUnownedPointer(
|
331
|
+
store_value),
|
332
|
+
ChannelArgTypeTraits<std::shared_ptr<T>>::VTable()));
|
333
|
+
}
|
334
|
+
template <typename T>
|
246
335
|
GRPC_MUST_USE_RESULT ChannelArgs SetIfUnset(absl::string_view name,
|
247
336
|
T value) const {
|
248
337
|
if (Contains(name)) return *this;
|
@@ -251,13 +340,20 @@ class ChannelArgs {
|
|
251
340
|
GRPC_MUST_USE_RESULT ChannelArgs Remove(absl::string_view name) const;
|
252
341
|
bool Contains(absl::string_view name) const;
|
253
342
|
|
343
|
+
template <typename T>
|
344
|
+
bool ContainsObject() const {
|
345
|
+
return Get(ChannelArgNameTraits<T>::ChannelArgName()) != nullptr;
|
346
|
+
}
|
347
|
+
|
254
348
|
absl::optional<int> GetInt(absl::string_view name) const;
|
255
349
|
absl::optional<absl::string_view> GetString(absl::string_view name) const;
|
256
350
|
absl::optional<std::string> GetOwnedString(absl::string_view name) const;
|
257
351
|
void* GetVoidPointer(absl::string_view name) const;
|
258
352
|
template <typename T>
|
259
|
-
T
|
260
|
-
|
353
|
+
typename GetObjectImpl<T>::StoredType GetPointer(
|
354
|
+
absl::string_view name) const {
|
355
|
+
return static_cast<typename GetObjectImpl<T>::StoredType>(
|
356
|
+
GetVoidPointer(name));
|
261
357
|
}
|
262
358
|
absl::optional<Duration> GetDurationFromIntMillis(
|
263
359
|
absl::string_view name) const;
|
@@ -277,21 +373,25 @@ class ChannelArgs {
|
|
277
373
|
return Set(T::ChannelArgName(), std::move(p));
|
278
374
|
}
|
279
375
|
template <typename T>
|
280
|
-
T
|
281
|
-
return
|
376
|
+
GRPC_MUST_USE_RESULT ChannelArgs SetObject(std::shared_ptr<T> p) const {
|
377
|
+
return Set(ChannelArgNameTraits<T>::ChannelArgName(), std::move(p));
|
282
378
|
}
|
283
379
|
template <typename T>
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
return p->Ref(DEBUG_LOCATION, "ChannelArgs GetObjectRef()");
|
380
|
+
typename GetObjectImpl<T>::Result GetObject() const {
|
381
|
+
return GetObjectImpl<T>::Get(
|
382
|
+
GetPointer<T>(ChannelArgNameTraits<T>::ChannelArgName()));
|
288
383
|
}
|
289
384
|
template <typename T>
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
385
|
+
typename GetObjectImpl<T>::ReffedResult GetObjectRef() const {
|
386
|
+
return GetObjectImpl<T>::GetReffed(
|
387
|
+
GetPointer<T>(ChannelArgNameTraits<T>::ChannelArgName()));
|
388
|
+
}
|
389
|
+
template <typename T>
|
390
|
+
typename GetObjectImpl<T>::ReffedResult GetObjectRef(
|
391
|
+
const DebugLocation& location, const char* reason) const {
|
392
|
+
return GetObjectImpl<T>::GetReffed(
|
393
|
+
GetPointer<T>(ChannelArgNameTraits<T>::ChannelArgName()), location,
|
394
|
+
reason);
|
295
395
|
}
|
296
396
|
|
297
397
|
bool operator!=(const ChannelArgs& other) const;
|
@@ -30,7 +30,6 @@
|
|
30
30
|
#include "src/core/lib/channel/channelz.h"
|
31
31
|
#include "src/core/lib/gpr/string.h"
|
32
32
|
#include "src/core/lib/gprpp/time.h"
|
33
|
-
#include "src/core/lib/iomgr/exec_ctx.h"
|
34
33
|
#include "src/core/lib/slice/slice_internal.h"
|
35
34
|
#include "src/core/lib/slice/slice_refcount.h"
|
36
35
|
|
@@ -41,7 +40,7 @@ ChannelTrace::TraceEvent::TraceEvent(Severity severity, const grpc_slice& data,
|
|
41
40
|
RefCountedPtr<BaseNode> referenced_entity)
|
42
41
|
: severity_(severity),
|
43
42
|
data_(data),
|
44
|
-
timestamp_(
|
43
|
+
timestamp_(Timestamp::Now().as_timespec(GPR_CLOCK_REALTIME)),
|
45
44
|
next_(nullptr),
|
46
45
|
referenced_entity_(std::move(referenced_entity)),
|
47
46
|
memory_usage_(sizeof(TraceEvent) + grpc_slice_memory_usage(data)) {}
|
@@ -49,7 +48,7 @@ ChannelTrace::TraceEvent::TraceEvent(Severity severity, const grpc_slice& data,
|
|
49
48
|
ChannelTrace::TraceEvent::TraceEvent(Severity severity, const grpc_slice& data)
|
50
49
|
: severity_(severity),
|
51
50
|
data_(data),
|
52
|
-
timestamp_(
|
51
|
+
timestamp_(Timestamp::Now().as_timespec(GPR_CLOCK_REALTIME)),
|
53
52
|
next_(nullptr),
|
54
53
|
memory_usage_(sizeof(TraceEvent) + grpc_slice_memory_usage(data)) {}
|
55
54
|
|
@@ -65,7 +64,7 @@ ChannelTrace::ChannelTrace(size_t max_event_memory)
|
|
65
64
|
return; // tracing is disabled if max_event_memory_ == 0
|
66
65
|
}
|
67
66
|
gpr_mu_init(&tracer_mu_);
|
68
|
-
time_created_ =
|
67
|
+
time_created_ = Timestamp::Now().as_timespec(GPR_CLOCK_REALTIME);
|
69
68
|
}
|
70
69
|
|
71
70
|
ChannelTrace::~ChannelTrace() {
|
@@ -22,7 +22,6 @@
|
|
22
22
|
#include "absl/base/attributes.h"
|
23
23
|
#include "absl/memory/memory.h"
|
24
24
|
#include "absl/types/variant.h"
|
25
|
-
#include "absl/utility/utility.h"
|
26
25
|
|
27
26
|
#include <grpc/status.h>
|
28
27
|
|
@@ -134,7 +133,7 @@ BaseCallData::CapturedBatch& BaseCallData::CapturedBatch::operator=(
|
|
134
133
|
}
|
135
134
|
|
136
135
|
void BaseCallData::CapturedBatch::ResumeWith(Flusher* releaser) {
|
137
|
-
auto* batch =
|
136
|
+
auto* batch = std::exchange(batch_, nullptr);
|
138
137
|
GPR_ASSERT(batch != nullptr);
|
139
138
|
uintptr_t& refcnt = *RefCountField(batch);
|
140
139
|
if (refcnt == 0) return; // refcnt==0 ==> cancelled
|
@@ -144,7 +143,7 @@ void BaseCallData::CapturedBatch::ResumeWith(Flusher* releaser) {
|
|
144
143
|
}
|
145
144
|
|
146
145
|
void BaseCallData::CapturedBatch::CompleteWith(Flusher* releaser) {
|
147
|
-
auto* batch =
|
146
|
+
auto* batch = std::exchange(batch_, nullptr);
|
148
147
|
GPR_ASSERT(batch != nullptr);
|
149
148
|
uintptr_t& refcnt = *RefCountField(batch);
|
150
149
|
if (refcnt == 0) return; // refcnt==0 ==> cancelled
|
@@ -155,7 +154,7 @@ void BaseCallData::CapturedBatch::CompleteWith(Flusher* releaser) {
|
|
155
154
|
|
156
155
|
void BaseCallData::CapturedBatch::CancelWith(grpc_error_handle error,
|
157
156
|
Flusher* releaser) {
|
158
|
-
auto* batch =
|
157
|
+
auto* batch = std::exchange(batch_, nullptr);
|
159
158
|
GPR_ASSERT(batch != nullptr);
|
160
159
|
uintptr_t& refcnt = *RefCountField(batch);
|
161
160
|
if (refcnt == 0) {
|
@@ -282,8 +281,8 @@ class ClientCallData::PollContext {
|
|
282
281
|
self_->recv_initial_metadata_->state =
|
283
282
|
RecvInitialMetadata::kResponded;
|
284
283
|
flusher_->AddClosure(
|
285
|
-
|
286
|
-
|
284
|
+
std::exchange(self_->recv_initial_metadata_->original_on_ready,
|
285
|
+
nullptr),
|
287
286
|
GRPC_ERROR_NONE,
|
288
287
|
"wake_inside_combiner:recv_initial_metadata_ready");
|
289
288
|
}
|
@@ -310,8 +309,8 @@ class ClientCallData::PollContext {
|
|
310
309
|
}
|
311
310
|
self_->recv_trailing_state_ = RecvTrailingState::kResponded;
|
312
311
|
flusher_->AddClosure(
|
313
|
-
|
314
|
-
|
312
|
+
std::exchange(self_->original_recv_trailing_metadata_ready_,
|
313
|
+
nullptr),
|
315
314
|
GRPC_ERROR_NONE, "wake_inside_combiner:recv_trailing_ready:1");
|
316
315
|
if (self_->recv_initial_metadata_ != nullptr) {
|
317
316
|
switch (self_->recv_initial_metadata_->state) {
|
@@ -334,7 +333,7 @@ class ClientCallData::PollContext {
|
|
334
333
|
self_->recv_initial_metadata_->state =
|
335
334
|
RecvInitialMetadata::kResponded;
|
336
335
|
flusher_->AddClosure(
|
337
|
-
|
336
|
+
std::exchange(
|
338
337
|
self_->recv_initial_metadata_->original_on_ready,
|
339
338
|
nullptr),
|
340
339
|
GRPC_ERROR_CANCELLED,
|
@@ -376,7 +375,7 @@ class ClientCallData::PollContext {
|
|
376
375
|
self_->recv_initial_metadata_->state =
|
377
376
|
RecvInitialMetadata::kResponded;
|
378
377
|
flusher_->AddClosure(
|
379
|
-
|
378
|
+
std::exchange(
|
380
379
|
self_->recv_initial_metadata_->original_on_ready,
|
381
380
|
nullptr),
|
382
381
|
GRPC_ERROR_REF(error),
|
@@ -419,8 +418,8 @@ class ClientCallData::PollContext {
|
|
419
418
|
if (self_->recv_trailing_state_ == RecvTrailingState::kComplete) {
|
420
419
|
self_->recv_trailing_state_ = RecvTrailingState::kResponded;
|
421
420
|
flusher_->AddClosure(
|
422
|
-
|
423
|
-
|
421
|
+
std::exchange(self_->original_recv_trailing_metadata_ready_,
|
422
|
+
nullptr),
|
424
423
|
GRPC_ERROR_NONE, "wake_inside_combiner:recv_trailing_ready:2");
|
425
424
|
}
|
426
425
|
break;
|
@@ -646,7 +645,7 @@ void ClientCallData::Cancel(grpc_error_handle error) {
|
|
646
645
|
recv_initial_metadata_->state = RecvInitialMetadata::kResponded;
|
647
646
|
GRPC_CALL_COMBINER_START(
|
648
647
|
call_combiner(),
|
649
|
-
|
648
|
+
std::exchange(recv_initial_metadata_->original_on_ready, nullptr),
|
650
649
|
GRPC_ERROR_REF(error), "propagate cancellation");
|
651
650
|
break;
|
652
651
|
case RecvInitialMetadata::kInitial:
|
@@ -701,13 +700,13 @@ void ClientCallData::RecvInitialMetadataReady(grpc_error_handle error) {
|
|
701
700
|
if (!GRPC_ERROR_IS_NONE(error)) {
|
702
701
|
recv_initial_metadata_->state = RecvInitialMetadata::kResponded;
|
703
702
|
flusher.AddClosure(
|
704
|
-
|
703
|
+
std::exchange(recv_initial_metadata_->original_on_ready, nullptr),
|
705
704
|
GRPC_ERROR_REF(error), "propagate cancellation");
|
706
705
|
} else if (send_initial_state_ == SendInitialState::kCancelled ||
|
707
706
|
recv_trailing_state_ == RecvTrailingState::kResponded) {
|
708
707
|
recv_initial_metadata_->state = RecvInitialMetadata::kResponded;
|
709
708
|
flusher.AddClosure(
|
710
|
-
|
709
|
+
std::exchange(recv_initial_metadata_->original_on_ready, nullptr),
|
711
710
|
GRPC_ERROR_REF(cancelled_error_), "propagate cancellation");
|
712
711
|
}
|
713
712
|
WakeInsideCombiner(&flusher);
|
@@ -827,7 +826,7 @@ void ClientCallData::RecvTrailingMetadataReady(grpc_error_handle error) {
|
|
827
826
|
// forward the callback up with the same error.
|
828
827
|
if (recv_trailing_state_ == RecvTrailingState::kCancelled) {
|
829
828
|
if (grpc_closure* call_closure =
|
830
|
-
|
829
|
+
std::exchange(original_recv_trailing_metadata_ready_, nullptr)) {
|
831
830
|
flusher.AddClosure(call_closure, GRPC_ERROR_REF(error),
|
832
831
|
"propagate failure");
|
833
832
|
}
|
@@ -1080,7 +1079,7 @@ void ServerCallData::Cancel(grpc_error_handle error, Flusher* flusher) {
|
|
1080
1079
|
send_initial_metadata_->state = SendInitialMetadata::kCancelled;
|
1081
1080
|
}
|
1082
1081
|
if (auto* closure =
|
1083
|
-
|
1082
|
+
std::exchange(original_recv_initial_metadata_ready_, nullptr)) {
|
1084
1083
|
flusher->AddClosure(closure, GRPC_ERROR_REF(error),
|
1085
1084
|
"original_recv_initial_metadata");
|
1086
1085
|
}
|
@@ -1158,7 +1157,7 @@ void ServerCallData::RecvInitialMetadataReady(grpc_error_handle error) {
|
|
1158
1157
|
if (!GRPC_ERROR_IS_NONE(error)) {
|
1159
1158
|
recv_initial_state_ = RecvInitialState::kResponded;
|
1160
1159
|
flusher.AddClosure(
|
1161
|
-
|
1160
|
+
std::exchange(original_recv_initial_metadata_ready_, nullptr),
|
1162
1161
|
GRPC_ERROR_REF(error), "propagate error");
|
1163
1162
|
return;
|
1164
1163
|
}
|
@@ -1178,7 +1177,7 @@ void ServerCallData::RecvInitialMetadataReady(grpc_error_handle error) {
|
|
1178
1177
|
// Poll once.
|
1179
1178
|
WakeInsideCombiner(&flusher);
|
1180
1179
|
if (auto* closure =
|
1181
|
-
|
1180
|
+
std::exchange(original_recv_initial_metadata_ready_, nullptr)) {
|
1182
1181
|
flusher.AddClosure(closure, GRPC_ERROR_NONE,
|
1183
1182
|
"original_recv_initial_metadata");
|
1184
1183
|
}
|
@@ -22,6 +22,8 @@
|
|
22
22
|
|
23
23
|
#include <string.h>
|
24
24
|
|
25
|
+
#include "absl/strings/str_cat.h"
|
26
|
+
|
25
27
|
#include "src/core/lib/gpr/useful.h"
|
26
28
|
|
27
29
|
struct status_string_entry {
|
@@ -109,3 +111,28 @@ bool grpc_status_code_from_int(int status_int, grpc_status_code* status) {
|
|
109
111
|
*status = static_cast<grpc_status_code>(status_int);
|
110
112
|
return true;
|
111
113
|
}
|
114
|
+
|
115
|
+
namespace grpc_core {
|
116
|
+
|
117
|
+
absl::Status MaybeRewriteIllegalStatusCode(absl::Status status,
|
118
|
+
absl::string_view source) {
|
119
|
+
switch (status.code()) {
|
120
|
+
// The set of disallowed codes, as per
|
121
|
+
// https://github.com/grpc/proposal/blob/master/A54-restrict-control-plane-status-codes.md.
|
122
|
+
case absl::StatusCode::kInvalidArgument:
|
123
|
+
case absl::StatusCode::kNotFound:
|
124
|
+
case absl::StatusCode::kAlreadyExists:
|
125
|
+
case absl::StatusCode::kFailedPrecondition:
|
126
|
+
case absl::StatusCode::kAborted:
|
127
|
+
case absl::StatusCode::kOutOfRange:
|
128
|
+
case absl::StatusCode::kDataLoss: {
|
129
|
+
return absl::InternalError(
|
130
|
+
absl::StrCat("Illegal status code from ", source,
|
131
|
+
"; original status: ", status.ToString()));
|
132
|
+
}
|
133
|
+
default:
|
134
|
+
return status;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
} // namespace grpc_core
|
@@ -21,6 +21,9 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
+
#include "absl/status/status.h"
|
25
|
+
#include "absl/strings/string_view.h"
|
26
|
+
|
24
27
|
#include <grpc/status.h>
|
25
28
|
|
26
29
|
/// If \a status_str is a valid status string, sets \a status to the
|
@@ -59,6 +62,13 @@ class StatusCodeSet {
|
|
59
62
|
};
|
60
63
|
|
61
64
|
} // namespace internal
|
65
|
+
|
66
|
+
// Optionally rewrites a status as per
|
67
|
+
// https://github.com/grpc/proposal/blob/master/A54-restrict-control-plane-status-codes.md.
|
68
|
+
// The source parameter indicates where the status came from.
|
69
|
+
absl::Status MaybeRewriteIllegalStatusCode(absl::Status status,
|
70
|
+
absl::string_view source);
|
71
|
+
|
62
72
|
} // namespace grpc_core
|
63
73
|
|
64
74
|
#endif /* GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H */
|
@@ -43,7 +43,11 @@ CoreConfiguration::CoreConfiguration(Builder* builder)
|
|
43
43
|
handshaker_registry_(builder->handshaker_registry_.Build()),
|
44
44
|
channel_creds_registry_(builder->channel_creds_registry_.Build()),
|
45
45
|
service_config_parser_(builder->service_config_parser_.Build()),
|
46
|
-
resolver_registry_(builder->resolver_registry_.Build())
|
46
|
+
resolver_registry_(builder->resolver_registry_.Build()),
|
47
|
+
lb_policy_registry_(builder->lb_policy_registry_.Build()),
|
48
|
+
proxy_mapper_registry_(builder->proxy_mapper_registry_.Build()),
|
49
|
+
certificate_provider_registry_(
|
50
|
+
builder->certificate_provider_registry_.Build()) {}
|
47
51
|
|
48
52
|
void CoreConfiguration::RegisterBuilder(std::function<void(Builder*)> builder) {
|
49
53
|
GPR_ASSERT(config_.load(std::memory_order_relaxed) == nullptr &&
|
@@ -23,7 +23,10 @@
|
|
23
23
|
#include <grpc/support/log.h>
|
24
24
|
|
25
25
|
#include "src/core/lib/channel/channel_args_preconditioning.h"
|
26
|
+
#include "src/core/lib/handshaker/proxy_mapper_registry.h"
|
27
|
+
#include "src/core/lib/load_balancing/lb_policy_registry.h"
|
26
28
|
#include "src/core/lib/resolver/resolver_registry.h"
|
29
|
+
#include "src/core/lib/security/certificate_provider/certificate_provider_registry.h"
|
27
30
|
#include "src/core/lib/security/credentials/channel_creds_registry.h"
|
28
31
|
#include "src/core/lib/service_config/service_config_parser.h"
|
29
32
|
#include "src/core/lib/surface/channel_init.h"
|
@@ -64,6 +67,18 @@ class CoreConfiguration {
|
|
64
67
|
return &resolver_registry_;
|
65
68
|
}
|
66
69
|
|
70
|
+
LoadBalancingPolicyRegistry::Builder* lb_policy_registry() {
|
71
|
+
return &lb_policy_registry_;
|
72
|
+
}
|
73
|
+
|
74
|
+
ProxyMapperRegistry::Builder* proxy_mapper_registry() {
|
75
|
+
return &proxy_mapper_registry_;
|
76
|
+
}
|
77
|
+
|
78
|
+
CertificateProviderRegistry::Builder* certificate_provider_registry() {
|
79
|
+
return &certificate_provider_registry_;
|
80
|
+
}
|
81
|
+
|
67
82
|
private:
|
68
83
|
friend class CoreConfiguration;
|
69
84
|
|
@@ -73,6 +88,9 @@ class CoreConfiguration {
|
|
73
88
|
ChannelCredsRegistry<>::Builder channel_creds_registry_;
|
74
89
|
ServiceConfigParser::Builder service_config_parser_;
|
75
90
|
ResolverRegistry::Builder resolver_registry_;
|
91
|
+
LoadBalancingPolicyRegistry::Builder lb_policy_registry_;
|
92
|
+
ProxyMapperRegistry::Builder proxy_mapper_registry_;
|
93
|
+
CertificateProviderRegistry::Builder certificate_provider_registry_;
|
76
94
|
|
77
95
|
Builder();
|
78
96
|
CoreConfiguration* Build();
|
@@ -177,6 +195,18 @@ class CoreConfiguration {
|
|
177
195
|
return resolver_registry_;
|
178
196
|
}
|
179
197
|
|
198
|
+
const LoadBalancingPolicyRegistry& lb_policy_registry() const {
|
199
|
+
return lb_policy_registry_;
|
200
|
+
}
|
201
|
+
|
202
|
+
const ProxyMapperRegistry& proxy_mapper_registry() const {
|
203
|
+
return proxy_mapper_registry_;
|
204
|
+
}
|
205
|
+
|
206
|
+
const CertificateProviderRegistry& certificate_provider_registry() const {
|
207
|
+
return certificate_provider_registry_;
|
208
|
+
}
|
209
|
+
|
180
210
|
static void SetDefaultBuilder(void (*builder)(CoreConfiguration::Builder*)) {
|
181
211
|
default_builder_ = builder;
|
182
212
|
}
|
@@ -201,6 +231,9 @@ class CoreConfiguration {
|
|
201
231
|
ChannelCredsRegistry<> channel_creds_registry_;
|
202
232
|
ServiceConfigParser service_config_parser_;
|
203
233
|
ResolverRegistry resolver_registry_;
|
234
|
+
LoadBalancingPolicyRegistry lb_policy_registry_;
|
235
|
+
ProxyMapperRegistry proxy_mapper_registry_;
|
236
|
+
CertificateProviderRegistry certificate_provider_registry_;
|
204
237
|
};
|
205
238
|
|
206
239
|
extern void BuildCoreConfiguration(CoreConfiguration::Builder* builder);
|
data/src/core/lib/debug/stats.cc
CHANGED
@@ -26,6 +26,7 @@
|
|
26
26
|
#include <algorithm>
|
27
27
|
#include <vector>
|
28
28
|
|
29
|
+
#include "absl/strings/str_cat.h"
|
29
30
|
#include "absl/strings/str_format.h"
|
30
31
|
#include "absl/strings/str_join.h"
|
31
32
|
|
@@ -66,21 +67,12 @@ void grpc_stats_diff(const grpc_stats_data* b, const grpc_stats_data* a,
|
|
66
67
|
}
|
67
68
|
}
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
const int* it = table + step;
|
76
|
-
if (value >= *it) {
|
77
|
-
table = it + 1;
|
78
|
-
table_size -= step + 1;
|
79
|
-
} else {
|
80
|
-
table_size = step;
|
81
|
-
}
|
82
|
-
}
|
83
|
-
return static_cast<int>(table - start) - 1;
|
70
|
+
void grpc_stats_inc_histogram_value(int histogram, int value) {
|
71
|
+
const int bucket = grpc_stats_get_bucket[histogram](value);
|
72
|
+
gpr_atm_no_barrier_fetch_add(
|
73
|
+
&GRPC_THREAD_STATS_DATA()
|
74
|
+
->histograms[grpc_stats_histo_start[histogram] + bucket],
|
75
|
+
1);
|
84
76
|
}
|
85
77
|
|
86
78
|
size_t grpc_stats_histo_count(const grpc_stats_data* stats,
|
@@ -142,28 +134,32 @@ double grpc_stats_histo_percentile(const grpc_stats_data* stats,
|
|
142
134
|
static_cast<double>(count) * percentile / 100.0);
|
143
135
|
}
|
144
136
|
|
137
|
+
namespace {
|
138
|
+
template <typename I>
|
139
|
+
std::string ArrayToJson(const I* values, size_t count) {
|
140
|
+
std::vector<std::string> parts;
|
141
|
+
for (size_t i = 0; i < count; i++) {
|
142
|
+
parts.push_back(absl::StrFormat("%d", values[i]));
|
143
|
+
}
|
144
|
+
return absl::StrCat("[", absl::StrJoin(parts, ","), "]");
|
145
|
+
}
|
146
|
+
} // namespace
|
147
|
+
|
145
148
|
std::string grpc_stats_data_as_json(const grpc_stats_data* data) {
|
146
149
|
std::vector<std::string> parts;
|
147
|
-
parts.push_back("{");
|
148
150
|
for (size_t i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
|
149
151
|
parts.push_back(absl::StrFormat(
|
150
152
|
"\"%s\": %" PRIdPTR, grpc_stats_counter_name[i], data->counters[i]));
|
151
153
|
}
|
152
154
|
for (size_t i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
|
153
|
-
parts.push_back(absl::StrFormat(
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
data->histograms[grpc_stats_histo_start[i] + j]));
|
158
|
-
}
|
155
|
+
parts.push_back(absl::StrFormat(
|
156
|
+
"\"%s\": %s", grpc_stats_histogram_name[i],
|
157
|
+
ArrayToJson(data->histograms + grpc_stats_histo_start[i],
|
158
|
+
grpc_stats_histo_buckets[i])));
|
159
159
|
parts.push_back(
|
160
|
-
absl::StrFormat("
|
161
|
-
|
162
|
-
|
163
|
-
"%s%d", j == 0 ? "" : ",", grpc_stats_histo_bucket_boundaries[i][j]));
|
164
|
-
}
|
165
|
-
parts.push_back("]");
|
160
|
+
absl::StrFormat("\"%s_bkt\": %s", grpc_stats_histogram_name[i],
|
161
|
+
ArrayToJson(grpc_stats_histo_bucket_boundaries[i],
|
162
|
+
grpc_stats_histo_buckets[i])));
|
166
163
|
}
|
167
|
-
|
168
|
-
return absl::StrJoin(parts, "");
|
164
|
+
return absl::StrCat("{", absl::StrJoin(parts, ", "), "}");
|
169
165
|
}
|
data/src/core/lib/debug/stats.h
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
#include <grpc/support/atm.h>
|
29
29
|
|
30
|
-
#include "src/core/lib/debug/stats_data.h"
|
30
|
+
#include "src/core/lib/debug/stats_data.h" // IWYU pragma: export
|
31
31
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
32
32
|
|
33
33
|
typedef struct grpc_stats_data {
|
@@ -47,9 +47,6 @@ extern Stats* const g_stats_data;
|
|
47
47
|
(&::grpc_core::g_stats_data \
|
48
48
|
->per_cpu[grpc_core::ExecCtx::Get()->starting_cpu()])
|
49
49
|
|
50
|
-
/* Only collect stats if GRPC_COLLECT_STATS is defined or it is a debug build.
|
51
|
-
*/
|
52
|
-
#if defined(GRPC_COLLECT_STATS) || !defined(NDEBUG)
|
53
50
|
#define GRPC_STATS_INC_COUNTER(ctr) \
|
54
51
|
(gpr_atm_no_barrier_fetch_add(&GRPC_THREAD_STATS_DATA()->counters[(ctr)], 1))
|
55
52
|
|
@@ -57,24 +54,17 @@ extern Stats* const g_stats_data;
|
|
57
54
|
(gpr_atm_no_barrier_fetch_add( \
|
58
55
|
&GRPC_THREAD_STATS_DATA()->histograms[histogram##_FIRST_SLOT + (index)], \
|
59
56
|
1))
|
60
|
-
#else /* defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) */
|
61
|
-
#define GRPC_STATS_INC_COUNTER(ctr)
|
62
|
-
#define GRPC_STATS_INC_HISTOGRAM(histogram, index)
|
63
|
-
#endif /* defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) */
|
64
57
|
|
65
|
-
GRPC_DEPRECATED("function is no longer needed")
|
66
|
-
inline void grpc_stats_init(void) {}
|
67
58
|
void grpc_stats_collect(grpc_stats_data* output);
|
68
59
|
// c = b-a
|
69
60
|
void grpc_stats_diff(const grpc_stats_data* b, const grpc_stats_data* a,
|
70
61
|
grpc_stats_data* c);
|
71
62
|
std::string grpc_stats_data_as_json(const grpc_stats_data* data);
|
72
|
-
int grpc_stats_histo_find_bucket_slow(int value, const int* table,
|
73
|
-
int table_size);
|
74
63
|
double grpc_stats_histo_percentile(const grpc_stats_data* stats,
|
75
64
|
grpc_stats_histograms histogram,
|
76
65
|
double percentile);
|
77
66
|
size_t grpc_stats_histo_count(const grpc_stats_data* stats,
|
78
67
|
grpc_stats_histograms histogram);
|
68
|
+
void grpc_stats_inc_histogram_value(int histogram, int value);
|
79
69
|
|
80
70
|
#endif // GRPC_CORE_LIB_DEBUG_STATS_H
|