Make plugin registries work

pull/6000/head
Craig Tiller 9 years ago
parent 04b7ca8d5c
commit fb43385204
  1. 9
      BUILD
  2. 3
      Makefile
  3. 1
      binding.gyp
  4. 4
      build.yaml
  5. 2
      config.m4
  6. 5
      gRPC.podspec
  7. 3
      grpc.gemspec
  8. 3
      package.json
  9. 3
      package.xml
  10. 32
      src/core/ext/lb_policy/pick_first/pick_first.c
  11. 43
      src/core/ext/lb_policy/pick_first/pick_first.h
  12. 29
      src/core/ext/lb_policy/round_robin/round_robin.c
  13. 46
      src/core/ext/lb_policy/round_robin/round_robin.h
  14. 5
      src/core/lib/surface/init.c
  15. 14
      src/core/plugin_registry/grpc_plugin_registry.c
  16. 14
      src/core/plugin_registry/grpc_unsecure_plugin_registry.c
  17. 1
      src/python/grpcio/grpc_core_dependencies.py
  18. 14
      templates/src/core/plugin_registry.template
  19. 3
      test/core/client_config/lb_policies_test.c
  20. 20
      tools/buildgen/plugins/expand_filegroups.py
  21. 3
      tools/doxygen/Doxyfile.core.internal
  22. 14
      tools/run_tests/sources_and_headers.json
  23. 4
      vsprojects/vcxproj/grpc/grpc.vcxproj
  24. 12
      vsprojects/vcxproj/grpc/grpc.vcxproj.filters
  25. 4
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
  26. 12
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters

