Allow LB policy name to be matched in a case-insensitive manner.

pull/8617/head
Mark D. Roth 8 years ago
parent c19049c39d
commit 69f783dffc
  1. 8
      src/core/ext/client_channel/lb_policy_registry.c
  2. 4
      test/core/client_channel/lb_policies_test.c

@ -35,6 +35,8 @@
#include <string.h>
#include "src/core/lib/support/string.h"
#define MAX_POLICIES 10
static grpc_lb_policy_factory *g_all_of_the_lb_policies[MAX_POLICIES];
@ -52,8 +54,8 @@ void grpc_lb_policy_registry_shutdown(void) {
void grpc_register_lb_policy(grpc_lb_policy_factory *factory) {
int i;
for (i = 0; i < g_number_of_lb_policies; i++) {
GPR_ASSERT(0 != strcmp(factory->vtable->name,
g_all_of_the_lb_policies[i]->vtable->name));
GPR_ASSERT(0 != gpr_stricmp(factory->vtable->name,
g_all_of_the_lb_policies[i]->vtable->name));
}
GPR_ASSERT(g_number_of_lb_policies != MAX_POLICIES);
grpc_lb_policy_factory_ref(factory);
@ -66,7 +68,7 @@ static grpc_lb_policy_factory *lookup_factory(const char *name) {
if (name == NULL) return NULL;
for (i = 0; i < g_number_of_lb_policies; i++) {
if (0 == strcmp(name, g_all_of_the_lb_policies[i]->vtable->name)) {
if (0 == gpr_stricmp(name, g_all_of_the_lb_policies[i]->vtable->name)) {
return g_all_of_the_lb_policies[i];
}
}

@ -554,7 +554,7 @@ static grpc_channel *create_client(const servers_fixture *f) {
arg_array[0].value.integer = RETRY_TIMEOUT;
arg_array[1].type = GRPC_ARG_STRING;
arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
arg_array[1].value.string = "round_robin";
arg_array[1].value.string = "ROUND_ROBIN";
args.num_args = 2;
args.args = arg_array;
@ -669,7 +669,7 @@ static void test_get_channel_info() {
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
arg.key = GRPC_ARG_SERVICE_CONFIG;
arg.value.string = "{\"lb_policy_name\": \"round_robin\"}";
arg.value.string = "{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}";
grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, NULL);
grpc_channel_args_destroy(args);

Loading…
Cancel
Save