diff options
author | yang-g <yangg@google.com> | 2017-05-16 11:42:04 -0700 |
---|---|---|
committer | yang-g <yangg@google.com> | 2017-05-16 11:42:04 -0700 |
commit | 21035da1c9c20b5204ad4e9f2339490b3a3b6c0f (patch) | |
tree | 18de0e4e4e33bd522d66e76c1bb39faa7e421a9f | |
parent | 081c442462a21f326ff08f47ff1cd9a17c6746ea (diff) |
Add api to server builder plugin to modify the builder
-rw-r--r-- | include/grpc++/impl/server_builder_plugin.h | 4 | ||||
-rw-r--r-- | src/cpp/server/server_builder.cc | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/grpc++/impl/server_builder_plugin.h b/include/grpc++/impl/server_builder_plugin.h index 61632e32fa..00d806ddb1 100644 --- a/include/grpc++/impl/server_builder_plugin.h +++ b/include/grpc++/impl/server_builder_plugin.h @@ -40,6 +40,7 @@ namespace grpc { +class ServerBuilder; class ServerInitializer; class ChannelArguments; @@ -48,6 +49,9 @@ class ServerBuilderPlugin { virtual ~ServerBuilderPlugin() {} virtual grpc::string name() = 0; + /// UpdateServerBuilder will be called at the beginning of BuildAndStart. + virtual void UpdateServerBuilder(ServerBuilder* builder) {} + // InitServer will be called in ServerBuilder::BuildAndStart(), after the // Server instance is created. virtual void InitServer(ServerInitializer* si) = 0; diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 2ead048a1f..c3de7fee76 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -180,6 +180,10 @@ ServerBuilder& ServerBuilder::AddListeningPort( } std::unique_ptr<Server> ServerBuilder::BuildAndStart() { + for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) { + (*plugin)->UpdateServerBuilder(this); + } + ChannelArguments args; for (auto option = options_.begin(); option != options_.end(); ++option) { (*option)->UpdateArguments(&args); |