channelz_service.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
22 
23 #include <grpc/support/alloc.h>
25 
26 // IWYU pragma: no_include <google/protobuf/util/json_util.h>
27 
28 namespace grpc {
29 
30 namespace {
31 
32 grpc::protobuf::util::Status ParseJson(const char* json_str,
34  grpc::protobuf::json::JsonParseOptions options;
35  options.case_insensitive_enum_parsing = true;
37 }
38 
39 } // namespace
40 
42  ServerContext* /*unused*/,
43  const channelz::v1::GetTopChannelsRequest* request,
44  channelz::v1::GetTopChannelsResponse* response) {
45  char* json_str = grpc_channelz_get_top_channels(request->start_channel_id());
46  if (json_str == nullptr) {
48  "grpc_channelz_get_top_channels returned null");
49  }
51  gpr_free(json_str);
52  if (!s.ok()) {
53  return Status(StatusCode::INTERNAL, s.ToString());
54  }
55  return Status::OK;
56 }
57 
59  ServerContext* /*unused*/, const channelz::v1::GetServersRequest* request,
60  channelz::v1::GetServersResponse* response) {
61  char* json_str = grpc_channelz_get_servers(request->start_server_id());
62  if (json_str == nullptr) {
64  "grpc_channelz_get_servers returned null");
65  }
67  gpr_free(json_str);
68  if (!s.ok()) {
69  return Status(StatusCode::INTERNAL, s.ToString());
70  }
71  return Status::OK;
72 }
73 
75  const channelz::v1::GetServerRequest* request,
76  channelz::v1::GetServerResponse* response) {
77  char* json_str = grpc_channelz_get_server(request->server_id());
78  if (json_str == nullptr) {
80  "grpc_channelz_get_server returned null");
81  }
83  gpr_free(json_str);
84  if (!s.ok()) {
85  return Status(StatusCode::INTERNAL, s.ToString());
86  }
87  return Status::OK;
88 }
89 
91  ServerContext* /*unused*/,
92  const channelz::v1::GetServerSocketsRequest* request,
93  channelz::v1::GetServerSocketsResponse* response) {
94  char* json_str = grpc_channelz_get_server_sockets(
95  request->server_id(), request->start_socket_id(), request->max_results());
96  if (json_str == nullptr) {
98  "grpc_channelz_get_server_sockets returned null");
99  }
101  gpr_free(json_str);
102  if (!s.ok()) {
103  return Status(StatusCode::INTERNAL, s.ToString());
104  }
105  return Status::OK;
106 }
107 
109  ServerContext* /*unused*/, const channelz::v1::GetChannelRequest* request,
110  channelz::v1::GetChannelResponse* response) {
111  char* json_str = grpc_channelz_get_channel(request->channel_id());
112  if (json_str == nullptr) {
113  return Status(StatusCode::NOT_FOUND, "No object found for that ChannelId");
114  }
116  gpr_free(json_str);
117  if (!s.ok()) {
118  return Status(StatusCode::INTERNAL, s.ToString());
119  }
120  return Status::OK;
121 }
122 
124  ServerContext* /*unused*/,
125  const channelz::v1::GetSubchannelRequest* request,
126  channelz::v1::GetSubchannelResponse* response) {
127  char* json_str = grpc_channelz_get_subchannel(request->subchannel_id());
128  if (json_str == nullptr) {
130  "No object found for that SubchannelId");
131  }
133  gpr_free(json_str);
134  if (!s.ok()) {
135  return Status(StatusCode::INTERNAL, s.ToString());
136  }
137  return Status::OK;
138 }
139 
141  const channelz::v1::GetSocketRequest* request,
142  channelz::v1::GetSocketResponse* response) {
143  char* json_str = grpc_channelz_get_socket(request->socket_id());
144  if (json_str == nullptr) {
145  return Status(StatusCode::NOT_FOUND, "No object found for that SocketId");
146  }
148  gpr_free(json_str);
149  if (!s.ok()) {
150  return Status(StatusCode::INTERNAL, s.ToString());
151  }
152  return Status::OK;
153 }
154 
155 } // namespace grpc
grpc_channelz_get_top_channels
GRPCAPI char * grpc_channelz_get_top_channels(intptr_t start_channel_id)
Definition: channelz_registry.cc:176
grpc::ServerContext
Definition: grpcpp/impl/codegen/server_context.h:566
grpc::gpr_free
gpr_free(creds_file_name)
grpc
Definition: grpcpp/alarm.h:33
options
double_dict options[]
Definition: capstone_test.c:55
benchmark.request
request
Definition: benchmark.py:77
grpc_channelz_get_server
GRPCAPI char * grpc_channelz_get_server(intptr_t server_id)
Definition: channelz_registry.cc:192
grpc::protobuf::Message
GRPC_CUSTOM_MESSAGE Message
Definition: include/grpcpp/impl/codegen/config_protobuf.h:78
grpc::ChannelzService::GetSocket
Status GetSocket(ServerContext *unused, const channelz::v1::GetSocketRequest *request, channelz::v1::GetSocketResponse *response) override
Definition: channelz_service.cc:140
grpc::ChannelzService::GetServerSockets
Status GetServerSockets(ServerContext *unused, const channelz::v1::GetServerSocketsRequest *request, channelz::v1::GetServerSocketsResponse *response) override
Definition: channelz_service.cc:90
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
grpc_channelz_get_servers
GRPCAPI char * grpc_channelz_get_servers(intptr_t start_server_id)
Definition: channelz_registry.cc:184
grpc_channelz_get_socket
GRPCAPI char * grpc_channelz_get_socket(intptr_t socket_id)
Definition: channelz_registry.cc:263
channelz_service.h
grpc.StatusCode.NOT_FOUND
tuple NOT_FOUND
Definition: src/python/grpcio/grpc/__init__.py:266
grpc_channelz_get_subchannel
GRPCAPI char * grpc_channelz_get_subchannel(intptr_t subchannel_id)
Definition: channelz_registry.cc:247
grpc::ChannelzService::GetServers
Status GetServers(ServerContext *unused, const channelz::v1::GetServersRequest *request, channelz::v1::GetServersResponse *response) override
Definition: channelz_service.cc:58
grpc::Status::OK
static const Status & OK
An OK pre-defined instance.
Definition: include/grpcpp/impl/codegen/status.h:113
grpc::ChannelzService::GetTopChannels
Status GetTopChannels(ServerContext *unused, const channelz::v1::GetTopChannelsRequest *request, channelz::v1::GetTopChannelsResponse *response) override
Definition: channelz_service.cc:41
grpc::ChannelzService::GetSubchannel
Status GetSubchannel(ServerContext *unused, const channelz::v1::GetSubchannelRequest *request, channelz::v1::GetSubchannelResponse *response) override
Definition: channelz_service.cc:123
grpc::testing::ParseJson
void ParseJson(const std::string &json, const std::string &type, GRPC_CUSTOM_MESSAGE *msg)
Definition: parse_json.cc:28
grpc::ChannelzService::GetChannel
Status GetChannel(ServerContext *unused, const channelz::v1::GetChannelRequest *request, channelz::v1::GetChannelResponse *response) override
Definition: channelz_service.cc:108
grpc_channelz_get_channel
GRPCAPI char * grpc_channelz_get_channel(intptr_t channel_id)
Definition: channelz_registry.cc:229
grpc::ChannelzService::GetServer
Status GetServer(ServerContext *unused, const channelz::v1::GetServerRequest *request, channelz::v1::GetServerResponse *response) override
Definition: channelz_service.cc:74
config_protobuf.h
grpc_channelz_get_server_sockets
GRPCAPI char * grpc_channelz_get_server_sockets(intptr_t server_id, intptr_t start_socket_id, intptr_t max_results)
Definition: channelz_registry.cc:208
alloc.h
asyncio_get_stats.response
response
Definition: asyncio_get_stats.py:28
grpc::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition: include/grpcpp/impl/codegen/config_protobuf.h:93
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
grpc.StatusCode.INTERNAL
tuple INTERNAL
Definition: src/python/grpcio/grpc/__init__.py:277
google::protobuf::util::JsonStringToMessage
util::Status JsonStringToMessage(StringPiece input, Message *message, const JsonParseOptions &options)
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/util/json_util.cc:258
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:53