14 """Channelz debug service implementation in gRPC Python."""
19 import grpc_channelz.v1.channelz_pb2
as _channelz_pb2
20 import grpc_channelz.v1.channelz_pb2_grpc
as _channelz_pb2_grpc
24 """Servicer handling RPCs for service statuses."""
29 return json_format.Parse(
30 cygrpc.channelz_get_top_channels(request.start_channel_id),
31 _channelz_pb2.GetTopChannelsResponse(),
33 except (ValueError, json_format.ParseError)
as e:
34 context.set_code(grpc.StatusCode.INTERNAL)
35 context.set_details(
str(e))
40 return json_format.Parse(
41 cygrpc.channelz_get_servers(request.start_server_id),
42 _channelz_pb2.GetServersResponse(),
44 except (ValueError, json_format.ParseError)
as e:
45 context.set_code(grpc.StatusCode.INTERNAL)
46 context.set_details(
str(e))
51 return json_format.Parse(
52 cygrpc.channelz_get_server(request.server_id),
53 _channelz_pb2.GetServerResponse(),
55 except ValueError
as e:
56 context.set_code(grpc.StatusCode.NOT_FOUND)
57 context.set_details(
str(e))
58 except json_format.ParseError
as e:
59 context.set_code(grpc.StatusCode.INTERNAL)
60 context.set_details(
str(e))
65 return json_format.Parse(
66 cygrpc.channelz_get_server_sockets(request.server_id,
67 request.start_socket_id,
69 _channelz_pb2.GetServerSocketsResponse(),
71 except ValueError
as e:
72 context.set_code(grpc.StatusCode.NOT_FOUND)
73 context.set_details(
str(e))
74 except json_format.ParseError
as e:
75 context.set_code(grpc.StatusCode.INTERNAL)
76 context.set_details(
str(e))
81 return json_format.Parse(
82 cygrpc.channelz_get_channel(request.channel_id),
83 _channelz_pb2.GetChannelResponse(),
85 except ValueError
as e:
86 context.set_code(grpc.StatusCode.NOT_FOUND)
87 context.set_details(
str(e))
88 except json_format.ParseError
as e:
89 context.set_code(grpc.StatusCode.INTERNAL)
90 context.set_details(
str(e))
95 return json_format.Parse(
96 cygrpc.channelz_get_subchannel(request.subchannel_id),
97 _channelz_pb2.GetSubchannelResponse(),
99 except ValueError
as e:
100 context.set_code(grpc.StatusCode.NOT_FOUND)
101 context.set_details(
str(e))
102 except json_format.ParseError
as e:
103 context.set_code(grpc.StatusCode.INTERNAL)
104 context.set_details(
str(e))
109 return json_format.Parse(
110 cygrpc.channelz_get_socket(request.socket_id),
111 _channelz_pb2.GetSocketResponse(),
113 except ValueError
as e:
114 context.set_code(grpc.StatusCode.NOT_FOUND)
115 context.set_details(
str(e))
116 except json_format.ParseError
as e:
117 context.set_code(grpc.StatusCode.INTERNAL)
118 context.set_details(
str(e))