From fcf7ad692cbd98a75d7dba53acf0ac8739a9da5e Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 29 Mar 2016 21:55:34 -0700 Subject: Renamed subchannel_factory to client_channel_factory. Added the ability to create channels from client_channel_factory. This will be used by the grpclb code to create the channels to communicate with the LB servers. --- src/core/lib/client_config/README.md | 2 +- .../lib/client_config/client_channel_factory.c | 55 +++++++++++++++ .../lib/client_config/client_channel_factory.h | 78 ++++++++++++++++++++++ src/core/lib/client_config/resolver_factory.h | 4 +- src/core/lib/client_config/resolver_registry.c | 4 +- src/core/lib/client_config/resolver_registry.h | 2 +- .../lib/client_config/resolvers/dns_resolver.c | 13 ++-- .../client_config/resolvers/sockaddr_resolver.c | 12 ++-- .../client_config/resolvers/zookeeper_resolver.c | 12 ++-- src/core/lib/client_config/subchannel_factory.c | 49 -------------- src/core/lib/client_config/subchannel_factory.h | 66 ------------------ 11 files changed, 158 insertions(+), 139 deletions(-) create mode 100644 src/core/lib/client_config/client_channel_factory.c create mode 100644 src/core/lib/client_config/client_channel_factory.h delete mode 100644 src/core/lib/client_config/subchannel_factory.c delete mode 100644 src/core/lib/client_config/subchannel_factory.h (limited to 'src/core/lib/client_config') diff --git a/src/core/lib/client_config/README.md b/src/core/lib/client_config/README.md index fff7a5af5b..7024fd540d 100644 --- a/src/core/lib/client_config/README.md +++ b/src/core/lib/client_config/README.md @@ -40,7 +40,7 @@ decisions (for example, by avoiding disconnected backends). Configured sub-channels are fully setup to participate in the grpc data plane. Their behavior is specified by a set of grpc channel filters defined at their construction. To customize this behavior, resolvers build -grpc_subchannel_factory objects, which use the decorator pattern to customize +grpc_client_channel_factory objects, which use the decorator pattern to customize construction arguments for concrete grpc_subchannel instances. diff --git a/src/core/lib/client_config/client_channel_factory.c b/src/core/lib/client_config/client_channel_factory.c new file mode 100644 index 0000000000..c079ce09dd --- /dev/null +++ b/src/core/lib/client_config/client_channel_factory.c @@ -0,0 +1,55 @@ +/* + * + * Copyright 2015-2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/lib/client_config/client_channel_factory.h" + +void grpc_client_channel_factory_ref(grpc_client_channel_factory* factory) { + factory->vtable->ref(factory); +} + +void grpc_client_channel_factory_unref(grpc_exec_ctx* exec_ctx, + grpc_client_channel_factory* factory) { + factory->vtable->unref(exec_ctx, factory); +} + +grpc_subchannel* grpc_client_channel_factory_create_subchannel( + grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory, + grpc_subchannel_args* args) { + return factory->vtable->create_subchannel(exec_ctx, factory, args); +} + +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); +} diff --git a/src/core/lib/client_config/client_channel_factory.h b/src/core/lib/client_config/client_channel_factory.h new file mode 100644 index 0000000000..3dd9dfea12 --- /dev/null +++ b/src/core/lib/client_config/client_channel_factory.h @@ -0,0 +1,78 @@ +/* + * + * Copyright 2015-2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_LIB_CLIENT_CONFIG_CLIENT_CHANNEL_FACTORY_H +#define GRPC_CORE_LIB_CLIENT_CONFIG_CLIENT_CHANNEL_FACTORY_H + +#include +#include + +#include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/client_config/subchannel.h" + +typedef struct grpc_client_channel_factory grpc_client_channel_factory; +typedef struct grpc_client_channel_factory_vtable + grpc_client_channel_factory_vtable; + +/** Constructor for new configured channels. + Creating decorators around this type is encouraged to adapt behavior. */ +struct grpc_client_channel_factory { + const grpc_client_channel_factory_vtable *vtable; +}; + +struct grpc_client_channel_factory_vtable { + void (*ref)(grpc_client_channel_factory *factory); + void (*unref)(grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *factory); + 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); +}; + +void grpc_client_channel_factory_ref(grpc_client_channel_factory *factory); +void grpc_client_channel_factory_unref(grpc_exec_ctx *exec_ctx, + grpc_client_channel_factory *factory); + +/** Create a new grpc_subchannel */ +grpc_subchannel *grpc_client_channel_factory_create_subchannel( + grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *factory, + grpc_subchannel_args *args); + +/** 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); + +#endif /* GRPC_CORE_LIB_CLIENT_CONFIG_CLIENT_CHANNEL_FACTORY_H */ diff --git a/src/core/lib/client_config/resolver_factory.h b/src/core/lib/client_config/resolver_factory.h index 7765c3c844..91bdbfe01c 100644 --- a/src/core/lib/client_config/resolver_factory.h +++ b/src/core/lib/client_config/resolver_factory.h @@ -34,8 +34,8 @@ #ifndef GRPC_CORE_LIB_CLIENT_CONFIG_RESOLVER_FACTORY_H #define GRPC_CORE_LIB_CLIENT_CONFIG_RESOLVER_FACTORY_H +#include "src/core/lib/client_config/client_channel_factory.h" #include "src/core/lib/client_config/resolver.h" -#include "src/core/lib/client_config/subchannel_factory.h" #include "src/core/lib/client_config/uri_parser.h" typedef struct grpc_resolver_factory grpc_resolver_factory; @@ -49,7 +49,7 @@ struct grpc_resolver_factory { typedef struct grpc_resolver_args { grpc_uri *uri; - grpc_subchannel_factory *subchannel_factory; + grpc_client_channel_factory *client_channel_factory; } grpc_resolver_args; struct grpc_resolver_factory_vtable { diff --git a/src/core/lib/client_config/resolver_registry.c b/src/core/lib/client_config/resolver_registry.c index 29bd00c284..ff03041bc5 100644 --- a/src/core/lib/client_config/resolver_registry.c +++ b/src/core/lib/client_config/resolver_registry.c @@ -115,14 +115,14 @@ static grpc_resolver_factory *resolve_factory(const char *target, } grpc_resolver *grpc_resolver_create( - const char *target, grpc_subchannel_factory *subchannel_factory) { + const char *target, grpc_client_channel_factory *client_channel_factory) { grpc_uri *uri = NULL; grpc_resolver_factory *factory = resolve_factory(target, &uri); grpc_resolver *resolver; grpc_resolver_args args; memset(&args, 0, sizeof(args)); args.uri = uri; - args.subchannel_factory = subchannel_factory; + args.client_channel_factory = client_channel_factory; resolver = grpc_resolver_factory_create_resolver(factory, &args); grpc_uri_destroy(uri); return resolver; diff --git a/src/core/lib/client_config/resolver_registry.h b/src/core/lib/client_config/resolver_registry.h index 22289ca6bd..eec830bbcb 100644 --- a/src/core/lib/client_config/resolver_registry.h +++ b/src/core/lib/client_config/resolver_registry.h @@ -56,7 +56,7 @@ void grpc_register_resolver_type(grpc_resolver_factory *factory); return it. If a resolver factory was not found, return NULL. */ grpc_resolver *grpc_resolver_create( - const char *target, grpc_subchannel_factory *subchannel_factory); + const char *target, grpc_client_channel_factory *client_channel_factory); /** Given a target, return a (freshly allocated with gpr_malloc) string representing the default authority to pass from a client. */ diff --git a/src/core/lib/client_config/resolvers/dns_resolver.c b/src/core/lib/client_config/resolvers/dns_resolver.c index ab445730ad..078fda298a 100644 --- a/src/core/lib/client_config/resolvers/dns_resolver.c +++ b/src/core/lib/client_config/resolvers/dns_resolver.c @@ -60,7 +60,7 @@ typedef struct { /** default port to use */ char *default_port; /** subchannel factory */ - grpc_subchannel_factory *subchannel_factory; + grpc_client_channel_factory *client_channel_factory; /** load balancing policy name */ char *lb_policy_name; @@ -178,8 +178,9 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, memset(&args, 0, sizeof(args)); args.addr = (struct sockaddr *)(addresses->addrs[i].addr); args.addr_len = (size_t)addresses->addrs[i].len; - grpc_subchannel *subchannel = grpc_subchannel_factory_create_subchannel( - exec_ctx, r->subchannel_factory, &args); + grpc_subchannel *subchannel = + grpc_client_channel_factory_create_subchannel( + exec_ctx, r->client_channel_factory, &args); if (subchannel != NULL) { subchannels[naddrs++] = subchannel; } @@ -244,7 +245,7 @@ static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) { if (r->resolved_config) { grpc_client_config_unref(exec_ctx, r->resolved_config); } - grpc_subchannel_factory_unref(exec_ctx, r->subchannel_factory); + grpc_client_channel_factory_unref(exec_ctx, r->client_channel_factory); gpr_free(r->name); gpr_free(r->default_port); gpr_free(r->lb_policy_name); @@ -271,10 +272,10 @@ static grpc_resolver *dns_create(grpc_resolver_args *args, grpc_resolver_init(&r->base, &dns_resolver_vtable); r->name = gpr_strdup(path); r->default_port = gpr_strdup(default_port); - r->subchannel_factory = args->subchannel_factory; + r->client_channel_factory = args->client_channel_factory; gpr_backoff_init(&r->backoff_state, BACKOFF_MULTIPLIER, BACKOFF_JITTER, BACKOFF_MIN_SECONDS * 1000, BACKOFF_MAX_SECONDS * 1000); - grpc_subchannel_factory_ref(r->subchannel_factory); + grpc_client_channel_factory_ref(r->client_channel_factory); r->lb_policy_name = gpr_strdup(lb_policy_name); return &r->base; } diff --git a/src/core/lib/client_config/resolvers/sockaddr_resolver.c b/src/core/lib/client_config/resolvers/sockaddr_resolver.c index 66cddc3ed9..c2492a44b4 100644 --- a/src/core/lib/client_config/resolvers/sockaddr_resolver.c +++ b/src/core/lib/client_config/resolvers/sockaddr_resolver.c @@ -53,7 +53,7 @@ typedef struct { /** refcount */ gpr_refcount refs; /** subchannel factory */ - grpc_subchannel_factory *subchannel_factory; + grpc_client_channel_factory *client_channel_factory; /** load balancing policy name */ char *lb_policy_name; @@ -139,8 +139,8 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, memset(&args, 0, sizeof(args)); args.addr = (struct sockaddr *)&r->addrs[i]; args.addr_len = r->addrs_len[i]; - subchannels[i] = grpc_subchannel_factory_create_subchannel( - exec_ctx, r->subchannel_factory, &args); + subchannels[i] = grpc_client_channel_factory_create_subchannel( + exec_ctx, r->client_channel_factory, &args); } memset(&lb_policy_args, 0, sizeof(lb_policy_args)); lb_policy_args.subchannels = subchannels; @@ -159,7 +159,7 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) { sockaddr_resolver *r = (sockaddr_resolver *)gr; gpr_mu_destroy(&r->mu); - grpc_subchannel_factory_unref(exec_ctx, r->subchannel_factory); + grpc_client_channel_factory_unref(exec_ctx, r->client_channel_factory); gpr_free(r->addrs); gpr_free(r->addrs_len); gpr_free(r->lb_policy_name); @@ -337,8 +337,8 @@ static grpc_resolver *sockaddr_create( gpr_ref_init(&r->refs, 1); gpr_mu_init(&r->mu); grpc_resolver_init(&r->base, &sockaddr_resolver_vtable); - r->subchannel_factory = args->subchannel_factory; - grpc_subchannel_factory_ref(r->subchannel_factory); + r->client_channel_factory = args->client_channel_factory; + grpc_client_channel_factory_ref(r->client_channel_factory); return &r->base; } diff --git a/src/core/lib/client_config/resolvers/zookeeper_resolver.c b/src/core/lib/client_config/resolvers/zookeeper_resolver.c index 3bb0bbdf5c..4548344611 100644 --- a/src/core/lib/client_config/resolvers/zookeeper_resolver.c +++ b/src/core/lib/client_config/resolvers/zookeeper_resolver.c @@ -59,7 +59,7 @@ typedef struct { /** name to resolve */ char *name; /** subchannel factory */ - grpc_subchannel_factory *subchannel_factory; + grpc_client_channel_factory *client_channel_factory; /** load balancing policy name */ char *lb_policy_name; @@ -196,8 +196,8 @@ static void zookeeper_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, memset(&args, 0, sizeof(args)); args.addr = (struct sockaddr *)(addresses->addrs[i].addr); args.addr_len = addresses->addrs[i].len; - subchannels[i] = grpc_subchannel_factory_create_subchannel( - exec_ctx, r->subchannel_factory, &args); + subchannels[i] = grpc_client_channel_factory_create_subchannel( + exec_ctx, r->client_channel_factory, &args); } lb_policy_args.subchannels = subchannels; lb_policy_args.num_subchannels = addresses->naddrs; @@ -432,7 +432,7 @@ static void zookeeper_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) { if (r->resolved_config != NULL) { grpc_client_config_unref(exec_ctx, r->resolved_config); } - grpc_subchannel_factory_unref(exec_ctx, r->subchannel_factory); + grpc_client_channel_factory_unref(exec_ctx, r->client_channel_factory); gpr_free(r->name); gpr_free(r->lb_policy_name); gpr_free(r); @@ -462,8 +462,8 @@ static grpc_resolver *zookeeper_create(grpc_resolver_args *args, grpc_resolver_init(&r->base, &zookeeper_resolver_vtable); r->name = gpr_strdup(path); - r->subchannel_factory = args->subchannel_factory; - grpc_subchannel_factory_ref(r->subchannel_factory); + r->client_channel_factory = args->client_channel_factory; + grpc_client_channel_factory_ref(r->client_channel_factory); r->lb_policy_name = gpr_strdup(lb_policy_name); diff --git a/src/core/lib/client_config/subchannel_factory.c b/src/core/lib/client_config/subchannel_factory.c deleted file mode 100644 index 727a48a6c8..0000000000 --- a/src/core/lib/client_config/subchannel_factory.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright 2015-2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/lib/client_config/subchannel_factory.h" - -void grpc_subchannel_factory_ref(grpc_subchannel_factory* factory) { - factory->vtable->ref(factory); -} - -void grpc_subchannel_factory_unref(grpc_exec_ctx* exec_ctx, - grpc_subchannel_factory* factory) { - factory->vtable->unref(exec_ctx, factory); -} - -grpc_subchannel* grpc_subchannel_factory_create_subchannel( - grpc_exec_ctx* exec_ctx, grpc_subchannel_factory* factory, - grpc_subchannel_args* args) { - return factory->vtable->create_subchannel(exec_ctx, factory, args); -} diff --git a/src/core/lib/client_config/subchannel_factory.h b/src/core/lib/client_config/subchannel_factory.h deleted file mode 100644 index 3ba2f860fe..0000000000 --- a/src/core/lib/client_config/subchannel_factory.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Copyright 2015-2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_CORE_LIB_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H -#define GRPC_CORE_LIB_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H - -#include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/client_config/subchannel.h" - -typedef struct grpc_subchannel_factory grpc_subchannel_factory; -typedef struct grpc_subchannel_factory_vtable grpc_subchannel_factory_vtable; - -/** Constructor for new configured channels. - Creating decorators around this type is encouraged to adapt behavior. */ -struct grpc_subchannel_factory { - const grpc_subchannel_factory_vtable *vtable; -}; - -struct grpc_subchannel_factory_vtable { - void (*ref)(grpc_subchannel_factory *factory); - void (*unref)(grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *factory); - grpc_subchannel *(*create_subchannel)(grpc_exec_ctx *exec_ctx, - grpc_subchannel_factory *factory, - grpc_subchannel_args *args); -}; - -void grpc_subchannel_factory_ref(grpc_subchannel_factory *factory); -void grpc_subchannel_factory_unref(grpc_exec_ctx *exec_ctx, - grpc_subchannel_factory *factory); - -/** Create a new grpc_subchannel */ -grpc_subchannel *grpc_subchannel_factory_create_subchannel( - grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *factory, - grpc_subchannel_args *args); - -#endif /* GRPC_CORE_LIB_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H */ -- cgit v1.2.3 From a95f1b56ff5be69a3e5742d6a3f5e480cb46e275 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 31 Mar 2016 16:58:19 -0700 Subject: Increase initial connection timeout --- src/core/lib/client_config/subchannel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/lib/client_config') diff --git a/src/core/lib/client_config/subchannel.c b/src/core/lib/client_config/subchannel.c index 47c53a16ba..b4fd770e24 100644 --- a/src/core/lib/client_config/subchannel.c +++ b/src/core/lib/client_config/subchannel.c @@ -54,7 +54,7 @@ #define STRONG_REF_MASK (~(gpr_atm)((1 << INTERNAL_REF_BITS) - 1)) #define GRPC_SUBCHANNEL_MIN_CONNECT_TIMEOUT_SECONDS 20 -#define GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS 1 +#define GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS 2 #define GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER 1.6 #define GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS 120 #define GRPC_SUBCHANNEL_RECONNECT_JITTER 0.2 -- cgit v1.2.3 From 0b868c7c0713c93f2aa76460af1d03879256ba4d Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Fri, 1 Apr 2016 14:28:22 -0700 Subject: added grpc_client_channel_type for the creation of client channels --- .../transport/chttp2/client/insecure/channel_create.c | 7 ++++--- .../chttp2/client/secure/secure_channel_create.c | 7 ++++--- src/core/lib/client_config/client_channel_factory.c | 6 ++++-- src/core/lib/client_config/client_channel_factory.h | 16 ++++++++++++---- .../resolvers/dns_resolver_connectivity_test.c | 3 ++- test/core/client_config/resolvers/dns_resolver_test.c | 3 ++- .../client_config/resolvers/sockaddr_resolver_test.c | 3 ++- 7 files changed, 30 insertions(+), 15 deletions(-) (limited to 'src/core/lib/client_config') 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 */ diff --git a/test/core/client_config/resolvers/dns_resolver_connectivity_test.c b/test/core/client_config/resolvers/dns_resolver_connectivity_test.c index 1fd2d3d5ef..26c4e1d4ff 100644 --- a/test/core/client_config/resolvers/dns_resolver_connectivity_test.c +++ b/test/core/client_config/resolvers/dns_resolver_connectivity_test.c @@ -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); } diff --git a/test/core/client_config/resolvers/dns_resolver_test.c b/test/core/client_config/resolvers/dns_resolver_test.c index ce2da800bd..409d980ec1 100644 --- a/test/core/client_config/resolvers/dns_resolver_test.c +++ b/test/core/client_config/resolvers/dns_resolver_test.c @@ -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); } diff --git a/test/core/client_config/resolvers/sockaddr_resolver_test.c b/test/core/client_config/resolvers/sockaddr_resolver_test.c index 1e57d747f7..4eaf8ea2a4 100644 --- a/test/core/client_config/resolvers/sockaddr_resolver_test.c +++ b/test/core/client_config/resolvers/sockaddr_resolver_test.c @@ -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); } -- cgit v1.2.3 From f390c837d7edbe14430607fa7899e6ea08d631b3 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Fri, 1 Apr 2016 16:48:04 -0700 Subject: removed incorrect include --- src/core/lib/client_config/client_channel_factory.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/core/lib/client_config') diff --git a/src/core/lib/client_config/client_channel_factory.h b/src/core/lib/client_config/client_channel_factory.h index 83d743ddc3..0b71cd9bdb 100644 --- a/src/core/lib/client_config/client_channel_factory.h +++ b/src/core/lib/client_config/client_channel_factory.h @@ -34,7 +34,6 @@ #ifndef GRPC_CORE_LIB_CLIENT_CONFIG_CLIENT_CHANNEL_FACTORY_H #define GRPC_CORE_LIB_CLIENT_CONFIG_CLIENT_CHANNEL_FACTORY_H -#include #include #include "src/core/lib/channel/channel_stack.h" -- cgit v1.2.3