channelz.pyx.pxi 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright 2018 The gRPC Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. def channelz_get_top_channels(start_channel_id):
  15. cdef char *c_returned_str = grpc_channelz_get_top_channels(
  16. start_channel_id,
  17. )
  18. if c_returned_str == NULL:
  19. raise ValueError('Failed to get top channels, please ensure your' \
  20. ' start_channel_id==%s is valid' % start_channel_id)
  21. return c_returned_str
  22. def channelz_get_servers(start_server_id):
  23. cdef char *c_returned_str = grpc_channelz_get_servers(start_server_id)
  24. if c_returned_str == NULL:
  25. raise ValueError('Failed to get servers, please ensure your' \
  26. ' start_server_id==%s is valid' % start_server_id)
  27. return c_returned_str
  28. def channelz_get_server(server_id):
  29. cdef char *c_returned_str = grpc_channelz_get_server(server_id)
  30. if c_returned_str == NULL:
  31. raise ValueError('Failed to get the server, please ensure your' \
  32. ' server_id==%s is valid' % server_id)
  33. return c_returned_str
  34. def channelz_get_server_sockets(server_id, start_socket_id, max_results):
  35. cdef char *c_returned_str = grpc_channelz_get_server_sockets(
  36. server_id,
  37. start_socket_id,
  38. max_results,
  39. )
  40. if c_returned_str == NULL:
  41. raise ValueError('Failed to get server sockets, please ensure your' \
  42. ' server_id==%s and start_socket_id==%s and' \
  43. ' max_results==%s is valid' %
  44. (server_id, start_socket_id, max_results))
  45. return c_returned_str
  46. def channelz_get_channel(channel_id):
  47. cdef char *c_returned_str = grpc_channelz_get_channel(channel_id)
  48. if c_returned_str == NULL:
  49. raise ValueError('Failed to get the channel, please ensure your' \
  50. ' channel_id==%s is valid' % (channel_id))
  51. return c_returned_str
  52. def channelz_get_subchannel(subchannel_id):
  53. cdef char *c_returned_str = grpc_channelz_get_subchannel(subchannel_id)
  54. if c_returned_str == NULL:
  55. raise ValueError('Failed to get the subchannel, please ensure your' \
  56. ' subchannel_id==%s is valid' % (subchannel_id))
  57. return c_returned_str
  58. def channelz_get_socket(socket_id):
  59. cdef char *c_returned_str = grpc_channelz_get_socket(socket_id)
  60. if c_returned_str == NULL:
  61. raise ValueError('Failed to get the socket, please ensure your' \
  62. ' socket_id==%s is valid' % (socket_id))
  63. return c_returned_str