@ -159,8 +159,6 @@ cc_library(
srcs = [
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/pick_first/pick_first.h",
"src/core/ext/lb_policy/round_robin/round_robin.h",
"src/core/ext/transport/chttp2/transport/alpn.h",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",
@ -459,6 +457,7 @@ cc_library(
"src/core/lib/tsi/fake_transport_security.c",
"src/core/lib/tsi/ssl_transport_security.c",
"src/core/lib/tsi/transport_security.c",
"src/core/plugin_registry/grpc_plugin_registry.c",
"third_party/nanopb/pb_common.c",
"third_party/nanopb/pb_decode.c",
"third_party/nanopb/pb_encode.c",
@ -534,8 +533,6 @@ cc_library(
srcs = [
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/pick_first/pick_first.h",
"src/core/ext/lb_policy/round_robin/round_robin.h",
"src/core/ext/transport/chttp2/transport/alpn.h",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",
@ -800,6 +797,7 @@ cc_library(
"src/core/lib/transport/static_metadata.c",
"src/core/lib/transport/transport.c",
"src/core/lib/transport/transport_op_string.c",
"src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
"third_party/nanopb/pb_common.c",
"third_party/nanopb/pb_decode.c",
"third_party/nanopb/pb_encode.c",
@ -1521,6 +1519,7 @@ objc_library(
"src/core/lib/tsi/fake_transport_security.c",
"src/core/lib/tsi/ssl_transport_security.c",
"src/core/lib/tsi/transport_security.c",
"src/core/plugin_registry/grpc_plugin_registry.c",
"third_party/nanopb/pb_common.c",
"third_party/nanopb/pb_decode.c",
"third_party/nanopb/pb_encode.c",
@ -1541,8 +1540,6 @@ objc_library(
"include/grpc/status.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/pick_first/pick_first.h",
"src/core/ext/lb_policy/round_robin/round_robin.h",
"src/core/ext/transport/chttp2/transport/alpn.h",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",

@ -2581,6 +2581,7 @@ LIBGRPC_SRC = \
src/core/lib/tsi/fake_transport_security.c \
src/core/lib/tsi/ssl_transport_security.c \
src/core/lib/tsi/transport_security.c \
src/core/plugin_registry/grpc_plugin_registry.c \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
@ -2922,6 +2923,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/transport/static_metadata.c \
src/core/lib/transport/transport.c \
src/core/lib/transport/transport_op_string.c \
src/core/plugin_registry/grpc_unsecure_plugin_registry.c \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
@ -13492,6 +13494,7 @@ src/core/lib/surface/init_secure.c: $(OPENSSL_DEP)
src/core/lib/tsi/fake_transport_security.c: $(OPENSSL_DEP)
src/core/lib/tsi/ssl_transport_security.c: $(OPENSSL_DEP)
src/core/lib/tsi/transport_security.c: $(OPENSSL_DEP)
src/core/plugin_registry/grpc_plugin_registry.c: $(OPENSSL_DEP)
src/cpp/client/secure_credentials.cc: $(OPENSSL_DEP)
src/cpp/common/auth_property_iterator.cc: $(OPENSSL_DEP)
src/cpp/common/secure_auth_context.cc: $(OPENSSL_DEP)

@ -719,6 +719,7 @@
'src/core/lib/tsi/fake_transport_security.c',
'src/core/lib/tsi/ssl_transport_security.c',
'src/core/lib/tsi/transport_security.c',
'src/core/plugin_registry/grpc_plugin_registry.c',
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',

@ -468,16 +468,12 @@ filegroups:
uses:
- grpc_base
- name: grpc_lb_policy_pick_first
headers:
- src/core/ext/lb_policy/pick_first/pick_first.h
src:
- src/core/ext/lb_policy/pick_first/pick_first.c
plugin: grpc_lb_policy_pick_first
uses:
- grpc_base
- name: grpc_lb_policy_round_robin
headers:
- src/core/ext/lb_policy/round_robin/round_robin.h
src:
- src/core/ext/lb_policy/round_robin/round_robin.c
plugin: grpc_lb_policy_round_robin

@ -241,6 +241,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/tsi/fake_transport_security.c \
src/core/lib/tsi/ssl_transport_security.c \
src/core/lib/tsi/transport_security.c \
src/core/plugin_registry/grpc_plugin_registry.c \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
@ -570,6 +571,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/surface)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/transport)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/tsi)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/plugin_registry)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/aes)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/asn1)

@ -163,8 +163,6 @@ Pod::Spec.new do |s|
'src/core/lib/support/wrap_memcpy.c',
'src/core/ext/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h',
'src/core/ext/lb_policy/pick_first/pick_first.h',
'src/core/ext/lb_policy/round_robin/round_robin.h',
'src/core/ext/transport/chttp2/transport/alpn.h',
'src/core/ext/transport/chttp2/transport/bin_encoder.h',
'src/core/ext/transport/chttp2/transport/chttp2_transport.h',
@ -476,6 +474,7 @@ Pod::Spec.new do |s|
'src/core/lib/tsi/fake_transport_security.c',
'src/core/lib/tsi/ssl_transport_security.c',
'src/core/lib/tsi/transport_security.c',
'src/core/plugin_registry/grpc_plugin_registry.c',
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c'
@ -494,8 +493,6 @@ Pod::Spec.new do |s|
'src/core/lib/support/tmpfile.h',
'src/core/ext/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h',
'src/core/ext/lb_policy/pick_first/pick_first.h',
'src/core/ext/lb_policy/round_robin/round_robin.h',
'src/core/ext/transport/chttp2/transport/alpn.h',
'src/core/ext/transport/chttp2/transport/bin_encoder.h',
'src/core/ext/transport/chttp2/transport/chttp2_transport.h',

@ -159,8 +159,6 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/status.h )
s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.h )
s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h )
s.files += %w( src/core/ext/lb_policy/pick_first/pick_first.h )
s.files += %w( src/core/ext/lb_policy/round_robin/round_robin.h )
s.files += %w( src/core/ext/transport/chttp2/transport/alpn.h )
s.files += %w( src/core/ext/transport/chttp2/transport/bin_encoder.h )
s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_transport.h )
@ -459,6 +457,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/tsi/fake_transport_security.c )
s.files += %w( src/core/lib/tsi/ssl_transport_security.c )
s.files += %w( src/core/lib/tsi/transport_security.c )
s.files += %w( src/core/plugin_registry/grpc_plugin_registry.c )
s.files += %w( third_party/nanopb/pb_common.c )
s.files += %w( third_party/nanopb/pb_decode.c )
s.files += %w( third_party/nanopb/pb_encode.c )

