aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-04-01 14:28:22 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2016-04-01 14:28:22 -0700
commit0b868c7c0713c93f2aa76460af1d03879256ba4d (patch)
treeaba57825e91361af0fec28dc6565ba3103610646 /src
parent86fcfcc7b35cd4478603bb0a93711962b71b8c76 (diff)
added grpc_client_channel_type for the creation of client channels
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.c7
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.c7
-rw-r--r--src/core/lib/client_config/client_channel_factory.c6
-rw-r--r--src/core/lib/client_config/client_channel_factory.h16
4 files changed, 24 insertions, 12 deletions
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.c
index 024f4bc363..6083e0d22e 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.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");
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
index 210d9e4414..5d30805639 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
@@ -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");
diff --git a/src/core/lib/client_config/client_channel_factory.c b/src/core/lib/client_config/client_channel_factory.c
index 795776dcdd..d27b38d9f2 100644
--- a/src/core/lib/client_config/client_channel_factory.c
+++ b/src/core/lib/client_config/client_channel_factory.c
@@ -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);
}
diff --git a/src/core/lib/client_config/client_channel_factory.h b/src/core/lib/client_config/client_channel_factory.h
index 4975eecb1a..83d743ddc3 100644
--- a/src/core/lib/client_config/client_channel_factory.h
+++ b/src/core/lib/client_config/client_channel_factory.h
@@ -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 */