added grpc_client_channel_type for the creation of client channels

pull/6016/head
David Garcia Quintas 9 years ago
parent 86fcfcc7b3
commit 0b868c7c07
  1. 7
      src/core/ext/transport/chttp2/client/insecure/channel_create.c
  2. 7
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
  3. 6
      src/core/lib/client_config/client_channel_factory.c
  4. 16
      src/core/lib/client_config/client_channel_factory.h
  5. 3
      test/core/client_config/resolvers/dns_resolver_connectivity_test.c
  6. 3
      test/core/client_config/resolvers/dns_resolver_test.c
  7. 3
      test/core/client_config/resolvers/sockaddr_resolver_test.c

@ -181,7 +181,8 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
static grpc_channel *client_channel_factory_create_channel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
const char *target, grpc_channel_args *args) {
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,
@ -225,8 +226,8 @@ grpc_channel *grpc_insecure_channel_create(const char *target,
gpr_ref_init(&f->refs, 1);
f->merge_args = grpc_channel_args_copy(args);
grpc_channel *channel =
client_channel_factory_create_channel(&exec_ctx, &f->base, target, NULL);
grpc_channel *channel = client_channel_factory_create_channel(
&exec_ctx, &f->base, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR, NULL);
if (channel != NULL) {
f->master = channel;
GRPC_CHANNEL_INTERNAL_REF(f->master, "grpc_insecure_channel_create");

@ -242,7 +242,8 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
static grpc_channel *client_channel_factory_create_channel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
const char *target, grpc_channel_args *args) {
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);
@ -328,8 +329,8 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
"grpc_secure_channel_create");
f->security_connector = security_connector;
grpc_channel *channel =
client_channel_factory_create_channel(&exec_ctx, &f->base, target, NULL);
grpc_channel *channel = client_channel_factory_create_channel(
&exec_ctx, &f->base, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR, NULL);
if (channel != NULL) {
f->master = channel;
GRPC_CHANNEL_INTERNAL_REF(f->master, "grpc_secure_channel_create");

@ -50,6 +50,8 @@ grpc_subchannel* grpc_client_channel_factory_create_subchannel(
grpc_channel* grpc_client_channel_factory_create_channel(
grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory,
const char* target, grpc_channel_args* args) {
return factory->vtable->create_channel(exec_ctx, factory, target, args);
const char* target, grpc_client_channel_type type,
grpc_channel_args* args) {
return factory->vtable->create_client_channel(exec_ctx, factory, target, type,
args);
}

@ -44,6 +44,12 @@ typedef struct grpc_client_channel_factory grpc_client_channel_factory;
typedef struct grpc_client_channel_factory_vtable
grpc_client_channel_factory_vtable;
typedef enum {
GRPC_CLIENT_CHANNEL_TYPE_REGULAR, /** for the user-level regular calls */
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, /** for communication with a load
balancing service */
} grpc_client_channel_type;
/** Constructor for new configured channels.
Creating decorators around this type is encouraged to adapt behavior. */
struct grpc_client_channel_factory {
@ -56,9 +62,11 @@ struct grpc_client_channel_factory_vtable {
grpc_subchannel *(*create_subchannel)(grpc_exec_ctx *exec_ctx,
grpc_client_channel_factory *factory,
grpc_subchannel_args *args);
grpc_channel *(*create_channel)(grpc_exec_ctx *exec_ctx,
grpc_client_channel_factory *factory,
const char *target, grpc_channel_args *args);
grpc_channel *(*create_client_channel)(grpc_exec_ctx *exec_ctx,
grpc_client_channel_factory *factory,
const char *target,
grpc_client_channel_type type,
grpc_channel_args *args);
};
void grpc_client_channel_factory_ref(grpc_client_channel_factory *factory);
@ -73,6 +81,6 @@ grpc_subchannel *grpc_client_channel_factory_create_subchannel(
/** Create a new grpc_channel */
grpc_channel *grpc_client_channel_factory_create_channel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *factory,
const char *target, grpc_channel_args *args);
const char *target, grpc_client_channel_type type, grpc_channel_args *args);
#endif /* GRPC_CORE_LIB_CLIENT_CONFIG_CLIENT_CHANNEL_FACTORY_H */

@ -53,7 +53,8 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
static grpc_channel *client_channel_factory_create_channel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
const char *target, grpc_channel_args *args) {
const char *target, grpc_client_channel_type type,
grpc_channel_args *args) {
GPR_UNREACHABLE_CODE(return NULL);
}

@ -51,7 +51,8 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
static grpc_channel *client_channel_factory_create_channel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
const char *target, grpc_channel_args *args) {
const char *target, grpc_client_channel_type type,
grpc_channel_args *args) {
GPR_UNREACHABLE_CODE(return NULL);
}

@ -51,7 +51,8 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
static grpc_channel *client_channel_factory_create_channel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
const char *target, grpc_channel_args *args) {
const char *target, grpc_client_channel_type type,
grpc_channel_args *args) {
GPR_UNREACHABLE_CODE(return NULL);
}

Loading…
Cancel
Save