grpc 1.18.0 → 1.19.0

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.

Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +301 -33
  3. data/include/grpc/grpc_security.h +195 -0
  4. data/include/grpc/impl/codegen/grpc_types.h +17 -1
  5. data/include/grpc/impl/codegen/port_platform.h +40 -0
  6. data/include/grpc/impl/codegen/slice.h +1 -1
  7. data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -0
  8. data/src/core/ext/filters/client_channel/client_channel.cc +74 -69
  9. data/src/core/ext/filters/client_channel/client_channel.h +2 -2
  10. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +5 -6
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.h +5 -4
  12. data/src/core/ext/filters/client_channel/client_channel_factory.cc +2 -2
  13. data/src/core/ext/filters/client_channel/client_channel_factory.h +4 -4
  14. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -3
  15. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +176 -0
  16. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
  17. data/src/core/ext/filters/client_channel/health/health_check_client.cc +10 -8
  18. data/src/core/ext/filters/client_channel/health/health_check_client.h +1 -1
  19. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +146 -156
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +28 -30
  21. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +5 -8
  22. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -8
  23. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +23 -24
  24. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +80 -15
  25. data/src/core/ext/filters/client_channel/lb_policy.cc +30 -1
  26. data/src/core/ext/filters/client_channel/lb_policy.h +29 -1
  27. data/src/core/ext/filters/client_channel/lb_policy_factory.h +6 -1
  28. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +2 -2
  29. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  30. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
  31. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +56 -0
  32. data/src/core/ext/filters/client_channel/parse_address.cc +24 -5
  33. data/src/core/ext/filters/client_channel/request_routing.cc +13 -3
  34. data/src/core/ext/filters/client_channel/request_routing.h +5 -1
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +11 -6
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +9 -6
  37. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
  38. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +7 -35
  39. data/src/core/ext/filters/client_channel/subchannel.cc +698 -791
  40. data/src/core/ext/filters/client_channel/subchannel.h +213 -123
  41. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
  42. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +94 -0
  43. data/src/core/ext/filters/http/client_authority_filter.cc +5 -2
  44. data/src/core/ext/filters/max_age/max_age_filter.cc +1 -1
  45. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -12
  46. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +5 -7
  47. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +19 -27
  48. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +18 -19
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +27 -6
  50. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
  51. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +3 -2
  52. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
  53. data/src/core/ext/transport/chttp2/transport/writing.cc +8 -5
  54. data/src/core/lib/channel/handshaker.cc +141 -214
  55. data/src/core/lib/channel/handshaker.h +110 -101
  56. data/src/core/lib/channel/handshaker_factory.h +11 -19
  57. data/src/core/lib/channel/handshaker_registry.cc +64 -52
  58. data/src/core/lib/channel/handshaker_registry.h +21 -16
  59. data/src/core/lib/gpr/log_posix.cc +2 -1
  60. data/src/core/lib/gpr/time.cc +8 -0
  61. data/src/core/lib/gpr/time_posix.cc +8 -2
  62. data/src/core/lib/gprpp/optional.h +47 -0
  63. data/src/core/lib/http/httpcli_security_connector.cc +13 -14
  64. data/src/core/lib/iomgr/buffer_list.cc +182 -24
  65. data/src/core/lib/iomgr/buffer_list.h +70 -8
  66. data/src/core/lib/iomgr/combiner.cc +11 -3
  67. data/src/core/lib/iomgr/error.cc +9 -5
  68. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -0
  69. data/src/core/lib/iomgr/ev_epollex_linux.cc +136 -162
  70. data/src/core/lib/iomgr/ev_poll_posix.cc +3 -0
  71. data/src/core/lib/iomgr/ev_posix.cc +4 -0
  72. data/src/core/lib/iomgr/ev_posix.h +4 -0
  73. data/src/core/lib/iomgr/exec_ctx.cc +1 -0
  74. data/src/core/lib/iomgr/exec_ctx.h +137 -8
  75. data/src/core/lib/iomgr/executor.cc +122 -87
  76. data/src/core/lib/iomgr/executor.h +53 -48
  77. data/src/core/lib/iomgr/fork_posix.cc +6 -4
  78. data/src/core/lib/iomgr/{network_status_tracker.cc → grpc_if_nametoindex.h} +8 -14
  79. data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
  80. data/src/core/lib/iomgr/{network_status_tracker.h → grpc_if_nametoindex_unsupported.cc} +15 -9
  81. data/src/core/lib/iomgr/internal_errqueue.h +105 -3
  82. data/src/core/lib/iomgr/iomgr.cc +6 -5
  83. data/src/core/lib/iomgr/iomgr.h +8 -0
  84. data/src/core/lib/iomgr/iomgr_custom.cc +6 -2
  85. data/src/core/lib/iomgr/iomgr_internal.cc +4 -0
  86. data/src/core/lib/iomgr/iomgr_internal.h +4 -0
  87. data/src/core/lib/iomgr/iomgr_posix.cc +10 -1
  88. data/src/core/lib/iomgr/iomgr_windows.cc +8 -1
  89. data/src/core/lib/iomgr/port.h +1 -0
  90. data/src/core/lib/iomgr/resolve_address_posix.cc +4 -3
  91. data/src/core/lib/iomgr/resolve_address_windows.cc +2 -1
  92. data/src/core/lib/iomgr/tcp_custom.cc +0 -4
  93. data/src/core/lib/iomgr/tcp_posix.cc +58 -44
  94. data/src/core/lib/iomgr/tcp_uv.cc +0 -1
  95. data/src/core/lib/iomgr/tcp_windows.cc +0 -4
  96. data/src/core/lib/iomgr/timer_manager.cc +8 -0
  97. data/src/core/lib/iomgr/udp_server.cc +6 -4
  98. data/src/core/lib/json/json.cc +1 -4
  99. data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
  100. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
  101. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -0
  102. data/src/core/lib/security/credentials/credentials.h +9 -1
  103. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -2
  104. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +2 -0
  105. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  106. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +1 -0
  107. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
  108. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +2 -2
  109. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -0
  110. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +192 -0
  111. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +213 -0
  112. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +10 -8
  113. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +6 -10
  114. data/src/core/lib/security/security_connector/local/local_security_connector.cc +10 -8
  115. data/src/core/lib/security/security_connector/security_connector.h +2 -2
  116. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -6
  117. data/src/core/lib/security/security_connector/ssl_utils.h +33 -0
  118. data/src/core/lib/security/transport/security_handshaker.cc +267 -300
  119. data/src/core/lib/security/transport/security_handshaker.h +11 -2
  120. data/src/core/lib/security/transport/server_auth_filter.cc +1 -0
  121. data/src/core/lib/surface/call.cc +5 -1
  122. data/src/core/lib/surface/channel_init.h +5 -0
  123. data/src/core/lib/surface/completion_queue.cc +4 -7
  124. data/src/core/lib/surface/init.cc +5 -3
  125. data/src/core/lib/surface/init_secure.cc +1 -1
  126. data/src/core/lib/surface/server.cc +19 -17
  127. data/src/core/lib/surface/version.cc +1 -1
  128. data/src/core/lib/transport/service_config.h +1 -0
  129. data/src/core/lib/transport/static_metadata.cc +279 -279
  130. data/src/core/lib/transport/transport.cc +5 -3
  131. data/src/core/tsi/ssl_transport_security.cc +10 -4
  132. data/src/ruby/ext/grpc/extconf.rb +12 -4
  133. data/src/ruby/ext/grpc/rb_call_credentials.c +8 -5
  134. data/src/ruby/ext/grpc/rb_channel.c +14 -10
  135. data/src/ruby/ext/grpc/rb_channel_credentials.c +8 -4
  136. data/src/ruby/ext/grpc/rb_compression_options.c +9 -7
  137. data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
  138. data/src/ruby/ext/grpc/rb_grpc.c +22 -23
  139. data/src/ruby/ext/grpc/rb_grpc.h +4 -2
  140. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +18 -0
  141. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +27 -0
  142. data/src/ruby/ext/grpc/rb_server.c +8 -4
  143. data/src/ruby/lib/grpc/version.rb +1 -1
  144. metadata +45 -38
  145. data/src/core/ext/filters/client_channel/subchannel_index.cc +0 -248
  146. data/src/core/ext/filters/client_channel/subchannel_index.h +0 -76
  147. data/src/core/lib/channel/handshaker_factory.cc +0 -42
