grpc 1.49.1-x86_64-linux → 1.50.0-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 +31 -17
- 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
@@ -37,6 +37,7 @@
|
|
37
37
|
|
38
38
|
#include "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h"
|
39
39
|
#include "src/core/lib/channel/channel_args.h"
|
40
|
+
#include "src/core/lib/config/core_configuration.h"
|
40
41
|
#include "src/core/lib/debug/trace.h"
|
41
42
|
#include "src/core/lib/gprpp/debug_location.h"
|
42
43
|
#include "src/core/lib/gprpp/orphanable.h"
|
@@ -67,7 +68,7 @@ class RoundRobin : public LoadBalancingPolicy {
|
|
67
68
|
|
68
69
|
absl::string_view name() const override { return kRoundRobin; }
|
69
70
|
|
70
|
-
|
71
|
+
absl::Status UpdateLocked(UpdateArgs args) override;
|
71
72
|
void ResetBackoffLocked() override;
|
72
73
|
|
73
74
|
private:
|
@@ -182,12 +183,12 @@ class RoundRobin : public LoadBalancingPolicy {
|
|
182
183
|
void ShutdownLocked() override;
|
183
184
|
|
184
185
|
// List of subchannels.
|
185
|
-
|
186
|
+
RefCountedPtr<RoundRobinSubchannelList> subchannel_list_;
|
186
187
|
// Latest pending subchannel list.
|
187
188
|
// When we get an updated address list, we create a new subchannel list
|
188
189
|
// for it here, and we wait to swap it into subchannel_list_ until the new
|
189
190
|
// list becomes READY.
|
190
|
-
|
191
|
+
RefCountedPtr<RoundRobinSubchannelList> latest_pending_subchannel_list_;
|
191
192
|
|
192
193
|
bool shutdown_ = false;
|
193
194
|
};
|
@@ -265,7 +266,7 @@ void RoundRobin::ResetBackoffLocked() {
|
|
265
266
|
}
|
266
267
|
}
|
267
268
|
|
268
|
-
|
269
|
+
absl::Status RoundRobin::UpdateLocked(UpdateArgs args) {
|
269
270
|
ServerAddressList addresses;
|
270
271
|
if (args.addresses.ok()) {
|
271
272
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) {
|
@@ -278,9 +279,9 @@ void RoundRobin::UpdateLocked(UpdateArgs args) {
|
|
278
279
|
gpr_log(GPR_INFO, "[RR %p] received update with address error: %s", this,
|
279
280
|
args.addresses.status().ToString().c_str());
|
280
281
|
}
|
281
|
-
// If we already have a subchannel list, then
|
282
|
-
//
|
283
|
-
if (subchannel_list_ != nullptr) return;
|
282
|
+
// If we already have a subchannel list, then keep using the existing
|
283
|
+
// list, but still report back that the update was not accepted.
|
284
|
+
if (subchannel_list_ != nullptr) return args.addresses.status();
|
284
285
|
}
|
285
286
|
// Create new subchannel list, replacing the previous pending list, if any.
|
286
287
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace) &&
|
@@ -288,7 +289,7 @@ void RoundRobin::UpdateLocked(UpdateArgs args) {
|
|
288
289
|
gpr_log(GPR_INFO, "[RR %p] replacing previous pending subchannel list %p",
|
289
290
|
this, latest_pending_subchannel_list_.get());
|
290
291
|
}
|
291
|
-
latest_pending_subchannel_list_ =
|
292
|
+
latest_pending_subchannel_list_ = MakeRefCounted<RoundRobinSubchannelList>(
|
292
293
|
this, std::move(addresses), args.args);
|
293
294
|
latest_pending_subchannel_list_->StartWatchingLocked();
|
294
295
|
// If the new list is empty, immediately promote it to
|
@@ -307,15 +308,17 @@ void RoundRobin::UpdateLocked(UpdateArgs args) {
|
|
307
308
|
channel_control_helper()->UpdateState(
|
308
309
|
GRPC_CHANNEL_TRANSIENT_FAILURE, status,
|
309
310
|
absl::make_unique<TransientFailurePicker>(status));
|
311
|
+
return status;
|
310
312
|
}
|
311
313
|
// Otherwise, if this is the initial update, immediately promote it to
|
312
314
|
// subchannel_list_ and report CONNECTING.
|
313
|
-
|
315
|
+
if (subchannel_list_.get() == nullptr) {
|
314
316
|
subchannel_list_ = std::move(latest_pending_subchannel_list_);
|
315
317
|
channel_control_helper()->UpdateState(
|
316
318
|
GRPC_CHANNEL_CONNECTING, absl::Status(),
|
317
319
|
absl::make_unique<QueuePicker>(Ref(DEBUG_LOCATION, "QueuePicker")));
|
318
320
|
}
|
321
|
+
return absl::OkStatus();
|
319
322
|
}
|
320
323
|
|
321
324
|
//
|
@@ -520,12 +523,9 @@ class RoundRobinFactory : public LoadBalancingPolicyFactory {
|
|
520
523
|
|
521
524
|
} // namespace
|
522
525
|
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
grpc_core::LoadBalancingPolicyRegistry::Builder::
|
527
|
-
RegisterLoadBalancingPolicyFactory(
|
528
|
-
absl::make_unique<grpc_core::RoundRobinFactory>());
|
526
|
+
void RegisterRoundRobinLbPolicy(CoreConfiguration::Builder* builder) {
|
527
|
+
builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
|
528
|
+
absl::make_unique<RoundRobinFactory>());
|
529
529
|
}
|
530
530
|
|
531
|
-
|
531
|
+
} // namespace grpc_core
|
@@ -35,8 +35,8 @@
|
|
35
35
|
|
36
36
|
#include "src/core/lib/channel/channel_args.h"
|
37
37
|
#include "src/core/lib/gprpp/debug_location.h"
|
38
|
+
#include "src/core/lib/gprpp/dual_ref_counted.h"
|
38
39
|
#include "src/core/lib/gprpp/manual_constructor.h"
|
39
|
-
#include "src/core/lib/gprpp/orphanable.h"
|
40
40
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
41
41
|
#include "src/core/lib/iomgr/iomgr_fwd.h"
|
42
42
|
#include "src/core/lib/load_balancing/lb_policy.h"
|
@@ -131,7 +131,7 @@ class SubchannelData {
|
|
131
131
|
public:
|
132
132
|
Watcher(
|
133
133
|
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data,
|
134
|
-
|
134
|
+
WeakRefCountedPtr<SubchannelListType> subchannel_list)
|
135
135
|
: subchannel_data_(subchannel_data),
|
136
136
|
subchannel_list_(std::move(subchannel_list)) {}
|
137
137
|
|
@@ -148,7 +148,7 @@ class SubchannelData {
|
|
148
148
|
|
149
149
|
private:
|
150
150
|
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data_;
|
151
|
-
|
151
|
+
WeakRefCountedPtr<SubchannelListType> subchannel_list_;
|
152
152
|
};
|
153
153
|
|
154
154
|
// Starts watching the connectivity state of the subchannel.
|
@@ -176,7 +176,7 @@ class SubchannelData {
|
|
176
176
|
|
177
177
|
// A list of subchannels.
|
178
178
|
template <typename SubchannelListType, typename SubchannelDataType>
|
179
|
-
class SubchannelList : public
|
179
|
+
class SubchannelList : public DualRefCounted<SubchannelListType> {
|
180
180
|
public:
|
181
181
|
// Starts watching the connectivity state of all subchannels.
|
182
182
|
// Must be called immediately after instantiation.
|
@@ -200,10 +200,7 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|
200
200
|
// Resets connection backoff of all subchannels.
|
201
201
|
void ResetBackoffLocked();
|
202
202
|
|
203
|
-
void Orphan() override
|
204
|
-
ShutdownLocked();
|
205
|
-
InternallyRefCounted<SubchannelListType>::Unref(DEBUG_LOCATION, "shutdown");
|
206
|
-
}
|
203
|
+
void Orphan() override;
|
207
204
|
|
208
205
|
protected:
|
209
206
|
SubchannelList(LoadBalancingPolicy* policy, const char* tracer,
|
@@ -213,8 +210,6 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|
213
210
|
|
214
211
|
virtual ~SubchannelList();
|
215
212
|
|
216
|
-
virtual void ShutdownLocked();
|
217
|
-
|
218
213
|
private:
|
219
214
|
// For accessing Ref() and Unref().
|
220
215
|
friend class SubchannelData<SubchannelListType, SubchannelDataType>;
|
@@ -327,7 +322,7 @@ void SubchannelData<SubchannelListType,
|
|
327
322
|
}
|
328
323
|
GPR_ASSERT(pending_watcher_ == nullptr);
|
329
324
|
pending_watcher_ =
|
330
|
-
new Watcher(this, subchannel_list()->
|
325
|
+
new Watcher(this, subchannel_list()->WeakRef(DEBUG_LOCATION, "Watcher"));
|
331
326
|
subchannel_->WatchConnectivityState(
|
332
327
|
std::unique_ptr<SubchannelInterface::ConnectivityStateWatcherInterface>(
|
333
328
|
pending_watcher_));
|
@@ -365,7 +360,7 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
|
365
360
|
LoadBalancingPolicy* policy, const char* tracer,
|
366
361
|
ServerAddressList addresses,
|
367
362
|
LoadBalancingPolicy::ChannelControlHelper* helper, const ChannelArgs& args)
|
368
|
-
:
|
363
|
+
: DualRefCounted<SubchannelListType>(tracer),
|
369
364
|
policy_(policy),
|
370
365
|
tracer_(tracer) {
|
371
366
|
if (GPR_UNLIKELY(tracer_ != nullptr)) {
|
@@ -419,7 +414,7 @@ void SubchannelList<SubchannelListType,
|
|
419
414
|
}
|
420
415
|
|
421
416
|
template <typename SubchannelListType, typename SubchannelDataType>
|
422
|
-
void SubchannelList<SubchannelListType, SubchannelDataType>::
|
417
|
+
void SubchannelList<SubchannelListType, SubchannelDataType>::Orphan() {
|
423
418
|
if (GPR_UNLIKELY(tracer_ != nullptr)) {
|
424
419
|
gpr_log(GPR_INFO, "[%s %p] Shutting down subchannel_list %p", tracer_,
|
425
420
|
policy_, this);
|
@@ -41,18 +41,21 @@
|
|
41
41
|
#include "src/core/ext/filters/client_channel/lb_policy/address_filtering.h"
|
42
42
|
#include "src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h"
|
43
43
|
#include "src/core/lib/channel/channel_args.h"
|
44
|
+
#include "src/core/lib/config/core_configuration.h"
|
44
45
|
#include "src/core/lib/debug/trace.h"
|
45
46
|
#include "src/core/lib/event_engine/default_event_engine.h"
|
46
|
-
#include "src/core/lib/gpr/string.h"
|
47
47
|
#include "src/core/lib/gprpp/debug_location.h"
|
48
48
|
#include "src/core/lib/gprpp/orphanable.h"
|
49
49
|
#include "src/core/lib/gprpp/ref_counted.h"
|
50
50
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
51
51
|
#include "src/core/lib/gprpp/time.h"
|
52
|
+
#include "src/core/lib/gprpp/validation_errors.h"
|
52
53
|
#include "src/core/lib/gprpp/work_serializer.h"
|
53
54
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
54
55
|
#include "src/core/lib/iomgr/pollset_set.h"
|
55
56
|
#include "src/core/lib/json/json.h"
|
57
|
+
#include "src/core/lib/json/json_args.h"
|
58
|
+
#include "src/core/lib/json/json_object_loader.h"
|
56
59
|
#include "src/core/lib/load_balancing/lb_policy.h"
|
57
60
|
#include "src/core/lib/load_balancing/lb_policy_factory.h"
|
58
61
|
#include "src/core/lib/load_balancing/lb_policy_registry.h"
|
@@ -83,17 +86,28 @@ class WeightedTargetLbConfig : public LoadBalancingPolicy::Config {
|
|
83
86
|
struct ChildConfig {
|
84
87
|
uint32_t weight;
|
85
88
|
RefCountedPtr<LoadBalancingPolicy::Config> config;
|
89
|
+
|
90
|
+
static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
|
91
|
+
void JsonPostLoad(const Json& json, const JsonArgs&,
|
92
|
+
ValidationErrors* errors);
|
86
93
|
};
|
87
94
|
|
88
95
|
using TargetMap = std::map<std::string, ChildConfig>;
|
89
96
|
|
90
|
-
|
91
|
-
|
97
|
+
WeightedTargetLbConfig() = default;
|
98
|
+
|
99
|
+
WeightedTargetLbConfig(const WeightedTargetLbConfig&) = delete;
|
100
|
+
WeightedTargetLbConfig& operator=(const WeightedTargetLbConfig&) = delete;
|
101
|
+
|
102
|
+
WeightedTargetLbConfig(WeightedTargetLbConfig&& other) = delete;
|
103
|
+
WeightedTargetLbConfig& operator=(WeightedTargetLbConfig&& other) = delete;
|
92
104
|
|
93
105
|
absl::string_view name() const override { return kWeightedTarget; }
|
94
106
|
|
95
107
|
const TargetMap& target_map() const { return target_map_; }
|
96
108
|
|
109
|
+
static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
|
110
|
+
|
97
111
|
private:
|
98
112
|
TargetMap target_map_;
|
99
113
|
};
|
@@ -105,7 +119,7 @@ class WeightedTargetLb : public LoadBalancingPolicy {
|
|
105
119
|
|
106
120
|
absl::string_view name() const override { return kWeightedTarget; }
|
107
121
|
|
108
|
-
|
122
|
+
absl::Status UpdateLocked(UpdateArgs args) override;
|
109
123
|
void ResetBackoffLocked() override;
|
110
124
|
|
111
125
|
private:
|
@@ -149,10 +163,10 @@ class WeightedTargetLb : public LoadBalancingPolicy {
|
|
149
163
|
|
150
164
|
void Orphan() override;
|
151
165
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
166
|
+
absl::Status UpdateLocked(const WeightedTargetLbConfig::ChildConfig& config,
|
167
|
+
absl::StatusOr<ServerAddressList> addresses,
|
168
|
+
const std::string& resolution_note,
|
169
|
+
const ChannelArgs& args);
|
156
170
|
void ResetBackoffLocked();
|
157
171
|
void DeactivateLocked();
|
158
172
|
|
@@ -301,8 +315,8 @@ void WeightedTargetLb::ResetBackoffLocked() {
|
|
301
315
|
for (auto& p : targets_) p.second->ResetBackoffLocked();
|
302
316
|
}
|
303
317
|
|
304
|
-
|
305
|
-
if (shutting_down_) return;
|
318
|
+
absl::Status WeightedTargetLb::UpdateLocked(UpdateArgs args) {
|
319
|
+
if (shutting_down_) return absl::OkStatus();
|
306
320
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_weighted_target_trace)) {
|
307
321
|
gpr_log(GPR_INFO, "[weighted_target_lb %p] Received update", this);
|
308
322
|
}
|
@@ -320,6 +334,7 @@ void WeightedTargetLb::UpdateLocked(UpdateArgs args) {
|
|
320
334
|
// Update all children.
|
321
335
|
absl::StatusOr<HierarchicalAddressMap> address_map =
|
322
336
|
MakeHierarchicalAddressMap(args.addresses);
|
337
|
+
std::vector<std::string> errors;
|
323
338
|
for (const auto& p : config_->target_map()) {
|
324
339
|
const std::string& name = p.first;
|
325
340
|
const WeightedTargetLbConfig::ChildConfig& config = p.second;
|
@@ -335,8 +350,12 @@ void WeightedTargetLb::UpdateLocked(UpdateArgs args) {
|
|
335
350
|
} else {
|
336
351
|
addresses = address_map.status();
|
337
352
|
}
|
338
|
-
target->UpdateLocked(config, std::move(addresses),
|
339
|
-
|
353
|
+
absl::Status status = target->UpdateLocked(config, std::move(addresses),
|
354
|
+
args.resolution_note, args.args);
|
355
|
+
if (!status.ok()) {
|
356
|
+
errors.emplace_back(
|
357
|
+
absl::StrCat("child ", name, ": ", status.ToString()));
|
358
|
+
}
|
340
359
|
}
|
341
360
|
update_in_progress_ = false;
|
342
361
|
if (config_->target_map().empty()) {
|
@@ -345,9 +364,15 @@ void WeightedTargetLb::UpdateLocked(UpdateArgs args) {
|
|
345
364
|
channel_control_helper()->UpdateState(
|
346
365
|
GRPC_CHANNEL_TRANSIENT_FAILURE, status,
|
347
366
|
absl::make_unique<TransientFailurePicker>(status));
|
348
|
-
return;
|
367
|
+
return absl::OkStatus();
|
349
368
|
}
|
350
369
|
UpdateStateLocked();
|
370
|
+
// Return status.
|
371
|
+
if (!errors.empty()) {
|
372
|
+
return absl::UnavailableError(absl::StrCat(
|
373
|
+
"errors from children: [", absl::StrJoin(errors, "; "), "]"));
|
374
|
+
}
|
375
|
+
return absl::OkStatus();
|
351
376
|
}
|
352
377
|
|
353
378
|
void WeightedTargetLb::UpdateStateLocked() {
|
@@ -555,11 +580,11 @@ WeightedTargetLb::WeightedChild::CreateChildPolicyLocked(
|
|
555
580
|
return lb_policy;
|
556
581
|
}
|
557
582
|
|
558
|
-
|
583
|
+
absl::Status WeightedTargetLb::WeightedChild::UpdateLocked(
|
559
584
|
const WeightedTargetLbConfig::ChildConfig& config,
|
560
585
|
absl::StatusOr<ServerAddressList> addresses,
|
561
586
|
const std::string& resolution_note, const ChannelArgs& args) {
|
562
|
-
if (weighted_target_policy_->shutting_down_) return;
|
587
|
+
if (weighted_target_policy_->shutting_down_) return absl::OkStatus();
|
563
588
|
// Update child weight.
|
564
589
|
weight_ = config.weight;
|
565
590
|
// Reactivate if needed.
|
@@ -589,7 +614,7 @@ void WeightedTargetLb::WeightedChild::UpdateLocked(
|
|
589
614
|
weighted_target_policy_.get(), this, name_.c_str(),
|
590
615
|
child_policy_.get());
|
591
616
|
}
|
592
|
-
child_policy_->UpdateLocked(std::move(update_args));
|
617
|
+
return child_policy_->UpdateLocked(std::move(update_args));
|
593
618
|
}
|
594
619
|
|
595
620
|
void WeightedTargetLb::WeightedChild::ResetBackoffLocked() {
|
@@ -679,6 +704,43 @@ void WeightedTargetLb::WeightedChild::Helper::AddTraceEvent(
|
|
679
704
|
// factory
|
680
705
|
//
|
681
706
|
|
707
|
+
const JsonLoaderInterface* WeightedTargetLbConfig::ChildConfig::JsonLoader(
|
708
|
+
const JsonArgs&) {
|
709
|
+
static const auto* loader =
|
710
|
+
JsonObjectLoader<ChildConfig>()
|
711
|
+
// Note: The config field requires custom parsing, so it's
|
712
|
+
// handled in JsonPostLoad() instead.
|
713
|
+
.Field("weight", &ChildConfig::weight)
|
714
|
+
.Finish();
|
715
|
+
return loader;
|
716
|
+
}
|
717
|
+
|
718
|
+
void WeightedTargetLbConfig::ChildConfig::JsonPostLoad(
|
719
|
+
const Json& json, const JsonArgs&, ValidationErrors* errors) {
|
720
|
+
ValidationErrors::ScopedField field(errors, ".childPolicy");
|
721
|
+
auto it = json.object_value().find("childPolicy");
|
722
|
+
if (it == json.object_value().end()) {
|
723
|
+
errors->AddError("field not present");
|
724
|
+
return;
|
725
|
+
}
|
726
|
+
auto lb_config =
|
727
|
+
CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig(
|
728
|
+
it->second);
|
729
|
+
if (!lb_config.ok()) {
|
730
|
+
errors->AddError(lb_config.status().message());
|
731
|
+
return;
|
732
|
+
}
|
733
|
+
config = std::move(*lb_config);
|
734
|
+
}
|
735
|
+
|
736
|
+
const JsonLoaderInterface* WeightedTargetLbConfig::JsonLoader(const JsonArgs&) {
|
737
|
+
static const auto* loader =
|
738
|
+
JsonObjectLoader<WeightedTargetLbConfig>()
|
739
|
+
.Field("targets", &WeightedTargetLbConfig::target_map_)
|
740
|
+
.Finish();
|
741
|
+
return loader;
|
742
|
+
}
|
743
|
+
|
682
744
|
class WeightedTargetLbFactory : public LoadBalancingPolicyFactory {
|
683
745
|
public:
|
684
746
|
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
|
@@ -698,90 +760,16 @@ class WeightedTargetLbFactory : public LoadBalancingPolicyFactory {
|
|
698
760
|
"configuration. Please use loadBalancingConfig field of service "
|
699
761
|
"config instead.");
|
700
762
|
}
|
701
|
-
|
702
|
-
|
703
|
-
WeightedTargetLbConfig::TargetMap target_map;
|
704
|
-
auto it = json.object_value().find("targets");
|
705
|
-
if (it == json.object_value().end()) {
|
706
|
-
errors.emplace_back("field:targets error:required field not present");
|
707
|
-
} else if (it->second.type() != Json::Type::OBJECT) {
|
708
|
-
errors.emplace_back("field:targets error:type should be object");
|
709
|
-
} else {
|
710
|
-
for (const auto& p : it->second.object_value()) {
|
711
|
-
auto config = ParseChildConfig(p.second);
|
712
|
-
if (!config.ok()) {
|
713
|
-
errors.emplace_back(config.status().message());
|
714
|
-
} else {
|
715
|
-
target_map[p.first] = std::move(*config);
|
716
|
-
}
|
717
|
-
}
|
718
|
-
}
|
719
|
-
if (!errors.empty()) {
|
720
|
-
return absl::InvalidArgumentError(
|
721
|
-
absl::StrCat("weighted_target_experimental LB policy config: [",
|
722
|
-
absl::StrJoin(errors, "; "), "]"));
|
723
|
-
}
|
724
|
-
return MakeRefCounted<WeightedTargetLbConfig>(std::move(target_map));
|
725
|
-
}
|
726
|
-
|
727
|
-
private:
|
728
|
-
static absl::StatusOr<WeightedTargetLbConfig::ChildConfig> ParseChildConfig(
|
729
|
-
const Json& json) {
|
730
|
-
if (json.type() != Json::Type::OBJECT) {
|
731
|
-
return absl::InvalidArgumentError("value should be of type object");
|
732
|
-
}
|
733
|
-
WeightedTargetLbConfig::ChildConfig child_config;
|
734
|
-
std::vector<std::string> errors;
|
735
|
-
// Weight.
|
736
|
-
auto it = json.object_value().find("weight");
|
737
|
-
if (it == json.object_value().end()) {
|
738
|
-
errors.emplace_back("required field \"weight\" not specified");
|
739
|
-
} else if (it->second.type() != Json::Type::NUMBER) {
|
740
|
-
errors.emplace_back("field:weight error:must be of type number");
|
741
|
-
} else {
|
742
|
-
int weight = gpr_parse_nonnegative_int(it->second.string_value().c_str());
|
743
|
-
if (weight == -1) {
|
744
|
-
errors.emplace_back("field:weight error:unparseable value");
|
745
|
-
} else if (weight == 0) {
|
746
|
-
errors.emplace_back(
|
747
|
-
"field:weight error:value must be greater than zero");
|
748
|
-
} else {
|
749
|
-
child_config.weight = weight;
|
750
|
-
}
|
751
|
-
}
|
752
|
-
// Child policy.
|
753
|
-
it = json.object_value().find("childPolicy");
|
754
|
-
if (it != json.object_value().end()) {
|
755
|
-
auto config =
|
756
|
-
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(it->second);
|
757
|
-
if (!config.ok()) {
|
758
|
-
errors.emplace_back(
|
759
|
-
absl::StrCat("field:childPolicy: ", config.status().message()));
|
760
|
-
} else {
|
761
|
-
child_config.config = std::move(*config);
|
762
|
-
}
|
763
|
-
}
|
764
|
-
// Return result.
|
765
|
-
if (!errors.empty()) {
|
766
|
-
return absl::InvalidArgumentError(absl::StrCat(
|
767
|
-
"errors parsing target config: [", absl::StrJoin(errors, "; "), "]"));
|
768
|
-
}
|
769
|
-
return child_config;
|
763
|
+
return LoadRefCountedFromJson<WeightedTargetLbConfig>(
|
764
|
+
json, JsonArgs(), "errors validating weighted_target LB policy config");
|
770
765
|
}
|
771
766
|
};
|
772
767
|
|
773
768
|
} // namespace
|
774
769
|
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
// Plugin registration
|
779
|
-
//
|
780
|
-
|
781
|
-
void grpc_lb_policy_weighted_target_init() {
|
782
|
-
grpc_core::LoadBalancingPolicyRegistry::Builder::
|
783
|
-
RegisterLoadBalancingPolicyFactory(
|
784
|
-
absl::make_unique<grpc_core::WeightedTargetLbFactory>());
|
770
|
+
void RegisterWeightedTargetLbPolicy(CoreConfiguration::Builder* builder) {
|
771
|
+
builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
|
772
|
+
absl::make_unique<WeightedTargetLbFactory>());
|
785
773
|
}
|
786
774
|
|
787
|
-
|
775
|
+
} // namespace grpc_core
|
@@ -28,7 +28,6 @@
|
|
28
28
|
#include "absl/status/status.h"
|
29
29
|
#include "absl/status/statusor.h"
|
30
30
|
#include "absl/strings/str_cat.h"
|
31
|
-
#include "absl/strings/str_join.h"
|
32
31
|
#include "absl/strings/string_view.h"
|
33
32
|
#include "absl/types/optional.h"
|
34
33
|
|
@@ -39,7 +38,7 @@
|
|
39
38
|
|
40
39
|
#include "src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h"
|
41
40
|
#include "src/core/ext/xds/certificate_provider_store.h"
|
42
|
-
#include "src/core/ext/xds/
|
41
|
+
#include "src/core/ext/xds/xds_bootstrap_grpc.h"
|
43
42
|
#include "src/core/ext/xds/xds_certificate_provider.h"
|
44
43
|
#include "src/core/ext/xds/xds_client.h"
|
45
44
|
#include "src/core/ext/xds/xds_client_grpc.h"
|
@@ -47,6 +46,7 @@
|
|
47
46
|
#include "src/core/ext/xds/xds_common_types.h"
|
48
47
|
#include "src/core/ext/xds/xds_resource_type_impl.h"
|
49
48
|
#include "src/core/lib/channel/channel_args.h"
|
49
|
+
#include "src/core/lib/config/core_configuration.h"
|
50
50
|
#include "src/core/lib/debug/trace.h"
|
51
51
|
#include "src/core/lib/gprpp/debug_location.h"
|
52
52
|
#include "src/core/lib/gprpp/orphanable.h"
|
@@ -57,6 +57,8 @@
|
|
57
57
|
#include "src/core/lib/iomgr/error.h"
|
58
58
|
#include "src/core/lib/iomgr/pollset_set.h"
|
59
59
|
#include "src/core/lib/json/json.h"
|
60
|
+
#include "src/core/lib/json/json_args.h"
|
61
|
+
#include "src/core/lib/json/json_object_loader.h"
|
60
62
|
#include "src/core/lib/load_balancing/lb_policy.h"
|
61
63
|
#include "src/core/lib/load_balancing/lb_policy_factory.h"
|
62
64
|
#include "src/core/lib/load_balancing/lb_policy_registry.h"
|
@@ -82,10 +84,24 @@ constexpr int kMaxAggregateClusterRecursionDepth = 16;
|
|
82
84
|
// Config for this LB policy.
|
83
85
|
class CdsLbConfig : public LoadBalancingPolicy::Config {
|
84
86
|
public:
|
85
|
-
|
87
|
+
CdsLbConfig() = default;
|
88
|
+
|
89
|
+
CdsLbConfig(const CdsLbConfig&) = delete;
|
90
|
+
CdsLbConfig& operator=(const CdsLbConfig&) = delete;
|
91
|
+
|
92
|
+
CdsLbConfig(CdsLbConfig&& other) = delete;
|
93
|
+
CdsLbConfig& operator=(CdsLbConfig&& other) = delete;
|
94
|
+
|
86
95
|
const std::string& cluster() const { return cluster_; }
|
87
96
|
absl::string_view name() const override { return kCds; }
|
88
97
|
|
98
|
+
static const JsonLoaderInterface* JsonLoader(const JsonArgs&) {
|
99
|
+
static const auto* loader = JsonObjectLoader<CdsLbConfig>()
|
100
|
+
.Field("cluster", &CdsLbConfig::cluster_)
|
101
|
+
.Finish();
|
102
|
+
return loader;
|
103
|
+
}
|
104
|
+
|
89
105
|
private:
|
90
106
|
std::string cluster_;
|
91
107
|
};
|
@@ -97,7 +113,7 @@ class CdsLb : public LoadBalancingPolicy {
|
|
97
113
|
|
98
114
|
absl::string_view name() const override { return kCds; }
|
99
115
|
|
100
|
-
|
116
|
+
absl::Status UpdateLocked(UpdateArgs args) override;
|
101
117
|
void ResetBackoffLocked() override;
|
102
118
|
void ExitIdleLocked() override;
|
103
119
|
|
@@ -309,7 +325,7 @@ void CdsLb::ExitIdleLocked() {
|
|
309
325
|
if (child_policy_ != nullptr) child_policy_->ExitIdleLocked();
|
310
326
|
}
|
311
327
|
|
312
|
-
|
328
|
+
absl::Status CdsLb::UpdateLocked(UpdateArgs args) {
|
313
329
|
// Update config.
|
314
330
|
auto old_config = std::move(config_);
|
315
331
|
config_ = std::move(args.config);
|
@@ -337,6 +353,7 @@ void CdsLb::UpdateLocked(UpdateArgs args) {
|
|
337
353
|
XdsClusterResourceType::StartWatch(xds_client_.get(), config_->cluster(),
|
338
354
|
std::move(watcher));
|
339
355
|
}
|
356
|
+
return absl::OkStatus();
|
340
357
|
}
|
341
358
|
|
342
359
|
// Generates the discovery mechanism config for the specified cluster name.
|
@@ -517,7 +534,9 @@ void CdsLb::OnClusterChanged(const std::string& name,
|
|
517
534
|
this, json_str.c_str());
|
518
535
|
}
|
519
536
|
grpc_error_handle error = GRPC_ERROR_NONE;
|
520
|
-
auto config =
|
537
|
+
auto config =
|
538
|
+
CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig(
|
539
|
+
json);
|
521
540
|
if (!config.ok()) {
|
522
541
|
OnError(name, absl::UnavailableError(config.status().message()));
|
523
542
|
return;
|
@@ -528,8 +547,10 @@ void CdsLb::OnClusterChanged(const std::string& name,
|
|
528
547
|
args.work_serializer = work_serializer();
|
529
548
|
args.args = args_;
|
530
549
|
args.channel_control_helper = absl::make_unique<Helper>(Ref());
|
531
|
-
child_policy_ =
|
532
|
-
|
550
|
+
child_policy_ =
|
551
|
+
CoreConfiguration::Get()
|
552
|
+
.lb_policy_registry()
|
553
|
+
.CreateLoadBalancingPolicy((*config)->name(), std::move(args));
|
533
554
|
if (child_policy_ == nullptr) {
|
534
555
|
OnError(name, absl::UnavailableError("failed to create child policy"));
|
535
556
|
return;
|
@@ -549,7 +570,9 @@ void CdsLb::OnClusterChanged(const std::string& name,
|
|
549
570
|
} else {
|
550
571
|
args.args = args_;
|
551
572
|
}
|
552
|
-
|
573
|
+
// TODO(roth): If the child policy reports an error with the update,
|
574
|
+
// we need to propagate the error to the resolver somehow.
|
575
|
+
(void)child_policy_->UpdateLocked(std::move(args));
|
553
576
|
}
|
554
577
|
// Remove entries in watchers_ for any clusters not in clusters_added
|
555
578
|
for (auto it = watchers_.begin(); it != watchers_.end();) {
|
@@ -734,38 +757,16 @@ class CdsLbFactory : public LoadBalancingPolicyFactory {
|
|
734
757
|
"field:loadBalancingPolicy error:cds policy requires configuration. "
|
735
758
|
"Please use loadBalancingConfig field of service config instead.");
|
736
759
|
}
|
737
|
-
|
738
|
-
|
739
|
-
std::string cluster;
|
740
|
-
auto it = json.object_value().find("cluster");
|
741
|
-
if (it == json.object_value().end()) {
|
742
|
-
errors.emplace_back("required field 'cluster' not present");
|
743
|
-
} else if (it->second.type() != Json::Type::STRING) {
|
744
|
-
errors.emplace_back("field:cluster error:type should be string");
|
745
|
-
} else {
|
746
|
-
cluster = it->second.string_value();
|
747
|
-
}
|
748
|
-
if (!errors.empty()) {
|
749
|
-
return absl::InvalidArgumentError(
|
750
|
-
absl::StrCat("errors parsing CDS LB policy config: [",
|
751
|
-
absl::StrJoin(errors, "; "), "]"));
|
752
|
-
}
|
753
|
-
return MakeRefCounted<CdsLbConfig>(std::move(cluster));
|
760
|
+
return LoadRefCountedFromJson<CdsLbConfig>(
|
761
|
+
json, JsonArgs(), "errors validating cds LB policy config");
|
754
762
|
}
|
755
763
|
};
|
756
764
|
|
757
765
|
} // namespace
|
758
766
|
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
// Plugin registration
|
763
|
-
//
|
764
|
-
|
765
|
-
void grpc_lb_policy_cds_init() {
|
766
|
-
grpc_core::LoadBalancingPolicyRegistry::Builder::
|
767
|
-
RegisterLoadBalancingPolicyFactory(
|
768
|
-
absl::make_unique<grpc_core::CdsLbFactory>());
|
767
|
+
void RegisterCdsLbPolicy(CoreConfiguration::Builder* builder) {
|
768
|
+
builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
|
769
|
+
absl::make_unique<CdsLbFactory>());
|
769
770
|
}
|
770
771
|
|
771
|
-
|
772
|
+
} // namespace grpc_core
|