Add api to server builder plugin to modify the builder

pull/11158/head
yang-g 8 years ago
parent 081c442462
commit 21035da1c9
  1. 4
      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;
@ -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;

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