PollingResolver: clean up the way that ChannelArgs are passed in (#32430)

pull/32495/head
Mark D. Roth 2 years ago committed by GitHub
parent f059259182
commit 78b2b35ad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
  2. 20
      src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
  3. 3
      src/core/ext/filters/client_channel/resolver/polling_resolver.cc
  4. 3
      src/core/ext/filters/client_channel/resolver/polling_resolver.h

@ -95,7 +95,7 @@ namespace {
class AresClientChannelDNSResolver : public PollingResolver {
public:
AresClientChannelDNSResolver(ResolverArgs args,
const ChannelArgs& channel_args);
Duration min_time_between_resolutions);
OrphanablePtr<Orphanable> StartRequest() override;
@ -205,14 +205,8 @@ class AresClientChannelDNSResolver : public PollingResolver {
};
AresClientChannelDNSResolver::AresClientChannelDNSResolver(
ResolverArgs args, const ChannelArgs& channel_args)
: PollingResolver(
std::move(args), channel_args,
std::max(Duration::Zero(),
channel_args
.GetDurationFromIntMillis(
GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS)
.value_or(Duration::Seconds(30))),
ResolverArgs args, Duration min_time_between_resolutions)
: PollingResolver(std::move(args), min_time_between_resolutions,
BackOff::Options()
.set_initial_backoff(Duration::Milliseconds(
GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * 1000))
@ -222,12 +216,15 @@ AresClientChannelDNSResolver::AresClientChannelDNSResolver(
GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)),
&grpc_trace_cares_resolver),
request_service_config_(
!channel_args.GetBool(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION)
!channel_args()
.GetBool(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION)
.value_or(true)),
enable_srv_queries_(channel_args.GetBool(GRPC_ARG_DNS_ENABLE_SRV_QUERIES)
enable_srv_queries_(channel_args()
.GetBool(GRPC_ARG_DNS_ENABLE_SRV_QUERIES)
.value_or(false)),
query_timeout_ms_(
std::max(0, channel_args.GetInt(GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS)
std::max(0, channel_args()
.GetInt(GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS)
.value_or(GRPC_DNS_ARES_DEFAULT_QUERY_TIMEOUT_MS))) {}
AresClientChannelDNSResolver::~AresClientChannelDNSResolver() {
@ -460,9 +457,13 @@ class AresClientChannelDNSResolverFactory : public ResolverFactory {
}
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
ChannelArgs channel_args = args.args;
return MakeOrphanable<AresClientChannelDNSResolver>(std::move(args),
channel_args);
Duration min_time_between_resolutions = std::max(
Duration::Zero(), args.args
.GetDurationFromIntMillis(
GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS)
.value_or(Duration::Seconds(30)));
return MakeOrphanable<AresClientChannelDNSResolver>(
std::move(args), min_time_between_resolutions);
}
};

@ -67,7 +67,7 @@ TraceFlag grpc_trace_dns_resolver(false, "dns_resolver");
class NativeClientChannelDNSResolver : public PollingResolver {
public:
NativeClientChannelDNSResolver(ResolverArgs args,
const ChannelArgs& channel_args);
Duration min_time_between_resolutions);
~NativeClientChannelDNSResolver() override;
OrphanablePtr<Orphanable> StartRequest() override;
@ -88,14 +88,8 @@ class NativeClientChannelDNSResolver : public PollingResolver {
};
NativeClientChannelDNSResolver::NativeClientChannelDNSResolver(
ResolverArgs args, const ChannelArgs& channel_args)
: PollingResolver(
std::move(args), channel_args,
std::max(Duration::Zero(),
channel_args
.GetDurationFromIntMillis(
GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS)
.value_or(Duration::Seconds(30))),
ResolverArgs args, Duration min_time_between_resolutions)
: PollingResolver(std::move(args), min_time_between_resolutions,
BackOff::Options()
.set_initial_backoff(Duration::Milliseconds(
GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * 1000))
@ -174,9 +168,13 @@ class NativeClientChannelDNSResolverFactory : public ResolverFactory {
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
if (!IsValidUri(args.uri)) return nullptr;
auto channel_args = args.args;
Duration min_time_between_resolutions = std::max(
Duration::Zero(), args.args
.GetDurationFromIntMillis(
GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS)
.value_or(Duration::Seconds(30)));
return MakeOrphanable<NativeClientChannelDNSResolver>(
std::move(args), std::move(channel_args));
std::move(args), min_time_between_resolutions);
}
};

@ -47,13 +47,12 @@ namespace grpc_core {
using ::grpc_event_engine::experimental::EventEngine;
PollingResolver::PollingResolver(ResolverArgs args,
const ChannelArgs& channel_args,
Duration min_time_between_resolutions,
BackOff::Options backoff_options,
TraceFlag* tracer)
: authority_(args.uri.authority()),
name_to_resolve_(absl::StripPrefix(args.uri.path(), "/")),
channel_args_(channel_args),
channel_args_(std::move(args.args)),
work_serializer_(std::move(args.work_serializer)),
result_handler_(std::move(args.result_handler)),
tracer_(tracer),

@ -44,8 +44,7 @@ namespace grpc_core {
// Implementations need only to implement StartRequest().
class PollingResolver : public Resolver {
public:
PollingResolver(ResolverArgs args, const ChannelArgs& channel_args,
Duration min_time_between_resolutions,
PollingResolver(ResolverArgs args, Duration min_time_between_resolutions,
BackOff::Options backoff_options, TraceFlag* tracer);
~PollingResolver() override;

Loading…
Cancel
Save