diff options
author | ncteisen <ncteisen@gmail.com> | 2018-09-27 10:26:08 -0500 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-09-27 14:20:57 -0500 |
commit | 038e760a7da9098dd1e0b76db0342b1eb1a6351d (patch) | |
tree | 02b2079f022a279e061172cd86acb533d975b160 /src/cpp/server/channelz | |
parent | 404b2515af9c4dcc29440dea8b955ba341521b68 (diff) |
Channelz C++ Socket support
Diffstat (limited to 'src/cpp/server/channelz')
-rw-r--r-- | src/cpp/server/channelz/channelz_service.cc | 17 | ||||
-rw-r--r-- | src/cpp/server/channelz/channelz_service.h | 4 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/cpp/server/channelz/channelz_service.cc b/src/cpp/server/channelz/channelz_service.cc index e096c1f421..4e3fe8c1c9 100644 --- a/src/cpp/server/channelz/channelz_service.cc +++ b/src/cpp/server/channelz/channelz_service.cc @@ -92,4 +92,21 @@ Status ChannelzService::GetSubchannel( return Status::OK; } +Status ChannelzService::GetSocket(ServerContext* unused, + const channelz::v1::GetSocketRequest* request, + channelz::v1::GetSocketResponse* response) { + char* json_str = grpc_channelz_get_socket(request->socket_id()); + gpr_log(GPR_ERROR, "%s", json_str); + if (json_str == nullptr) { + return Status(NOT_FOUND, "No object found for that SocketId"); + } + google::protobuf::util::Status s = + google::protobuf::util::JsonStringToMessage(json_str, response); + gpr_free(json_str); + if (s != google::protobuf::util::Status::OK) { + return Status(INTERNAL, s.ToString()); + } + return Status::OK; +} + } // namespace grpc diff --git a/src/cpp/server/channelz/channelz_service.h b/src/cpp/server/channelz/channelz_service.h index 9e0b5b6ead..1be4e01c73 100644 --- a/src/cpp/server/channelz/channelz_service.h +++ b/src/cpp/server/channelz/channelz_service.h @@ -44,6 +44,10 @@ class ChannelzService final : public channelz::v1::Channelz::Service { Status GetSubchannel(ServerContext* unused, const channelz::v1::GetSubchannelRequest* request, channelz::v1::GetSubchannelResponse* response) override; + // implementation of GetSocket rpc + Status GetSocket(ServerContext* unused, + const channelz::v1::GetSocketRequest* request, + channelz::v1::GetSocketResponse* response) override; }; } // namespace grpc |