|
|
|
@ -29,49 +29,37 @@ 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; |
|
|
|
|
ChannelzServicePlugin() : channelz_service_(new grpc::ChannelzService()) {} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
std::shared_ptr<grpc::ChannelzService> channelz_service_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
ChannelzServicePlugin::ChannelzServicePlugin() |
|
|
|
|
: channelz_service_(new grpc::ChannelzService()) {} |
|
|
|
|
grpc::string name() override { return "channelz_service"; } |
|
|
|
|
|
|
|
|
|
grpc::string ChannelzServicePlugin::name() { return "channelz_service"; } |
|
|
|
|
|
|
|
|
|
void ChannelzServicePlugin::InitServer(grpc::ServerInitializer* si) { |
|
|
|
|
void InitServer(grpc::ServerInitializer* si) override { |
|
|
|
|
si->RegisterService(channelz_service_); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ChannelzServicePlugin::Finish(grpc::ServerInitializer* si) {} |
|
|
|
|
void Finish(grpc::ServerInitializer* si) override {} |
|
|
|
|
|
|
|
|
|
void ChannelzServicePlugin::ChangeArguments(const grpc::string& name, |
|
|
|
|
void* value) {} |
|
|
|
|
void ChangeArguments(const grpc::string& name, void* value) override {} |
|
|
|
|
|
|
|
|
|
bool ChannelzServicePlugin::has_sync_methods() const { |
|
|
|
|
bool has_sync_methods() const override { |
|
|
|
|
if (channelz_service_) { |
|
|
|
|
return channelz_service_->has_synchronous_methods(); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool ChannelzServicePlugin::has_async_methods() const { |
|
|
|
|
bool has_async_methods() const override { |
|
|
|
|
if (channelz_service_) { |
|
|
|
|
return channelz_service_->has_async_methods(); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
std::shared_ptr<grpc::ChannelzService> channelz_service_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static std::unique_ptr< ::grpc::ServerBuilderPlugin> |
|
|
|
|
CreateChannelzServicePlugin() { |
|
|
|
@ -79,7 +67,7 @@ CreateChannelzServicePlugin() { |
|
|
|
|
new ChannelzServicePlugin()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void InitChannelzServiceBuilderPlugin() { |
|
|
|
|
void InitChannelzService() { |
|
|
|
|
static bool already_here = false; |
|
|
|
|
if (already_here) return; |
|
|
|
|
already_here = true; |
|
|
|
|