pull/36723/head
Craig Tiller 6 months ago
parent 60ac0d5b7f
commit 444f548312
  1. 62
      src/core/client_channel/client_channel.cc
  2. 13
      src/core/client_channel/client_channel.h

@ -123,10 +123,43 @@ extern TraceFlag grpc_client_channel_trace;
extern TraceFlag grpc_client_channel_call_trace;
extern TraceFlag grpc_client_channel_lb_call_trace;
//
// ClientChannel::ResolverResultHandler
//
class ClientChannel::ResolverResultHandler : public Resolver::ResultHandler {
public:
explicit ResolverResultHandler(RefCountedPtr<ClientChannel> client_channel)
: client_channel_(std::move(client_channel)) {}
~ResolverResultHandler() override {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: resolver shutdown complete",
client_channel_.get());
}
}
void ReportResult(Resolver::Result result) override
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_) {
client_channel_->OnResolverResultChangedLocked(std::move(result));
}
private:
RefCountedPtr<ClientChannel> client_channel_;
};
//
// ClientChannel::SubchannelWrapper
//
// This class is a wrapper for Subchannel that hides details of the
// channel's implementation (such as the connected subchannel) from the
// LB policy API.
//
// Note that no synchronization is needed here, because even if the
// underlying subchannel is shared between channels, this wrapper will only
// be used within one channel, so it will always be synchronized by the
// control plane work_serializer.
class ClientChannel::SubchannelWrapper
: public SubchannelInterfaceWithCallDestination {
public:
@ -190,35 +223,6 @@ class ClientChannel::SubchannelWrapper
data_watchers_ ABSL_GUARDED_BY(*client_channel_->work_serializer_);
};
//
// ClientChannel::ResolverResultHandler
//
class ClientChannel::ResolverResultHandler : public Resolver::ResultHandler {
public:
explicit ResolverResultHandler(RefCountedPtr<ClientChannel> client_channel)
: client_channel_(std::move(client_channel)) {}
~ResolverResultHandler() override {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: resolver shutdown complete",
client_channel_.get());
}
}
void ReportResult(Resolver::Result result) override
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_) {
client_channel_->OnResolverResultChangedLocked(std::move(result));
}
private:
RefCountedPtr<ClientChannel> client_channel_;
};
//
// ClientChannel::SubchannelWrapper
//
// This wrapper provides a bridge between the internal Subchannel API
// and the SubchannelInterface API that we expose to LB policies.
// It implements Subchannel::ConnectivityStateWatcherInterface and wraps

@ -39,16 +39,6 @@ namespace grpc_core {
class ClientChannel : public Channel {
public:
// This class is a wrapper for Subchannel that hides details of the
// channel's implementation (such as the connected subchannel) from the
// LB policy API.
//
// Note that no synchronization is needed here, because even if the
// underlying subchannel is shared between channels, this wrapper will only
// be used within one channel, so it will always be synchronized by the
// control plane work_serializer.
class SubchannelWrapper;
using PickerObservable =
Observable<RefCountedPtr<LoadBalancingPolicy::SubchannelPicker>>;
@ -132,8 +122,9 @@ class ClientChannel : public Channel {
}
private:
class ResolverResultHandler;
class ClientChannelControlHelper;
class ResolverResultHandler;
class SubchannelWrapper;
void CreateResolverLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(*work_serializer_);
void DestroyResolverAndLbPolicyLocked()

Loading…
Cancel
Save