Merge pull request #11158 from yang-g/async_default_service

Add api to server builder plugin to modify the builder
pull/11291/head
Yang Gao 8 years ago committed by GitHub
commit 0a94f3c8ab
  1. 5
      include/grpc++/impl/server_builder_plugin.h
  2. 4
      src/cpp/server/server_builder.cc

@ -40,6 +40,7 @@
namespace grpc {
class ServerBuilder;
class ServerInitializer;
class ChannelArguments;
@ -51,6 +52,10 @@ class ServerBuilderPlugin {
virtual ~ServerBuilderPlugin() {}
virtual grpc::string name() = 0;
/// UpdateServerBuilder will be called at the beginning of
/// \a ServerBuilder::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;

@ -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);

Loading…
Cancel
Save