@ -102,8 +102,6 @@
"include/grpc/status.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/pick_first/pick_first.h",
"src/core/ext/lb_policy/round_robin/round_robin.h",
"src/core/ext/transport/chttp2/transport/alpn.h",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",
@ -402,6 +400,7 @@
"src/core/lib/tsi/fake_transport_security.c",
"src/core/lib/tsi/ssl_transport_security.c",
"src/core/lib/tsi/transport_security.c",
"src/core/plugin_registry/grpc_plugin_registry.c",
"third_party/nanopb/pb_common.c",
"third_party/nanopb/pb_decode.c",
"third_party/nanopb/pb_encode.c",

@ -163,8 +163,6 @@
<file baseinstalldir="/" name="include/grpc/status.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/load_balancer_api.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/pick_first/pick_first.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/lb_policy/round_robin/round_robin.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/alpn.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/bin_encoder.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/chttp2_transport.h" role="src" />
@ -463,6 +461,7 @@
<file baseinstalldir="/" name="src/core/lib/tsi/fake_transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/tsi/ssl_transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/tsi/transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/plugin_registry/grpc_plugin_registry.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_common.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_decode.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_encode.c" role="src" />

@ -31,12 +31,10 @@
*
*/
#include "src/core/ext/lb_policy/pick_first/pick_first.h"
#include "src/core/lib/client_config/lb_policy_factory.h"
#include <string.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/client_config/lb_policy_registry.h"
#include "src/core/lib/transport/connectivity_state.h"
typedef struct pending_pick {
@ -78,7 +76,7 @@ typedef struct {
#define GET_SELECTED(p) \
((grpc_connected_subchannel *)gpr_atm_acq_load(&(p)->selected))
void pf_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static void pf_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
grpc_connected_subchannel *selected = GET_SELECTED(p);
size_t i;
@ -95,7 +93,7 @@ void pf_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
gpr_free(p);
}
void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
pending_pick *pp;
grpc_connected_subchannel *selected;
@ -162,7 +160,7 @@ static void start_picking(grpc_exec_ctx *exec_ctx, pick_first_lb_policy *p) {
&p->connectivity_changed);
}
void pf_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static void pf_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
gpr_mu_lock(&p->mu);
if (!p->started_picking) {
@ -171,9 +169,10 @@ void pf_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
gpr_mu_unlock(&p->mu);
}
int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_pollset *pollset,
grpc_metadata_batch *initial_metadata,
grpc_connected_subchannel **target, grpc_closure *on_complete) {
static int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_pollset *pollset, grpc_metadata_batch *initial_metadata,
grpc_connected_subchannel **target,
grpc_closure *on_complete) {
pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
pending_pick *pp;
@ -356,7 +355,8 @@ static grpc_connectivity_state pf_check_connectivity(grpc_exec_ctx *exec_ctx,
return st;
}
void pf_notify_on_state_change(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
static void pf_notify_on_state_change(grpc_exec_ctx *exec_ctx,
grpc_lb_policy *pol,
grpc_connectivity_state *current,
grpc_closure *notify) {
pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
@ -366,7 +366,7 @@ void pf_notify_on_state_change(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
gpr_mu_unlock(&p->mu);
}
void pf_ping_one(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
static void pf_ping_one(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_closure *closure) {
pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
grpc_connected_subchannel *selected = GET_SELECTED(p);
@ -416,6 +416,14 @@ static const grpc_lb_policy_factory_vtable pick_first_factory_vtable = {
static grpc_lb_policy_factory pick_first_lb_policy_factory = {
&pick_first_factory_vtable};
grpc_lb_policy_factory *grpc_pick_first_lb_factory_create() {
static grpc_lb_policy_factory *pick_first_lb_factory_create() {
return &pick_first_lb_policy_factory;
}
/* Plugin registration */
void grpc_lb_policy_pick_first_init() {
grpc_lb_policy_registry_init(pick_first_lb_factory_create());
}
void grpc_lb_policy_pick_first_shutdown() {}

@ -1,43 +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_EXT_LB_POLICY_PICK_FIRST_PICK_FIRST_H
#define GRPC_CORE_EXT_LB_POLICY_PICK_FIRST_PICK_FIRST_H
#include "src/core/lib/client_config/lb_policy_factory.h"
/** Returns a load balancing factory for the pick first policy, which picks up
* the first subchannel from \a subchannels to succesfully connect */
grpc_lb_policy_factory *grpc_pick_first_lb_factory_create();
#endif /* GRPC_CORE_EXT_LB_POLICY_PICK_FIRST_PICK_FIRST_H */

@ -31,11 +31,12 @@
*
*/
#include "src/core/ext/lb_policy/round_robin/round_robin.h"
#include <string.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/client_config/lb_policy_registry.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/transport/connectivity_state.h"
typedef struct round_robin_lb_policy round_robin_lb_policy;
@ -199,7 +200,7 @@ static void remove_disconnected_sc_locked(round_robin_lb_policy *p,
gpr_free(node);
}
void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
size_t i;
ready_list *elem;
@ -226,7 +227,7 @@ void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
gpr_free(p);
}
void rr_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static void rr_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
pending_pick *pp;
size_t i;
@ -291,7 +292,7 @@ static void start_picking(grpc_exec_ctx *exec_ctx, round_robin_lb_policy *p) {
}
}
void rr_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static void rr_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
gpr_mu_lock(&p->mu);
if (!p->started_picking) {
@ -300,9 +301,10 @@ void rr_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
gpr_mu_unlock(&p->mu);
}
int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_pollset *pollset,
grpc_metadata_batch *initial_metadata,
grpc_connected_subchannel **target, grpc_closure *on_complete) {
static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_pollset *pollset, grpc_metadata_batch *initial_metadata,
grpc_connected_subchannel **target,
grpc_closure *on_complete) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
pending_pick *pp;
ready_list *selected;
@ -537,6 +539,15 @@ static const grpc_lb_policy_factory_vtable round_robin_factory_vtable = {
static grpc_lb_policy_factory round_robin_lb_policy_factory = {
&round_robin_factory_vtable};
grpc_lb_policy_factory *grpc_round_robin_lb_factory_create() {
static grpc_lb_policy_factory *round_robin_lb_factory_create() {
return &round_robin_lb_policy_factory;
}
/* Plugin registration */
void grpc_lb_policy_round_robin_init() {
grpc_lb_policy_registry_init(round_robin_lb_factory_create());
grpc_register_tracer("round_robin", &grpc_lb_round_robin_trace);
}
void grpc_lb_policy_round_robin_shutdown() {}

@ -1,46 +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_EXT_LB_POLICY_ROUND_ROBIN_ROUND_ROBIN_H
#define GRPC_CORE_EXT_LB_POLICY_ROUND_ROBIN_ROUND_ROBIN_H
#include "src/core/lib/client_config/lb_policy.h"
extern int grpc_lb_round_robin_trace;
#include "src/core/lib/client_config/lb_policy_factory.h"
/** Returns a load balancing factory for the round robin policy */
grpc_lb_policy_factory *grpc_round_robin_lb_factory_create();
#endif /* GRPC_CORE_EXT_LB_POLICY_ROUND_ROBIN_ROUND_ROBIN_H */

@ -48,8 +48,6 @@
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/channel/http_client_filter.h"
#include "src/core/lib/channel/http_server_filter.h"
#include "src/core/ext/lb_policy/pick_first/pick_first.h"
#include "src/core/ext/lb_policy/round_robin/round_robin.h"
#include "src/core/lib/client_config/lb_policy_registry.h"
#include "src/core/lib/client_config/resolver_registry.h"
#include "src/core/lib/client_config/resolvers/dns_resolver.h"
@ -165,9 +163,6 @@ void grpc_init(void) {
gpr_time_init();
grpc_mdctx_global_init();
grpc_channel_init_init();
grpc_lb_policy_registry_init(grpc_pick_first_lb_factory_create());
grpc_register_lb_policy(grpc_pick_first_lb_factory_create());
grpc_register_lb_policy(grpc_round_robin_lb_factory_create());
grpc_resolver_registry_init(GRPC_DEFAULT_NAME_PREFIX);
grpc_register_resolver_type(grpc_dns_resolver_factory_create());
grpc_register_resolver_type(grpc_ipv4_resolver_factory_create());

@ -30,3 +30,17 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/grpc.h>
extern void grpc_lb_policy_pick_first_init(void);
extern void grpc_lb_policy_pick_first_shutdown(void);
extern void grpc_lb_policy_round_robin_init(void);
extern void grpc_lb_policy_round_robin_shutdown(void);
void grpc_register_built_in_plugins(void) {
grpc_register_plugin(grpc_lb_policy_pick_first_init,
grpc_lb_policy_pick_first_shutdown);
grpc_register_plugin(grpc_lb_policy_round_robin_init,
grpc_lb_policy_round_robin_shutdown);
}

@ -30,3 +30,17 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/grpc.h>
extern void grpc_lb_policy_pick_first_init(void);
extern void grpc_lb_policy_pick_first_shutdown(void);
extern void grpc_lb_policy_round_robin_init(void);
extern void grpc_lb_policy_round_robin_shutdown(void);
void grpc_register_built_in_plugins(void) {
grpc_register_plugin(grpc_lb_policy_pick_first_init,
grpc_lb_policy_pick_first_shutdown);
grpc_register_plugin(grpc_lb_policy_round_robin_init,
grpc_lb_policy_round_robin_shutdown);
}

@ -235,6 +235,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/tsi/fake_transport_security.c',
'src/core/lib/tsi/ssl_transport_security.c',
'src/core/lib/tsi/transport_security.c',
'src/core/plugin_registry/grpc_plugin_registry.c',
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',

@ -36,3 +36,17 @@ template: |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/grpc.h>
%for plugin in selected.plugins:
extern void ${plugin}_init(void);
extern void ${plugin}_shutdown(void);
%endfor
void grpc_register_built_in_plugins(void) {
%for plugin in selected.plugins:
grpc_register_plugin(${plugin}_init,
${plugin}_shutdown);
%endfor
}

@ -43,7 +43,6 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/client_channel.h"
#include "src/core/ext/lb_policy/round_robin/round_robin.h"
#include "src/core/lib/client_config/lb_policy_registry.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/channel.h"
@ -880,7 +879,7 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
grpc_lb_round_robin_trace = 1;
grpc_tracer_set_enabled("round_robin", 1);
GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", NULL) ==
NULL);

@ -75,11 +75,20 @@ def mako_plugin(dictionary):
todo.append(cur)
else:
skips = 0
assert 'plugins' not in cur
plugins = []
for uses in cur.get('uses', []):
for plugin in filegroups[uses]['plugins']:
if plugin not in plugins:
plugins.append(plugin)
for lst in FILEGROUP_LISTS:
vals = cur.get(lst, [])
vals.extend(filegroups[uses].get(lst, []))
cur[lst] = vals
cur_plugin_name = cur.get('plugin')
if cur_plugin_name:
plugins.append(cur_plugin_name)
cur['plugins'] = plugins
filegroups[cur['name']] = cur
# the above expansion can introduce duplicate filenames: contract them here
@ -88,13 +97,20 @@ def mako_plugin(dictionary):
fg[lst] = sorted(list(set(fg.get(lst, []))))
for lib in libs:
assert 'plugins' not in lib
plugins = []
for fg_name in lib.get('filegroups', []):
fg = filegroups[fg_name]
for plugin in fg['plugins']:
if plugin not in plugins:
plugins.append(plugin)
for lst in FILEGROUP_LISTS:
vals = lib.get(lst, [])
vals.extend(fg.get(lst, []))
lib[lst] = vals
lib['plugins'] = plugins
if lib.get('generate_plugin_registry', False):
lib['src'].append('src/core/plugin_registry/%s_plugin_registry.c' %
lib['name'])
for lst in FILEGROUP_LISTS:
lib[lst] = sorted(list(set(lib.get(lst, []))))

@ -775,8 +775,6 @@ include/grpc/impl/codegen/status.h \
include/grpc/status.h \
src/core/ext/lb_policy/grpclb/load_balancer_api.h \
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h \
src/core/ext/lb_policy/pick_first/pick_first.h \
src/core/ext/lb_policy/round_robin/round_robin.h \
src/core/ext/transport/chttp2/transport/alpn.h \
src/core/ext/transport/chttp2/transport/bin_encoder.h \
src/core/ext/transport/chttp2/transport/chttp2_transport.h \
@ -1075,6 +1073,7 @@ src/core/lib/transport/transport_op_string.c \
src/core/lib/tsi/fake_transport_security.c \
src/core/lib/tsi/ssl_transport_security.c \
src/core/lib/tsi/transport_security.c \
src/core/plugin_registry/grpc_plugin_registry.c \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \

@ -3926,8 +3926,6 @@
"include/grpc/status.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/pick_first/pick_first.h",
"src/core/ext/lb_policy/round_robin/round_robin.h",
"src/core/ext/transport/chttp2/transport/alpn.h",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",
@ -4087,9 +4085,7 @@
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/pick_first/pick_first.c",
"src/core/ext/lb_policy/pick_first/pick_first.h",
"src/core/ext/lb_policy/round_robin/round_robin.c",
"src/core/ext/lb_policy/round_robin/round_robin.h",
"src/core/ext/transport/chttp2/client/insecure/channel_create.c",
"src/core/ext/transport/chttp2/client/secure/secure_channel_create.c",
"src/core/ext/transport/chttp2/server/insecure/server_chttp2.c",
@ -4379,7 +4375,8 @@
"src/core/lib/tsi/ssl_types.h",
"src/core/lib/tsi/transport_security.c",
"src/core/lib/tsi/transport_security.h",
"src/core/lib/tsi/transport_security_interface.h"
"src/core/lib/tsi/transport_security_interface.h",
"src/core/plugin_registry/grpc_plugin_registry.c"
],
"third_party": false,
"type": "lib"
@ -4554,8 +4551,6 @@
"include/grpc/status.h",
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/pick_first/pick_first.h",
"src/core/ext/lb_policy/round_robin/round_robin.h",
"src/core/ext/transport/chttp2/transport/alpn.h",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",
@ -4700,9 +4695,7 @@
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h",
"src/core/ext/lb_policy/pick_first/pick_first.c",
"src/core/ext/lb_policy/pick_first/pick_first.h",
"src/core/ext/lb_policy/round_robin/round_robin.c",
"src/core/ext/lb_policy/round_robin/round_robin.h",
"src/core/ext/transport/chttp2/client/insecure/channel_create.c",
"src/core/ext/transport/chttp2/server/insecure/server_chttp2.c",
"src/core/ext/transport/chttp2/transport/alpn.c",
@ -4958,7 +4951,8 @@
"src/core/lib/transport/transport.c",
"src/core/lib/transport/transport.h",
"src/core/lib/transport/transport_impl.h",
"src/core/lib/transport/transport_op_string.c"
"src/core/lib/transport/transport_op_string.c",
"src/core/plugin_registry/grpc_unsecure_plugin_registry.c"
],
"third_party": false,
"type": "lib"

@ -284,8 +284,6 @@
<ItemGroup>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\grpclb\load_balancer_api.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\grpclb\proto\grpc\lb\v0\load_balancer.pb.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\pick_first\pick_first.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\transport\chttp2\transport\alpn.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\transport\chttp2\transport\bin_encoder.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\transport\chttp2\transport\chttp2_transport.h" />
@ -747,6 +745,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\tsi\transport_security.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\plugin_registry\grpc_plugin_registry.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_common.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_decode.c">

@ -484,6 +484,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\tsi\transport_security.c">
<Filter>src\core\lib\tsi</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\plugin_registry\grpc_plugin_registry.c">
<Filter>src\core\plugin_registry</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_common.c">
<Filter>third_party\nanopb</Filter>
</ClCompile>
@ -542,12 +545,6 @@
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\grpclb\proto\grpc\lb\v0\load_balancer.pb.h">
<Filter>src\core\ext\lb_policy\grpclb\proto\grpc\lb\v0</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\pick_first\pick_first.h">
<Filter>src\core\ext\lb_policy\pick_first</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.h">
<Filter>src\core\ext\lb_policy\round_robin</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\transport\chttp2\transport\alpn.h">
<Filter>src\core\ext\transport\chttp2\transport</Filter>
</ClInclude>
@ -1079,6 +1076,9 @@
<Filter Include="src\core\lib\tsi">
<UniqueIdentifier>{95ad2811-c8d0-7a42-2a73-baf03fcbf699}</UniqueIdentifier>
</Filter>
<Filter Include="src\core\plugin_registry">
<UniqueIdentifier>{02bec99b-ff39-88d7-9dea-e0ff9f4a2701}</UniqueIdentifier>
</Filter>
<Filter Include="third_party">
<UniqueIdentifier>{aaab30a4-2a15-732e-c141-3fbc0f0f5a7a}</UniqueIdentifier>
</Filter>

@ -274,8 +274,6 @@
<ItemGroup>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\grpclb\load_balancer_api.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\grpclb\proto\grpc\lb\v0\load_balancer.pb.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\pick_first\pick_first.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\transport\chttp2\transport\alpn.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\transport\chttp2\transport\bin_encoder.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\transport\chttp2\transport\chttp2_transport.h" />
@ -683,6 +681,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\transport\transport_op_string.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\plugin_registry\grpc_unsecure_plugin_registry.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_common.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_decode.c">

@ -424,6 +424,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\transport\transport_op_string.c">
<Filter>src\core\lib\transport</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\plugin_registry\grpc_unsecure_plugin_registry.c">
<Filter>src\core\plugin_registry</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\third_party\nanopb\pb_common.c">
<Filter>third_party\nanopb</Filter>
</ClCompile>
@ -479,12 +482,6 @@
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\grpclb\proto\grpc\lb\v0\load_balancer.pb.h">
<Filter>src\core\ext\lb_policy\grpclb\proto\grpc\lb\v0</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\pick_first\pick_first.h">
<Filter>src\core\ext\lb_policy\pick_first</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.h">
<Filter>src\core\ext\lb_policy\round_robin</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\transport\chttp2\transport\alpn.h">
<Filter>src\core\ext\transport\chttp2\transport</Filter>
</ClInclude>
@ -962,6 +959,9 @@
<Filter Include="src\core\lib\transport">
<UniqueIdentifier>{6c3394d1-27e9-003e-19ed-8116d210f7cc}</UniqueIdentifier>
</Filter>
<Filter Include="src\core\plugin_registry">
<UniqueIdentifier>{babf0a90-e934-f599-5475-e6937d9580fe}</UniqueIdentifier>
</Filter>
<Filter Include="third_party">
<UniqueIdentifier>{025c051e-8eba-125b-67f9-173f95176eb2}</UniqueIdentifier>
</Filter>

Loading…
Cancel
Save