|
|
|
@ -19,16 +19,12 @@ |
|
|
|
|
#include <string> |
|
|
|
|
|
|
|
|
|
#include "src/core/ext/filters/client_channel/lb_policy.h" |
|
|
|
|
#include "src/core/ext/filters/client_channel/lb_policy_registry.h" |
|
|
|
|
#include "src/core/lib/channel/channel_args.h" |
|
|
|
|
#include "src/core/lib/channel/channelz.h" |
|
|
|
|
#include "src/core/lib/debug/trace.h" |
|
|
|
|
#include "src/core/lib/gprpp/orphanable.h" |
|
|
|
|
#include "src/core/lib/gprpp/ref_counted_ptr.h" |
|
|
|
|
#include "src/core/lib/iomgr/closure.h" |
|
|
|
|
#include "src/core/lib/iomgr/combiner.h" |
|
|
|
|
#include "src/core/lib/iomgr/error.h" |
|
|
|
|
#include "src/core/lib/iomgr/pollset_set.h" |
|
|
|
|
#include "src/core/lib/json/json.h" |
|
|
|
|
#include "src/core/lib/transport/connectivity_state.h" |
|
|
|
|
|
|
|
|
@ -37,26 +33,13 @@ |
|
|
|
|
|
|
|
|
|
namespace grpc_core { |
|
|
|
|
|
|
|
|
|
extern TraceFlag grpc_trace_forwarding_lb; |
|
|
|
|
|
|
|
|
|
// A minimal forwarding class to avoid implementing a standalone test LB.
|
|
|
|
|
class ForwardingLoadBalancingPolicy : public LoadBalancingPolicy { |
|
|
|
|
public: |
|
|
|
|
ForwardingLoadBalancingPolicy(const Args& args, |
|
|
|
|
const std::string& delegate_policy_name) |
|
|
|
|
: LoadBalancingPolicy(args) { |
|
|
|
|
delegate_ = |
|
|
|
|
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy( |
|
|
|
|
delegate_policy_name.c_str(), args); |
|
|
|
|
grpc_pollset_set_add_pollset_set(delegate_->interested_parties(), |
|
|
|
|
interested_parties()); |
|
|
|
|
// Give re-resolution closure to delegate.
|
|
|
|
|
GRPC_CLOSURE_INIT(&on_delegate_request_reresolution_, |
|
|
|
|
OnDelegateRequestReresolutionLocked, this, |
|
|
|
|
grpc_combiner_scheduler(combiner())); |
|
|
|
|
Ref().release(); // held by callback.
|
|
|
|
|
delegate_->SetReresolutionClosureLocked(&on_delegate_request_reresolution_); |
|
|
|
|
} |
|
|
|
|
const std::string& delegate_policy_name); |
|
|
|
|
|
|
|
|
|
~ForwardingLoadBalancingPolicy() override; |
|
|
|
|
|
|
|
|
|
const char* name() const override { return delegate_->name(); } |
|
|
|
|
|
|
|
|
@ -108,17 +91,7 @@ class ForwardingLoadBalancingPolicy : public LoadBalancingPolicy { |
|
|
|
|
void ShutdownLocked() override { delegate_.reset(); } |
|
|
|
|
|
|
|
|
|
static void OnDelegateRequestReresolutionLocked(void* arg, |
|
|
|
|
grpc_error* error) { |
|
|
|
|
ForwardingLoadBalancingPolicy* self = |
|
|
|
|
static_cast<ForwardingLoadBalancingPolicy*>(arg); |
|
|
|
|
if (error != GRPC_ERROR_NONE || self->delegate_ == nullptr) { |
|
|
|
|
self->Unref(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
self->TryReresolutionLocked(&grpc_trace_forwarding_lb, GRPC_ERROR_NONE); |
|
|
|
|
self->delegate_->SetReresolutionClosureLocked( |
|
|
|
|
&self->on_delegate_request_reresolution_); |
|
|
|
|
} |
|
|
|
|
grpc_error* error); |
|
|
|
|
|
|
|
|
|
OrphanablePtr<LoadBalancingPolicy> delegate_; |
|
|
|
|
grpc_closure on_delegate_request_reresolution_; |
|
|
|
|