aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/resolver
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-09-08 14:14:39 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-09-08 14:14:39 -0700
commit0e48a9af490c5c48802ca1f3faab36e022cfca49 (patch)
treeddc6facb9c8b66ce0f12216a80c3088e0073a27a /src/core/ext/resolver
parenta587b4136976ab19f370b0ff18a2cd9f4c720cda (diff)
Move LB policy instantiation from resolvers into client_channel.
Diffstat (limited to 'src/core/ext/resolver')
-rw-r--r--src/core/ext/resolver/dns/native/dns_resolver.c27
-rw-r--r--src/core/ext/resolver/sockaddr/sockaddr_resolver.c18
2 files changed, 7 insertions, 38 deletions
diff --git a/src/core/ext/resolver/dns/native/dns_resolver.c b/src/core/ext/resolver/dns/native/dns_resolver.c
index 8fc10d98a8..78a996788d 100644
--- a/src/core/ext/resolver/dns/native/dns_resolver.c
+++ b/src/core/ext/resolver/dns/native/dns_resolver.c
@@ -37,7 +37,6 @@
#include <grpc/support/host_port.h>
#include <grpc/support/string_util.h>
-#include "src/core/ext/client_config/lb_policy_registry.h"
#include "src/core/ext/client_config/resolver_registry.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/timer.h"
@@ -58,8 +57,6 @@ typedef struct {
char *name;
/** default port to use */
char *default_port;
- /** subchannel factory */
- grpc_client_channel_factory *client_channel_factory;
/** load balancing policy name */
char *lb_policy_name;
@@ -166,29 +163,18 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
dns_resolver *r = arg;
grpc_resolver_result *result = NULL;
- grpc_lb_policy *lb_policy;
gpr_mu_lock(&r->mu);
GPR_ASSERT(r->resolving);
r->resolving = 0;
if (r->addresses != NULL) {
- grpc_lb_policy_args lb_policy_args;
- memset(&lb_policy_args, 0, sizeof(lb_policy_args));
- lb_policy_args.addresses = grpc_addresses_create(r->addresses->naddrs);
+ grpc_addresses *addresses = grpc_addresses_create(r->addresses->naddrs);
for (size_t i = 0; i < r->addresses->naddrs; ++i) {
- grpc_addresses_set_address(
- lb_policy_args.addresses, i, &r->addresses->addrs[i].addr,
- r->addresses->addrs[i].len, false /* is_balancer */);
+ grpc_addresses_set_address(addresses, i, &r->addresses->addrs[i].addr,
+ r->addresses->addrs[i].len,
+ false /* is_balancer */);
}
grpc_resolved_addresses_destroy(r->addresses);
- lb_policy_args.client_channel_factory = r->client_channel_factory;
- lb_policy =
- grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args);
- grpc_addresses_destroy(lb_policy_args.addresses);
- result = grpc_resolver_result_create();
- if (lb_policy != NULL) {
- grpc_resolver_result_set_lb_policy(result, lb_policy);
- GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "construction");
- }
+ result = grpc_resolver_result_create(addresses, r->lb_policy_name);
} else {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
@@ -249,7 +235,6 @@ static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
if (r->resolved_result) {
grpc_resolver_result_unref(exec_ctx, r->resolved_result);
}
- grpc_client_channel_factory_unref(exec_ctx, r->client_channel_factory);
gpr_free(r->name);
gpr_free(r->default_port);
gpr_free(r->lb_policy_name);
@@ -276,10 +261,8 @@ static grpc_resolver *dns_create(grpc_resolver_args *args,
grpc_resolver_init(&r->base, &dns_resolver_vtable);
r->name = gpr_strdup(path);
r->default_port = gpr_strdup(default_port);
- r->client_channel_factory = args->client_channel_factory;
gpr_backoff_init(&r->backoff_state, BACKOFF_MULTIPLIER, BACKOFF_JITTER,
BACKOFF_MIN_SECONDS * 1000, BACKOFF_MAX_SECONDS * 1000);
- grpc_client_channel_factory_ref(r->client_channel_factory);
r->lb_policy_name = gpr_strdup(lb_policy_name);
return &r->base;
}
diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
index 94d2f892eb..328c7cb6f9 100644
--- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
+++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
@@ -40,7 +40,6 @@
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
-#include "src/core/ext/client_config/lb_policy_registry.h"
#include "src/core/ext/client_config/parse_address.h"
#include "src/core/ext/client_config/resolver_registry.h"
#include "src/core/lib/iomgr/resolve_address.h"
@@ -52,8 +51,6 @@ typedef struct {
grpc_resolver base;
/** refcount */
gpr_refcount refs;
- /** subchannel factory */
- grpc_client_channel_factory *client_channel_factory;
/** load balancing policy name */
char *lb_policy_name;
@@ -122,17 +119,9 @@ static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
sockaddr_resolver *r) {
if (r->next_completion != NULL && !r->published) {
- grpc_resolver_result *result = grpc_resolver_result_create();
- grpc_lb_policy_args lb_policy_args;
- memset(&lb_policy_args, 0, sizeof(lb_policy_args));
- lb_policy_args.addresses = r->addresses;
- lb_policy_args.client_channel_factory = r->client_channel_factory;
- grpc_lb_policy *lb_policy =
- grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args);
- grpc_resolver_result_set_lb_policy(result, lb_policy);
- GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "sockaddr");
r->published = true;
- *r->target_result = result;
+ *r->target_result =
+ grpc_resolver_result_create(r->addresses, r->lb_policy_name);
grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL);
r->next_completion = NULL;
}
@@ -141,7 +130,6 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
sockaddr_resolver *r = (sockaddr_resolver *)gr;
gpr_mu_destroy(&r->mu);
- grpc_client_channel_factory_unref(exec_ctx, r->client_channel_factory);
grpc_addresses_destroy(r->addresses);
gpr_free(r->lb_policy_name);
gpr_free(r);
@@ -243,8 +231,6 @@ static grpc_resolver *sockaddr_create(
gpr_ref_init(&r->refs, 1);
gpr_mu_init(&r->mu);
grpc_resolver_init(&r->base, &sockaddr_resolver_vtable);
- r->client_channel_factory = args->client_channel_factory;
- grpc_client_channel_factory_ref(r->client_channel_factory);
return &r->base;
}