diff options
author | ncteisen <ncteisen@gmail.com> | 2018-10-26 12:58:04 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-10-26 12:58:04 -0700 |
commit | bc44c5e3535fa7a1286a7324ebac9dda98a94182 (patch) | |
tree | 6d7e6f1a9fcc3e7256698dd2654b7de61b88f04a /src/cpp/server | |
parent | 5cf95f0b52c21e6ebd0a7917d619da7b545d86c7 (diff) |
Add GetServer to channelz cpp
Diffstat (limited to 'src/cpp/server')
-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 428893f277..9ecb9de7e4 100644 --- a/src/cpp/server/channelz/channelz_service.cc +++ b/src/cpp/server/channelz/channelz_service.cc @@ -59,6 +59,23 @@ Status ChannelzService::GetServers( return Status::OK; } +Status ChannelzService::GetServer(ServerContext* unused, + const channelz::v1::GetServerRequest* request, + channelz::v1::GetServerResponse* response) { + char* json_str = grpc_channelz_get_server(request->server_id()); + if (json_str == nullptr) { + return Status(StatusCode::INTERNAL, + "grpc_channelz_get_server returned null"); + } + grpc::protobuf::util::Status s = + grpc::protobuf::json::JsonStringToMessage(json_str, response); + gpr_free(json_str); + if (!s.ok()) { + return Status(StatusCode::INTERNAL, s.ToString()); + } + return Status::OK; +} + Status ChannelzService::GetServerSockets( ServerContext* unused, const channelz::v1::GetServerSocketsRequest* request, channelz::v1::GetServerSocketsResponse* response) { diff --git a/src/cpp/server/channelz/channelz_service.h b/src/cpp/server/channelz/channelz_service.h index 590b5d492e..b4a66ba1c6 100644 --- a/src/cpp/server/channelz/channelz_service.h +++ b/src/cpp/server/channelz/channelz_service.h @@ -36,6 +36,10 @@ class ChannelzService final : public channelz::v1::Channelz::Service { Status GetServers(ServerContext* unused, const channelz::v1::GetServersRequest* request, channelz::v1::GetServersResponse* response) override; + // implementation of GetServer rpc + Status GetServer(ServerContext* unused, + const channelz::v1::GetServerRequest* request, + channelz::v1::GetServerResponse* response) override; // implementation of GetServerSockets rpc Status GetServerSockets( ServerContext* unused, |