Example #1
0
static grpc_channel *client_channel_factory_create_channel(
    grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
    const char *target, grpc_client_channel_type type,
    const grpc_channel_args *args) {
    client_channel_factory *f = (client_channel_factory *)cc_factory;
    grpc_channel *channel =
        grpc_channel_create(exec_ctx, target, args, GRPC_CLIENT_CHANNEL, NULL);
    grpc_resolver *resolver = grpc_resolver_create(target, args);
    if (resolver != NULL) {
        grpc_client_channel_finish_initialization(
            exec_ctx, grpc_channel_get_channel_stack(channel), resolver, &f->base);
        GRPC_RESOLVER_UNREF(exec_ctx, resolver, "create");
    } else {
        GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel,
                                    "client_channel_factory_create_channel");
        channel = NULL;
    }
    return channel;
}
Example #2
0
static grpc_channel *client_channel_factory_create_channel(
    grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
    const char *target, grpc_client_channel_type type,
    grpc_channel_args *args) {
  client_channel_factory *f = (client_channel_factory *)cc_factory;
  grpc_channel_args *final_args = grpc_channel_args_merge(args, f->merge_args);
  grpc_channel *channel = grpc_channel_create(exec_ctx, target, final_args,
                                              GRPC_CLIENT_CHANNEL, NULL);
  grpc_channel_args_destroy(final_args);
  grpc_resolver *resolver = grpc_resolver_create(target);
  if (!resolver) {
    GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel,
                                "client_channel_factory_create_channel");
    return NULL;
  }

  grpc_client_channel_finish_initialization(
      exec_ctx, grpc_channel_get_channel_stack(channel), resolver, &f->base);
  GRPC_RESOLVER_UNREF(exec_ctx, resolver, "create_channel");

  return channel;
}