Skip to content

Commit

Permalink
Merge pull request grpc#7918 from y-zeng/server_builder
Browse files Browse the repository at this point in the history
Add ServerBuilderPlugin::UpdateChannelArguments
  • Loading branch information
kpayson64 authored Sep 1, 2016
2 parents 29b75b1 + 11d3c8f commit cfa1847
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions include/grpc++/impl/server_builder_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
namespace grpc {

class ServerInitializer;
class ChannelArguments;

class ServerBuilderPlugin {
public:
Expand All @@ -58,6 +59,10 @@ class ServerBuilderPlugin {
// ServerBuilderOption::UpdatePlugins
virtual void ChangeArguments(const grpc::string& name, void* value) = 0;

// UpdateChannelArguments will be called in ServerBuilder::BuildAndStart(),
// before the Server instance is created.
virtual void UpdateChannelArguments(ChannelArguments* args) {}

virtual bool has_sync_methods() const { return false; }
virtual bool has_async_methods() const { return false; }
};
Expand Down
12 changes: 5 additions & 7 deletions src/cpp/server/server_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
(*option)->UpdateArguments(&args);
(*option)->UpdatePlugins(&plugins_);
}
if (!thread_pool) {
for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
if ((*plugin)->has_sync_methods()) {
thread_pool.reset(CreateDefaultThreadPool());
has_sync_methods = true;
break;
}
for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
if (!thread_pool && (*plugin)->has_sync_methods()) {
thread_pool.reset(CreateDefaultThreadPool());
has_sync_methods = true;
}
(*plugin)->UpdateChannelArguments(&args);
}
if (max_message_size_ > 0) {
args.SetInt(GRPC_ARG_MAX_MESSAGE_LENGTH, max_message_size_);
Expand Down

0 comments on commit cfa1847

Please sign in to comment.