コード例 #1
0
int main(int argc, char **argv) {
  grpc_resolver_factory *ipv4, *ipv6;
  grpc_test_init(argc, argv);
  grpc_init();

  ipv4 = grpc_resolver_factory_lookup("ipv4");
  ipv6 = grpc_resolver_factory_lookup("ipv6");

  test_fails(ipv4, "ipv4:10.2.1.1");
  test_succeeds(ipv4, "ipv4:10.2.1.1:1234");
  test_succeeds(ipv4, "ipv4:10.2.1.1:1234,127.0.0.1:4321");
  test_fails(ipv4, "ipv4:10.2.1.1:123456");
  test_fails(ipv4, "ipv4:www.google.com");
  test_fails(ipv4, "ipv4:[");
  test_fails(ipv4, "ipv4://8.8.8.8/8.8.8.8:8888");

  test_fails(ipv6, "ipv6:[");
  test_fails(ipv6, "ipv6:[::]");
  test_succeeds(ipv6, "ipv6:[::]:1234");
  test_fails(ipv6, "ipv6:[::]:123456");
  test_fails(ipv6, "ipv6:www.google.com");

  grpc_resolver_factory_unref(ipv4);
  grpc_resolver_factory_unref(ipv6);
  grpc_shutdown();

  return 0;
}
コード例 #2
0
ファイル: resolver_registry.c プロジェクト: ifzz/grpc
void grpc_resolver_registry_shutdown(void) {
  int i;
  for (i = 0; i < g_number_of_resolvers; i++) {
    grpc_resolver_factory_unref(g_all_of_the_resolvers[i]);
  }
  gpr_free(g_default_resolver_prefix);
}
コード例 #3
0
ファイル: resolver_registry.c プロジェクト: wuyunhao/grpc
void grpc_resolver_registry_shutdown(void) {
    for (int i = 0; i < g_number_of_resolvers; i++) {
        grpc_resolver_factory_unref(g_all_of_the_resolvers[i]);
    }
    // FIXME(ctiller): this should live in grpc_resolver_registry_init,
    // however that would have the client_config plugin call this AFTER we start
    // registering resolvers from third party plugins, and so they'd never show
    // up.
    // We likely need some kind of dependency system for plugins.... what form
    // that takes is TBD.
    g_number_of_resolvers = 0;
}
コード例 #4
0
static grpc_resolver *create_resolver(const char *name) {
  grpc_resolver_factory *factory = grpc_resolver_factory_lookup("dns");
  grpc_uri *uri = grpc_uri_parse(name, 0);
  GPR_ASSERT(uri);
  grpc_resolver_args args;
  memset(&args, 0, sizeof(args));
  args.uri = uri;
  grpc_resolver *resolver =
      grpc_resolver_factory_create_resolver(factory, &args);
  grpc_resolver_factory_unref(factory);
  grpc_uri_destroy(uri);
  return resolver;
}
コード例 #5
0
ファイル: fake_resolver_test.c プロジェクト: makdharma/grpc
static grpc_resolver *build_fake_resolver(
    grpc_exec_ctx *exec_ctx, grpc_combiner *combiner,
    grpc_fake_resolver_response_generator *response_generator) {
  grpc_resolver_factory *factory = grpc_resolver_factory_lookup("test");
  grpc_arg generator_arg =
      grpc_fake_resolver_response_generator_arg(response_generator);
  grpc_resolver_args args;
  memset(&args, 0, sizeof(args));
  grpc_channel_args channel_args = {1, &generator_arg};
  args.args = &channel_args;
  args.combiner = combiner;
  grpc_resolver *resolver =
      grpc_resolver_factory_create_resolver(exec_ctx, factory, &args);
  grpc_resolver_factory_unref(factory);
  return resolver;
}
コード例 #6
0
ファイル: dns_resolver_test.c プロジェクト: wuyunhao/grpc
int main(int argc, char **argv) {
  grpc_resolver_factory *dns;
  grpc_test_init(argc, argv);
  grpc_init();

  dns = grpc_resolver_factory_lookup("dns");

  test_succeeds(dns, "dns:10.2.1.1");
  test_succeeds(dns, "dns:10.2.1.1:1234");
  test_succeeds(dns, "ipv4:www.google.com");
  test_fails(dns, "ipv4://8.8.8.8/8.8.8.8:8888");

  grpc_resolver_factory_unref(dns);
  grpc_shutdown();

  return 0;
}