Created
March 15, 2019 09:29
-
-
Save Harold2017/3fbf96bd2f3d44fb4616ed0af917f0fa to your computer and use it in GitHub Desktop.
python gRPC client side reflection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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