@@ -26,7 +26,6 @@
26
26
  #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
27
27
  #include "src/core/ext/filters/client_channel/server_address.h"
28
28
  #include "src/core/ext/filters/client_channel/subchannel.h"
29
- #include "src/core/ext/filters/client_channel/subchannel_index.h"
30
29
  #include "src/core/lib/channel/channel_args.h"
31
30
  #include "src/core/lib/gprpp/mutex_lock.h"
32
31
  #include "src/core/lib/iomgr/combiner.h"
@@ -47,7 +46,7 @@ constexpr char kPickFirst[] = "pick_first";
47
46
 
48
47
  class PickFirst : public LoadBalancingPolicy {
49
48
  public:
50
- explicit PickFirst(const Args& args);
49
+ explicit PickFirst(Args args);
51
50
 
52
51
  const char* name() const override { return kPickFirst; }
53
52
 
@@ -80,7 +79,7 @@ class PickFirst : public LoadBalancingPolicy {
80
79
  PickFirstSubchannelData(
81
80
  SubchannelList<PickFirstSubchannelList, PickFirstSubchannelData>*
82
81
  subchannel_list,
83
- const ServerAddress& address, grpc_subchannel* subchannel,
82
+ const ServerAddress& address, Subchannel* subchannel,
84
83
  grpc_combiner* combiner)
85
84
  : SubchannelData(subchannel_list, address, subchannel, combiner) {}
86
85
 
@@ -155,7 +154,7 @@ class PickFirst : public LoadBalancingPolicy {
155
154
  channelz::ChildRefsList child_channels_;
156
155
  };
157
156
 
158
- PickFirst::PickFirst(const Args& args) : LoadBalancingPolicy(args) {
157
+ PickFirst::PickFirst(Args args) : LoadBalancingPolicy(std::move(args)) {
159
158
  GPR_ASSERT(args.client_channel_factory != nullptr);
160
159
  gpr_mu_init(&child_refs_mu_);
161
160
  grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE,
@@ -164,7 +163,6 @@ PickFirst::PickFirst(const Args& args) : LoadBalancingPolicy(args) {
164
163
  gpr_log(GPR_INFO, "Pick First %p created.", this);
165
164
  }
166
165
  UpdateLocked(*args.args, args.lb_config);
167
- grpc_subchannel_index_ref();
168
166
  }
169
167
 
170
168
  PickFirst::~PickFirst() {
@@ -176,7 +174,6 @@ PickFirst::~PickFirst() {
176
174
  GPR_ASSERT(latest_pending_subchannel_list_ == nullptr);
177
175
  GPR_ASSERT(pending_picks_ == nullptr);
178
176
  grpc_connectivity_state_destroy(&state_tracker_);
179
- grpc_subchannel_index_unref();
180
177
  }
181
178
 
182
179
  void PickFirst::HandOffPendingPicksLocked(LoadBalancingPolicy* new_policy) {
@@ -622,8 +619,8 @@ void PickFirst::PickFirstSubchannelData::
622
619
  class PickFirstFactory : public LoadBalancingPolicyFactory {
623
620
  public:
624
621
  OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
625
- const LoadBalancingPolicy::Args& args) const override {
626
- return OrphanablePtr<LoadBalancingPolicy>(New<PickFirst>(args));
622
+ LoadBalancingPolicy::Args args) const override {
623
+ return OrphanablePtr<LoadBalancingPolicy>(New<PickFirst>(std::move(args)));
627
624
  }
628
625
 
629
626
  const char* name() const override { return kPickFirst; }
@@ -33,7 +33,6 @@
33
33
  #include "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h"
34
34
  #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
35
35
  #include "src/core/ext/filters/client_channel/subchannel.h"
36
- #include "src/core/ext/filters/client_channel/subchannel_index.h"
37
36
  #include "src/core/lib/channel/channel_args.h"
38
37
  #include "src/core/lib/debug/trace.h"
39
38
  #include "src/core/lib/gprpp/mutex_lock.h"
@@ -57,7 +56,7 @@ constexpr char kRoundRobin[] = "round_robin";
57
56
 
58
57
  class RoundRobin : public LoadBalancingPolicy {
59
58
  public:
60
- explicit RoundRobin(const Args& args);
59
+ explicit RoundRobin(Args args);
61
60
 
62
61
  const char* name() const override { return kRoundRobin; }
63
62
 
@@ -95,7 +94,7 @@ class RoundRobin : public LoadBalancingPolicy {
95
94
  RoundRobinSubchannelData(
96
95
  SubchannelList<RoundRobinSubchannelList, RoundRobinSubchannelData>*
97
96
  subchannel_list,
98
- const ServerAddress& address, grpc_subchannel* subchannel,
97
+ const ServerAddress& address, Subchannel* subchannel,
99
98
  grpc_combiner* combiner)
100
99
  : SubchannelData(subchannel_list, address, subchannel, combiner) {}
101
100
 
@@ -211,7 +210,7 @@ class RoundRobin : public LoadBalancingPolicy {
211
210
  channelz::ChildRefsList child_channels_;
212
211
  };
213
212
 
214
- RoundRobin::RoundRobin(const Args& args) : LoadBalancingPolicy(args) {
213
+ RoundRobin::RoundRobin(Args args) : LoadBalancingPolicy(std::move(args)) {
215
214
  GPR_ASSERT(args.client_channel_factory != nullptr);
216
215
  gpr_mu_init(&child_refs_mu_);
217
216
  grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE,
@@ -221,7 +220,6 @@ RoundRobin::RoundRobin(const Args& args) : LoadBalancingPolicy(args) {
221
220
  gpr_log(GPR_INFO, "[RR %p] Created with %" PRIuPTR " subchannels", this,
222
221
  subchannel_list_->num_subchannels());
223
222
  }
224
- grpc_subchannel_index_ref();
225
223
  }
226
224
 
227
225
  RoundRobin::~RoundRobin() {
@@ -233,7 +231,6 @@ RoundRobin::~RoundRobin() {
233
231
  GPR_ASSERT(latest_pending_subchannel_list_ == nullptr);
234
232
  GPR_ASSERT(pending_picks_ == nullptr);
235
233
  grpc_connectivity_state_destroy(&state_tracker_);
236
- grpc_subchannel_index_unref();
237
234
  }
238
235
 
239
236
  void RoundRobin::HandOffPendingPicksLocked(LoadBalancingPolicy* new_policy) {
@@ -700,8 +697,8 @@ void RoundRobin::UpdateLocked(const grpc_channel_args& args,
700
697
  class RoundRobinFactory : public LoadBalancingPolicyFactory {
701
698
  public:
702
699
  OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
703
- const LoadBalancingPolicy::Args& args) const override {
704
- return OrphanablePtr<LoadBalancingPolicy>(New<RoundRobin>(args));
700
+ LoadBalancingPolicy::Args args) const override {
701
+ return OrphanablePtr<LoadBalancingPolicy>(New<RoundRobin>(std::move(args)));
705
702
  }
706
703
 
707
704
  const char* name() const override { return kRoundRobin; }
@@ -88,7 +88,7 @@ class SubchannelData {
88
88
  }
89
89
 
90
90
  // Returns a pointer to the subchannel.
91
- grpc_subchannel* subchannel() const { return subchannel_; }
91
+ Subchannel* subchannel() const { return subchannel_; }
92
92
 
93
93
  // Returns the connected subchannel. Will be null if the subchannel
94
94
  // is not connected.
@@ -103,8 +103,8 @@ class SubchannelData {
103
103
  // ProcessConnectivityChangeLocked()).
104
104
  grpc_connectivity_state CheckConnectivityStateLocked(grpc_error** error) {
105
105
  GPR_ASSERT(!connectivity_notification_pending_);
106
- pending_connectivity_state_unsafe_ = grpc_subchannel_check_connectivity(
107
- subchannel(), error, subchannel_list_->inhibit_health_checking());
106
+ pending_connectivity_state_unsafe_ = subchannel()->CheckConnectivity(
107
+ error, subchannel_list_->inhibit_health_checking());
108
108
  UpdateConnectedSubchannelLocked();
109
109
  return pending_connectivity_state_unsafe_;
110
110
  }
@@ -142,7 +142,7 @@ class SubchannelData {
142
142
  protected:
143
143
  SubchannelData(
144
144
  SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list,
145
- const ServerAddress& address, grpc_subchannel* subchannel,
145
+ const ServerAddress& address, Subchannel* subchannel,
146
146
  grpc_combiner* combiner);
147
147
 
148
148
  virtual ~SubchannelData();
@@ -170,7 +170,7 @@ class SubchannelData {
170
170
  SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list_;
171
171
 
172
172
  // The subchannel and connected subchannel.
173
- grpc_subchannel* subchannel_;
173
+ Subchannel* subchannel_;
174
174
  RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
175
175
 
176
176
  // Notification that connectivity has changed on subchannel.
@@ -203,7 +203,7 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
203
203
  for (size_t i = 0; i < subchannels_.size(); ++i) {
204
204
  if (subchannels_[i].subchannel() != nullptr) {
205
205
  grpc_core::channelz::SubchannelNode* subchannel_node =
206
- grpc_subchannel_get_channelz_node(subchannels_[i].subchannel());
206
+ subchannels_[i].subchannel()->channelz_node();
207
207
  if (subchannel_node != nullptr) {
208
208
  refs_list->push_back(subchannel_node->uuid());
209
209
  }
@@ -276,7 +276,7 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
276
276
  template <typename SubchannelListType, typename SubchannelDataType>
277
277
  SubchannelData<SubchannelListType, SubchannelDataType>::SubchannelData(
278
278
  SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list,
279
- const ServerAddress& address, grpc_subchannel* subchannel,
279
+ const ServerAddress& address, Subchannel* subchannel,
280
280
  grpc_combiner* combiner)
281
281
  : subchannel_list_(subchannel_list),
282
282
  subchannel_(subchannel),
@@ -317,7 +317,7 @@ template <typename SubchannelListType, typename SubchannelDataType>
317
317
  void SubchannelData<SubchannelListType,
318
318
  SubchannelDataType>::ResetBackoffLocked() {
319
319
  if (subchannel_ != nullptr) {
320
- grpc_subchannel_reset_backoff(subchannel_);
320
+ subchannel_->ResetBackoff();
321
321
  }
322
322
  }
323
323
 
@@ -337,8 +337,8 @@ void SubchannelData<SubchannelListType,
337
337
  GPR_ASSERT(!connectivity_notification_pending_);
338
338
  connectivity_notification_pending_ = true;
339
339
  subchannel_list()->Ref(DEBUG_LOCATION, "connectivity_watch").release();
340
- grpc_subchannel_notify_on_state_change(
341
- subchannel_, subchannel_list_->policy()->interested_parties(),
340
+ subchannel_->NotifyOnStateChange(
341
+ subchannel_list_->policy()->interested_parties(),
342
342
  &pending_connectivity_state_unsafe_, &connectivity_changed_closure_,
343
343
  subchannel_list_->inhibit_health_checking());
344
344
  }
@@ -357,8 +357,8 @@ void SubchannelData<SubchannelListType,
357
357
  grpc_connectivity_state_name(pending_connectivity_state_unsafe_));
358
358
  }
359
359
  GPR_ASSERT(connectivity_notification_pending_);
360
- grpc_subchannel_notify_on_state_change(
361
- subchannel_, subchannel_list_->policy()->interested_parties(),
360
+ subchannel_->NotifyOnStateChange(
361
+ subchannel_list_->policy()->interested_parties(),
362
362
  &pending_connectivity_state_unsafe_, &connectivity_changed_closure_,
363
363
  subchannel_list_->inhibit_health_checking());
364
364
  }
@@ -391,9 +391,9 @@ void SubchannelData<SubchannelListType, SubchannelDataType>::
391
391
  subchannel_, reason);
392
392
  }
393
393
  GPR_ASSERT(connectivity_notification_pending_);
394
- grpc_subchannel_notify_on_state_change(
395
- subchannel_, nullptr, nullptr, &connectivity_changed_closure_,
396
- subchannel_list_->inhibit_health_checking());
394
+ subchannel_->NotifyOnStateChange(nullptr, nullptr,
395
+ &connectivity_changed_closure_,
396
+ subchannel_list_->inhibit_health_checking());
397
397
  }
398
398
 
399
399
  template <typename SubchannelListType, typename SubchannelDataType>
@@ -401,8 +401,7 @@ bool SubchannelData<SubchannelListType,
401
401
  SubchannelDataType>::UpdateConnectedSubchannelLocked() {
402
402
  // If the subchannel is READY, take a ref to the connected subchannel.
403
403
  if (pending_connectivity_state_unsafe_ == GRPC_CHANNEL_READY) {
404
- connected_subchannel_ =
405
- grpc_subchannel_get_connected_subchannel(subchannel_);
404
+ connected_subchannel_ = subchannel_->connected_subchannel();
406
405
  // If the subchannel became disconnected between the time that READY
407
406
  // was reported and the time we got here (e.g., between when a
408
407
  // notification callback is scheduled and when it was actually run in
@@ -509,15 +508,16 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
509
508
  GRPC_ARG_SERVER_ADDRESS_LIST,
510
509
  GRPC_ARG_INHIBIT_HEALTH_CHECKING};
511
510
  // Create a subchannel for each address.
512
- grpc_subchannel_args sc_args;
513
511
  for (size_t i = 0; i < addresses.size(); i++) {
514
512
  // If there were any balancer addresses, we would have chosen grpclb
515
513
  // policy, which does not use a SubchannelList.
516
514
  GPR_ASSERT(!addresses[i].IsBalancer());
517
- memset(&sc_args, 0, sizeof(grpc_subchannel_args));
518
515
  InlinedVector<grpc_arg, 4> args_to_add;
519
516
  args_to_add.emplace_back(
520
- grpc_create_subchannel_address_arg(&addresses[i].address()));
517
+ SubchannelPoolInterface::CreateChannelArg(policy_->subchannel_pool()));
518
+ const size_t subchannel_address_arg_index = args_to_add.size();
519
+ args_to_add.emplace_back(
520
+ Subchannel::CreateSubchannelAddressArg(&addresses[i].address()));
521
521
  if (addresses[i].args() != nullptr) {
522
522
  for (size_t j = 0; j < addresses[i].args()->num_args; ++j) {
523
523
  args_to_add.emplace_back(addresses[i].args()->args[j]);
@@ -526,10 +526,9 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
526
526
  grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
527
527
  &args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove),
528
528
  args_to_add.data(), args_to_add.size());
529
- gpr_free(args_to_add[0].value.string);
530
- sc_args.args = new_args;
531
- grpc_subchannel* subchannel = grpc_client_channel_factory_create_subchannel(
532
- client_channel_factory, &sc_args);
529
+ gpr_free(args_to_add[subchannel_address_arg_index].value.string);
530
+ Subchannel* subchannel = grpc_client_channel_factory_create_subchannel(
531
+ client_channel_factory, new_args);
533
532
  grpc_channel_args_destroy(new_args);
534
533
  if (subchannel == nullptr) {
535
534
  // Subchannel could not be created.
@@ -80,7 +80,6 @@
80
80
  #include "src/core/ext/filters/client_channel/parse_address.h"
81
81
  #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
82
82
  #include "src/core/ext/filters/client_channel/server_address.h"
83
- #include "src/core/ext/filters/client_channel/subchannel_index.h"
84
83
  #include "src/core/lib/backoff/backoff.h"
85
84
  #include "src/core/lib/channel/channel_args.h"
86
85
  #include "src/core/lib/channel/channel_stack.h"
@@ -101,6 +100,7 @@
101
100
  #include "src/core/lib/surface/call.h"
102
101
  #include "src/core/lib/surface/channel.h"
103
102
  #include "src/core/lib/surface/channel_init.h"
103
+ #include "src/core/lib/transport/service_config.h"
104
104
  #include "src/core/lib/transport/static_metadata.h"
105
105
 
106
106
  #define GRPC_XDS_INITIAL_CONNECT_BACKOFF_SECONDS 1
@@ -119,7 +119,7 @@ constexpr char kXds[] = "xds_experimental";
119
119
 
120
120
  class XdsLb : public LoadBalancingPolicy {
121
121
  public:
122
- explicit XdsLb(const Args& args);
122
+ explicit XdsLb(Args args);
123
123
 
124
124
  const char* name() const override { return kXds; }
125
125
 
@@ -248,6 +248,12 @@ class XdsLb : public LoadBalancingPolicy {
248
248
  // Helper function used in ctor and UpdateLocked().
249
249
  void ProcessChannelArgsLocked(const grpc_channel_args& args);
250
250
 
251
+ // Parses the xds config given the JSON node of the first child of XdsConfig.
252
+ // If parsing succeeds, updates \a balancer_name, and updates \a
253
+ // child_policy_json_dump_ and \a fallback_policy_json_dump_ if they are also
254
+ // found. Does nothing upon failure.
255
+ void ParseLbConfig(grpc_json* xds_config_json);
256
+
251
257
  // Methods for dealing with the balancer channel and call.
252
258
  void StartPickingLocked();
253
259
  void StartBalancerCallLocked();
@@ -266,7 +272,7 @@ class XdsLb : public LoadBalancingPolicy {
266
272
  // Methods for dealing with the child policy.
267
273
  void CreateOrUpdateChildPolicyLocked();
268
274
  grpc_channel_args* CreateChildPolicyArgsLocked();
269
- void CreateChildPolicyLocked(const Args& args);
275
+ void CreateChildPolicyLocked(const char* name, Args args);
270
276
  bool PickFromChildPolicyLocked(bool force_async, PendingPick* pp,
271
277
  grpc_error** error);
272
278
  void UpdateConnectivityStateFromChildPolicyLocked(
@@ -279,6 +285,9 @@ class XdsLb : public LoadBalancingPolicy {
279
285
  // Who the client is trying to communicate with.
280
286
  const char* server_name_ = nullptr;
281
287
 
288
+ // Name of the balancer to connect to.
289
+ UniquePtr<char> balancer_name_;
290
+
282
291
  // Current channel args from the resolver.
283
292
  grpc_channel_args* args_ = nullptr;
284
293
 
@@ -319,6 +328,7 @@ class XdsLb : public LoadBalancingPolicy {
319
328
 
320
329
  // Timeout in milliseconds for before using fallback backend addresses.
321
330
  // 0 means not using fallback.
331
+ UniquePtr<char> fallback_policy_json_string_;
322
332
  int lb_fallback_timeout_ms_ = 0;
323
333
  // The backend addresses from the resolver.
324
334
  UniquePtr<ServerAddressList> fallback_backend_addresses_;
@@ -332,6 +342,7 @@ class XdsLb : public LoadBalancingPolicy {
332
342
 
333
343
  // The policy to use for the backends.
334
344
  OrphanablePtr<LoadBalancingPolicy> child_policy_;
345
+ UniquePtr<char> child_policy_json_string_;
335
346
  grpc_connectivity_state child_connectivity_state_;
336
347
  grpc_closure on_child_connectivity_changed_;
337
348
  grpc_closure on_child_request_reresolution_;
@@ -893,8 +904,8 @@ grpc_channel_args* BuildBalancerChannelArgs(
893
904
  //
894
905
 
895
906
  // TODO(vishalpowar): Use lb_config in args to configure LB policy.
896
- XdsLb::XdsLb(const LoadBalancingPolicy::Args& args)
897
- : LoadBalancingPolicy(args),
907
+ XdsLb::XdsLb(LoadBalancingPolicy::Args args)
908
+ : LoadBalancingPolicy(std::move(args)),
898
909
  response_generator_(MakeRefCounted<FakeResolverResponseGenerator>()),
899
910
  lb_call_backoff_(
900
911
  BackOff::Options()
@@ -905,7 +916,6 @@ XdsLb::XdsLb(const LoadBalancingPolicy::Args& args)
905
916
  .set_max_backoff(GRPC_XDS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)) {
906
917
  // Initialization.
907
918
  gpr_mu_init(&lb_channel_mu_);
908
- grpc_subchannel_index_ref();
909
919
  GRPC_CLOSURE_INIT(&lb_channel_on_connectivity_changed_,
910
920
  &XdsLb::OnBalancerChannelConnectivityChangedLocked, this,
911
921
  grpc_combiner_scheduler(args.combiner));
@@ -936,6 +946,8 @@ XdsLb::XdsLb(const LoadBalancingPolicy::Args& args)
936
946
  arg = grpc_channel_args_find(args.args, GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS);
937
947
  lb_fallback_timeout_ms_ = grpc_channel_arg_get_integer(
938
948
  arg, {GRPC_XDS_DEFAULT_FALLBACK_TIMEOUT_MS, 0, INT_MAX});
949
+ // Parse the LB config.
950
+ ParseLbConfig(args.lb_config);
939
951
  // Process channel args.
940
952
  ProcessChannelArgsLocked(*args.args);
941
953
  }
@@ -949,7 +961,6 @@ XdsLb::~XdsLb() {
949
961
  if (serverlist_ != nullptr) {
950
962
  xds_grpclb_destroy_serverlist(serverlist_);
951
963
  }
952
- grpc_subchannel_index_unref();
953
964
  }
954
965
 
955
966
  void XdsLb::ShutdownLocked() {
@@ -1187,8 +1198,44 @@ void XdsLb::ProcessChannelArgsLocked(const grpc_channel_args& args) {
1187
1198
  grpc_channel_args_destroy(lb_channel_args);
1188
1199
  }
1189
1200
 
1190
- // TODO(vishalpowar): Use lb_config to configure LB policy.
1201
+ void XdsLb::ParseLbConfig(grpc_json* xds_config_json) {
1202
+ const char* balancer_name = nullptr;
1203
+ grpc_json* child_policy = nullptr;
1204
+ grpc_json* fallback_policy = nullptr;
1205
+ for (grpc_json* field = xds_config_json; field != nullptr;
1206
+ field = field->next) {
1207
+ if (field->key == nullptr) return;
1208
+ if (strcmp(field->key, "balancerName") == 0) {
1209
+ if (balancer_name != nullptr) return; // Duplicate.
1210
+ if (field->type != GRPC_JSON_STRING) return;
1211
+ balancer_name = field->value;
1212
+ } else if (strcmp(field->key, "childPolicy") == 0) {
1213
+ if (child_policy != nullptr) return; // Duplicate.
1214
+ child_policy = ParseLoadBalancingConfig(field);
1215
+ } else if (strcmp(field->key, "fallbackPolicy") == 0) {
1216
+ if (fallback_policy != nullptr) return; // Duplicate.
1217
+ fallback_policy = ParseLoadBalancingConfig(field);
1218
+ }
1219
+ }
1220
+ if (balancer_name == nullptr) return; // Required field.
1221
+ if (child_policy != nullptr) {
1222
+ child_policy_json_string_ =
1223
+ UniquePtr<char>(grpc_json_dump_to_string(child_policy, 0 /* indent */));
1224
+ }
1225
+ if (fallback_policy != nullptr) {
1226
+ fallback_policy_json_string_ = UniquePtr<char>(
1227
+ grpc_json_dump_to_string(fallback_policy, 0 /* indent */));
1228
+ }
1229
+ balancer_name_ = UniquePtr<char>(gpr_strdup(balancer_name));
1230
+ }
1231
+
1191
1232
  void XdsLb::UpdateLocked(const grpc_channel_args& args, grpc_json* lb_config) {
1233
+ ParseLbConfig(lb_config);
1234
+ // TODO(juanlishen): Pass fallback policy config update after fallback policy
1235
+ // is added.
1236
+ if (balancer_name_ == nullptr) {
1237
+ gpr_log(GPR_ERROR, "[xdslb %p] LB config parsing fails.", this);
1238
+ }
1192
1239
  ProcessChannelArgsLocked(args);
1193
1240
  // Update the existing child policy.
1194
1241
  // Note: We have disabled fallback mode in the code, so this child policy must
@@ -1439,10 +1486,10 @@ bool XdsLb::PickFromChildPolicyLocked(bool force_async, PendingPick* pp,
1439
1486
  return pick_done;
1440
1487
  }
1441
1488
 
1442
- void XdsLb::CreateChildPolicyLocked(const Args& args) {
1489
+ void XdsLb::CreateChildPolicyLocked(const char* name, Args args) {
1443
1490
  GPR_ASSERT(child_policy_ == nullptr);
1444
1491
  child_policy_ = LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
1445
- "round_robin", args);
1492
+ name, std::move(args));
1446
1493
  if (GPR_UNLIKELY(child_policy_ == nullptr)) {
1447
1494
  gpr_log(GPR_ERROR, "[xdslb %p] Failure creating a child policy", this);
1448
1495
  return;
@@ -1515,25 +1562,43 @@ void XdsLb::CreateOrUpdateChildPolicyLocked() {
1515
1562
  if (shutting_down_) return;
1516
1563
  grpc_channel_args* args = CreateChildPolicyArgsLocked();
1517
1564
  GPR_ASSERT(args != nullptr);
1565
+ const char* child_policy_name = nullptr;
1566
+ grpc_json* child_policy_config = nullptr;
1567
+ grpc_json* child_policy_json =
1568
+ grpc_json_parse_string(child_policy_json_string_.get());
1569
+ // TODO(juanlishen): If the child policy is not configured via service config,
1570
+ // use whatever algorithm is specified by the balancer.
1571
+ if (child_policy_json != nullptr) {
1572
+ child_policy_name = child_policy_json->key;
1573
+ child_policy_config = child_policy_json->child;
1574
+ } else {
1575
+ if (grpc_lb_xds_trace.enabled()) {
1576
+ gpr_log(GPR_INFO, "[xdslb %p] No valid child policy LB config", this);
1577
+ }
1578
+ child_policy_name = "round_robin";
1579
+ }
1580
+ // TODO(juanlishen): Switch policy according to child_policy_config->key.
1518
1581
  if (child_policy_ != nullptr) {
1519
1582
  if (grpc_lb_xds_trace.enabled()) {
1520
1583
  gpr_log(GPR_INFO, "[xdslb %p] Updating the child policy %p", this,
1521
1584
  child_policy_.get());
1522
1585
  }
1523
- // TODO(vishalpowar): Pass the correct LB config.
1524
- child_policy_->UpdateLocked(*args, nullptr);
1586
+ child_policy_->UpdateLocked(*args, child_policy_config);
1525
1587
  } else {
1526
1588
  LoadBalancingPolicy::Args lb_policy_args;
1527
1589
  lb_policy_args.combiner = combiner();
1528
1590
  lb_policy_args.client_channel_factory = client_channel_factory();
1591
+ lb_policy_args.subchannel_pool = subchannel_pool()->Ref();
1529
1592
  lb_policy_args.args = args;
1530
- CreateChildPolicyLocked(lb_policy_args);
1593
+ lb_policy_args.lb_config = child_policy_config;
1594
+ CreateChildPolicyLocked(child_policy_name, std::move(lb_policy_args));
1531
1595
  if (grpc_lb_xds_trace.enabled()) {
1532
1596
  gpr_log(GPR_INFO, "[xdslb %p] Created a new child policy %p", this,
1533
1597
  child_policy_.get());
1534
1598
  }
1535
1599
  }
1536
1600
  grpc_channel_args_destroy(args);
1601
+ grpc_json_destroy(child_policy_json);
1537
1602
  }
1538
1603
 
1539
1604
  void XdsLb::OnChildPolicyRequestReresolutionLocked(void* arg,
@@ -1639,7 +1704,7 @@ void XdsLb::OnChildPolicyConnectivityChangedLocked(void* arg,
1639
1704
  class XdsFactory : public LoadBalancingPolicyFactory {
1640
1705
  public:
1641
1706
  OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
1642
- const LoadBalancingPolicy::Args& args) const override {
1707
+ LoadBalancingPolicy::Args args) const override {
1643
1708
  /* Count the number of gRPC-LB addresses. There must be at least one. */
1644
1709
  const ServerAddressList* addresses =
1645
1710
  FindServerAddressListChannelArg(args.args);
@@ -1652,7 +1717,7 @@ class XdsFactory : public LoadBalancingPolicyFactory {
1652
1717
  }
1653
1718
  }
1654
1719
  if (!found_balancer_address) return nullptr;
1655
- return OrphanablePtr<LoadBalancingPolicy>(New<XdsLb>(args));
1720
+ return OrphanablePtr<LoadBalancingPolicy>(New<XdsLb>(std::move(args)));
1656
1721
  }
1657
1722
 
1658
1723
  const char* name() const override { return kXds; }
@@ -19,6 +19,8 @@
19
19
  #include <grpc/support/port_platform.h>
20
20
 
21
21
  #include "src/core/ext/filters/client_channel/lb_policy.h"
22
+
23
+ #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
22
24
  #include "src/core/lib/iomgr/combiner.h"
23
25
 
24
26
  grpc_core::DebugOnlyTraceFlag grpc_trace_lb_policy_refcount(
@@ -26,10 +28,37 @@ grpc_core::DebugOnlyTraceFlag grpc_trace_lb_policy_refcount(
26
28
 
27
29
  namespace grpc_core {
28
30
 
29
- LoadBalancingPolicy::LoadBalancingPolicy(const Args& args)
31
+ grpc_json* LoadBalancingPolicy::ParseLoadBalancingConfig(
32
+ const grpc_json* lb_config_array) {
33
+ if (lb_config_array == nullptr || lb_config_array->type != GRPC_JSON_ARRAY) {
34
+ return nullptr;
35
+ }
36
+ // Find the first LB policy that this client supports.
37
+ for (const grpc_json* lb_config = lb_config_array->child;
38
+ lb_config != nullptr; lb_config = lb_config->next) {
39
+ if (lb_config->type != GRPC_JSON_OBJECT) return nullptr;
40
+ grpc_json* policy = nullptr;
41
+ for (grpc_json* field = lb_config->child; field != nullptr;
42
+ field = field->next) {
43
+ if (field->key == nullptr || field->type != GRPC_JSON_OBJECT)
44
+ return nullptr;
45
+ if (policy != nullptr) return nullptr; // Violate "oneof" type.
46
+ policy = field;
47
+ }
48
+ if (policy == nullptr) return nullptr;
49
+ // If we support this policy, then select it.
50
+ if (LoadBalancingPolicyRegistry::LoadBalancingPolicyExists(policy->key)) {
51
+ return policy;
52
+ }
53
+ }
54
+ return nullptr;
55
+ }
56
+
57
+ LoadBalancingPolicy::LoadBalancingPolicy(Args args)
30
58
  : InternallyRefCounted(&grpc_trace_lb_policy_refcount),
31
59
  combiner_(GRPC_COMBINER_REF(args.combiner, "lb_policy")),
32
60
  client_channel_factory_(args.client_channel_factory),
61
+ subchannel_pool_(std::move(args.subchannel_pool)),
33
62
  interested_parties_(grpc_pollset_set_create()),
34
63
  request_reresolution_(nullptr) {}
35
64
 
@@ -24,6 +24,7 @@
24
24
  #include "src/core/ext/filters/client_channel/client_channel_channelz.h"
25
25
  #include "src/core/ext/filters/client_channel/client_channel_factory.h"
26
26
  #include "src/core/ext/filters/client_channel/subchannel.h"
27
+ #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h"
27
28
  #include "src/core/lib/gprpp/abstract.h"
28
29
  #include "src/core/lib/gprpp/orphanable.h"
29
30
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
@@ -53,6 +54,8 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
53
54
  grpc_combiner* combiner = nullptr;
54
55
  /// Used to create channels and subchannels.
55
56
  grpc_client_channel_factory* client_channel_factory = nullptr;
57
+ /// Subchannel pool.
58
+ RefCountedPtr<SubchannelPoolInterface> subchannel_pool;
56
59
  /// Channel args from the resolver.
57
60
  /// Note that the LB policy gets the set of addresses from the
58
61
  /// GRPC_ARG_SERVER_ADDRESS_LIST channel arg.
@@ -74,6 +77,19 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
74
77
  /// Closure to run when pick is complete, if not completed synchronously.
75
78
  /// If null, pick will fail if a result is not available synchronously.
76
79
  grpc_closure* on_complete = nullptr;
80
+ // Callback set by lb policy to be notified of trailing metadata.
81
+ // The callback must be scheduled on grpc_schedule_on_exec_ctx.
82
+ grpc_closure* recv_trailing_metadata_ready = nullptr;
83
+ // The address that will be set to point to the original
84
+ // recv_trailing_metadata_ready callback, to be invoked by the LB
85
+ // policy's recv_trailing_metadata_ready callback when complete.
86
+ // Must be non-null if recv_trailing_metadata_ready is non-null.
87
+ grpc_closure** original_recv_trailing_metadata_ready = nullptr;
88
+ // If this is not nullptr, then the client channel will point it to the
89
+ // call's trailing metadata before invoking recv_trailing_metadata_ready.
90
+ // If this is nullptr, then the callback will still be called.
91
+ // The lb does not have ownership of the metadata.
92
+ grpc_metadata_batch** recv_trailing_metadata = nullptr;
77
93
  /// Will be set to the selected subchannel, or nullptr on failure or when
78
94
  /// the LB policy decides to drop the call.
79
95
  RefCountedPtr<ConnectedSubchannel> connected_subchannel;
@@ -163,6 +179,10 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
163
179
  GRPC_ERROR_NONE);
164
180
  }
165
181
 
182
+ /// Returns the JSON node of policy (with both policy name and config content)
183
+ /// given the JSON node of a LoadBalancingConfig array.
184
+ static grpc_json* ParseLoadBalancingConfig(const grpc_json* lb_config_array);
185
+
166
186
  /// Sets the re-resolution closure to \a request_reresolution.
167
187
  void SetReresolutionClosureLocked(grpc_closure* request_reresolution) {
168
188
  GPR_ASSERT(request_reresolution_ == nullptr);
@@ -171,12 +191,18 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
171
191
 
172
192
  grpc_pollset_set* interested_parties() const { return interested_parties_; }
173
193
 
194
+ // Callers that need their own reference can call the returned
195
+ // object's Ref() method.
196
+ SubchannelPoolInterface* subchannel_pool() const {
197
+ return subchannel_pool_.get();
198
+ }
199
+
174
200
  GRPC_ABSTRACT_BASE_CLASS
175
201
 
176
202
  protected:
177
203
  GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE
178
204
 
179
- explicit LoadBalancingPolicy(const Args& args);
205
+ explicit LoadBalancingPolicy(Args args);
180
206
  virtual ~LoadBalancingPolicy();
181
207
 
182
208
  grpc_combiner* combiner() const { return combiner_; }
@@ -204,6 +230,8 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
204
230
  grpc_combiner* combiner_;
205
231
  /// Client channel factory, used to create channels and subchannels.
206
232
  grpc_client_channel_factory* client_channel_factory_;
233
+ /// Subchannel pool.
234
+ RefCountedPtr<SubchannelPoolInterface> subchannel_pool_;
207
235
  /// Owned pointer to interested parties in load balancing decisions.
208
236
  grpc_pollset_set* interested_parties_;
209
237
  /// Callback to force a re-resolution.
@@ -31,7 +31,12 @@ class LoadBalancingPolicyFactory {
31
31
  public:
32
32
  /// Returns a new LB policy instance.
33
33
  virtual OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
34
- const LoadBalancingPolicy::Args& args) const GRPC_ABSTRACT;
34
+ LoadBalancingPolicy::Args args) const {
35
+ std::move(args); // Suppress clang-tidy complaint.
36
+ // The rest of this is copied from the GRPC_ABSTRACT macro.
37
+ gpr_log(GPR_ERROR, "Function marked GRPC_ABSTRACT was not implemented");
38
+ GPR_ASSERT(false);
39
+ }
35
40
 
36
41
  /// Returns the LB policy name that this factory provides.
37
42
  /// Caller does NOT take ownership of result.
@@ -84,14 +84,14 @@ void LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
84
84
 
85
85
  OrphanablePtr<LoadBalancingPolicy>
86
86
  LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
87
- const char* name, const LoadBalancingPolicy::Args& args) {
87
+ const char* name, LoadBalancingPolicy::Args args) {
88
88
  GPR_ASSERT(g_state != nullptr);
89
89
  // Find factory.
90
90
  LoadBalancingPolicyFactory* factory =
91
91
  g_state->GetLoadBalancingPolicyFactory(name);
92
92
  if (factory == nullptr) return nullptr; // Specified name not found.
93
93
  // Create policy via factory.
94
- return factory->CreateLoadBalancingPolicy(args);
94
+ return factory->CreateLoadBalancingPolicy(std::move(args));
95
95
  }
96
96
 
97
97
  bool LoadBalancingPolicyRegistry::LoadBalancingPolicyExists(const char* name) {
@@ -46,7 +46,7 @@ class LoadBalancingPolicyRegistry {
46
46
 
47
47
  /// Creates an LB policy of the type specified by \a name.
48
48
  static OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
49
- const char* name, const LoadBalancingPolicy::Args& args);
49
+ const char* name, LoadBalancingPolicy::Args args);
50
50
 
51
51
  /// Returns true if the LB policy factory specified by \a name exists in this
52
52
  /// registry.