Skip to content

Instantly share code, notes, and snippets.

@Harold2017
Created March 15, 2019 09:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Harold2017/3fbf96bd2f3d44fb4616ed0af917f0fa to your computer and use it in GitHub Desktop.
Save Harold2017/3fbf96bd2f3d44fb4616ed0af917f0fa to your computer and use it in GitHub Desktop.
python gRPC client side reflection
from grpc_reflection.v1alpha import reflection
def list_services(address):
channel = grpc.secure_channel(address, get_client_credentials())
stub = reflection._reflection_pb2_grpc.ServerReflectionStub(channel)
def gen():
yield reflection._reflection_pb2.ServerReflectionRequest(host=address, list_services='')
result = [r for r in stub.ServerReflectionInfo(gen())]
print("Available services:\n%r" % result[0].list_services_response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment