reviewer feedback

reviewable/pr16023/r6
ncteisen 7 years ago
parent 6104e4f33b
commit b47214952b
  1. 20
      include/grpcpp/ext/channelz_service_plugin.h
  2. 24
      src/cpp/server/channelz/channelz_service_plugin.cc
  3. 6
      test/cpp/end2end/channelz_service_test.cc

@ -25,31 +25,13 @@
#include <grpcpp/impl/server_initializer.h>
#include <grpcpp/support/config.h>
#include "src/cpp/server/channelz/channelz_service.h"
namespace grpc {
namespace channelz {
namespace experimental {
// This plugin is experimental for now. Track progress in
// https://github.com/grpc/grpc/issues/15988.
class ChannelzServicePlugin : public ::grpc::ServerBuilderPlugin {
public:
ChannelzServicePlugin();
::grpc::string name() override;
void InitServer(::grpc::ServerInitializer* si) override;
void Finish(::grpc::ServerInitializer* si) override;
void ChangeArguments(const ::grpc::string& name, void* value) override;
bool has_async_methods() const override;
bool has_sync_methods() const override;
private:
std::shared_ptr<grpc::ChannelzService> channelz_service_;
};
/// Add channelz server plugin to \a ServerBuilder. This function should
/// be called at static initialization time.
void InitChannelzServerBuilderPlugin();
void InitChannelzServiceBuilderPlugin();
} // namespace experimental
} // namespace channelz

@ -29,6 +29,22 @@ namespace grpc {
namespace channelz {
namespace experimental {
// This plugin is experimental for now. Track progress in
// https://github.com/grpc/grpc/issues/15988.
class ChannelzServicePlugin : public ::grpc::ServerBuilderPlugin {
public:
ChannelzServicePlugin();
::grpc::string name() override;
void InitServer(::grpc::ServerInitializer* si) override;
void Finish(::grpc::ServerInitializer* si) override;
void ChangeArguments(const ::grpc::string& name, void* value) override;
bool has_async_methods() const override;
bool has_sync_methods() const override;
private:
std::shared_ptr<grpc::ChannelzService> channelz_service_;
};
ChannelzServicePlugin::ChannelzServicePlugin()
: channelz_service_(new grpc::ChannelzService()) {}
@ -70,14 +86,6 @@ void InitChannelzServiceBuilderPlugin() {
::grpc::ServerBuilder::InternalAddPluginFactory(&CreateChannelzServicePlugin);
}
// Force InitChannelzServiceBuilderPlugin() to be called at static
// initialization time.
struct StaticChannelServicePluginInitializer {
StaticChannelServicePluginInitializer() {
InitChannelzServiceBuilderPlugin();
}
} static_channelz_service_plugin_initializer;
} // namespace experimental
} // namespace channelz
} // namespace grpc

@ -76,6 +76,9 @@ class ChannelzServerTest : public ::testing::Test {
ChannelzServerTest() {}
void SetUp() override {
// ensure channel server is brought up on all severs we build.
::grpc::channelz::experimental::InitChannelzServiceBuilderPlugin();
// We set up a proxy server with channelz enabled.
proxy_port_ = grpc_pick_unused_port_or_die();
ServerBuilder proxy_builder;
@ -177,9 +180,6 @@ class ChannelzServerTest : public ::testing::Test {
// backends. All implement the echo service.
std::vector<BackendData> backends_;
// ensure channel server is linked in.
channelz::experimental::ChannelzServicePlugin plugin_;
};
TEST_F(ChannelzServerTest, BasicTest) {

Loading…
Cancel
Save