Exemplo n.º 1
0
Arquivo: init.c Projeto: cj525/grpc
void grpc_init(void) {
  int i;
  gpr_once_init(&g_basic_init, do_basic_init);

  gpr_mu_lock(&g_init_mu);
  if (++g_initializations == 1) {
    gpr_time_init();
    grpc_mdctx_global_init();
    grpc_lb_policy_registry_init(grpc_pick_first_lb_factory_create());
    grpc_register_lb_policy(grpc_pick_first_lb_factory_create());
    grpc_register_lb_policy(grpc_round_robin_lb_factory_create());
    grpc_resolver_registry_init(GRPC_DEFAULT_NAME_PREFIX);
    grpc_register_resolver_type(grpc_dns_resolver_factory_create());
    grpc_register_resolver_type(grpc_ipv4_resolver_factory_create());
    grpc_register_resolver_type(grpc_ipv6_resolver_factory_create());
#ifdef GPR_POSIX_SOCKET
    grpc_register_resolver_type(grpc_unix_resolver_factory_create());
#endif
    grpc_register_tracer("api", &grpc_api_trace);
    grpc_register_tracer("channel", &grpc_trace_channel);
    grpc_register_tracer("http", &grpc_http_trace);
    grpc_register_tracer("flowctl", &grpc_flowctl_trace);
    grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace);
    grpc_security_pre_init();
    grpc_iomgr_init();
    grpc_executor_init();
    grpc_tracer_init("GRPC_TRACE");
    /* Only initialize census if noone else has. */
    if (census_enabled() == CENSUS_FEATURE_NONE) {
      if (census_initialize(census_supported())) { /* enable all features. */
        gpr_log(GPR_ERROR, "Could not initialize census.");
      }
    }
    gpr_timers_global_init();
    grpc_cq_global_init();
    for (i = 0; i < g_number_of_plugins; i++) {
      if (g_all_of_the_plugins[i].init != NULL) {
        g_all_of_the_plugins[i].init();
      }
    }
  }
  gpr_mu_unlock(&g_init_mu);
  GRPC_API_TRACE("grpc_init(void)", 0, ());
}
Exemplo n.º 2
0
void grpc_lb_policy_pick_first_init() {
  grpc_register_lb_policy(pick_first_lb_factory_create());
}
Exemplo n.º 3
0
void grpc_lb_policy_round_robin_init() {
  grpc_register_lb_policy(round_robin_lb_factory_create());
  grpc_register_tracer("round_robin", &grpc_lb_round_robin_trace);
}