Skip to content
Snippets Groups Projects
Commit 0b868c7c authored by David Garcia Quintas's avatar David Garcia Quintas
Browse files

added grpc_client_channel_type for the creation of client channels

parent 86fcfcc7
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment