Skip to content

Instantly share code, notes, and snippets.

@etheleon
Created December 18, 2020 11:16
Show Gist options
  • Save etheleon/4b743d26d107c2dab8da15cbf043d750 to your computer and use it in GitHub Desktop.
Save etheleon/4b743d26d107c2dab8da15cbf043d750 to your computer and use it in GitHub Desktop.
querying gRPC using gPRC

There's no need to create a heartbeat endpoint, with gRPC you could just use the grpc-health-probe

You can use either of two tools grpcurl or the web equivalent grpcUI (similar to postman but you cannot store the collection, but you can keep the request data as a .json file

Installation

grpcURL

go get github.com/fullstorydev/grpcurl/...

grpcui

go get github.com/fullstorydev/grpcui/...
PROJECT_ROOT=/home/jovyan/
URI=<URI>
SVC=pb.yourService
PORT=80
WEBUIPORT=8080

# CLI
cat $PROJECT_ROOT/scripts/example_request.json |
grpcurl \
  -plaintext \
  -d @ \
  -import-path $PROJECT_ROOT/symbolic_schemas/vendor \
  -import-path $PROJECT_ROOT/symbolic_schemas/protos \
  -import-path $PROJECT_ROOT/pb \
  -proto $PROJECT_ROOT/pb/yourproto.proto \
  $URI:$PORT ${SVC}/Predict


# web UI
# grpcui \
#     --plaintext \
#     -bind 0.0.0.0 -port $WEBUIPORT  \
#     -import-path $PROJECT_ROOT/symbolic_schemas/vendor  \
#     -import-path $PROJECT_ROOT/symbolic_schemas/protos/  \
#     -import-path $PROJECT_ROOT/pb  \
#     -proto $PROJECT_ROOT/pb/yourproto.proto  \
#     $URI:$PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment