This is gRPC command line tool to use on SBT.
This is implemented to follow to the original specifications. and it refer to Polyglot.
This tool assists the input with tab completion when entering a command.
The command line tool can do the following things:
- Send unary rpc.
- Attach metadata and(yet) display received metadata.
- Handle common authentication to server.(yet)
- Infer request/response types from server reflection result.
- Find the request/response types from a given proto file.
- Read proto request in text form.
- Read request in wire form (for protobuf messages, this means serialized binary form).(yet)
- Display proto response in text form.
- (not yet)Write response in wire form to a file.(yet)
edit your-project/project/plugins.sbt
addSbtPlugin("com.github.bakenezumi" % "grpc-cli-sbt" % "0.1.0")Most grpc-cli commands need the server to support server reflection. See
guides for
Java
, C++
and Go
After enabling server reflection in a server application, you can use gRPC CLI to get information about its available services.
$ sbt
sbt:your-project> set gRPCEndpoint := "localhost:50051"
sbt:your-project> grpc-cli lsThe localhost:50051 part indicates the server you are connecting to.
grpc-cli ls command lists services and methods exposed at a setting port
- 
List all the services exposed at a given port sbt:your-project> grpc-cli lsoutput: grpc.reflection.v1alpha.ServerReflection helloworld.Greeter
- 
List one service with details grpc-cli lscommand inspects a service given its full name (in the format of <package>.<service>). It can print information with a long listing format when-lflag is set. This flag can be used to get more details about a service.sbt:your-project> grpc-cli ls helloworld.Greeter -lhelloworld.Greeteris full name of the service.output: filename: helloworld.proto package: helloworld; service Greeter { rpc SayHello(helloworld.HelloRequest) returns (helloworld.HelloReply) {} } 
- 
List one method with details grpc-cli lscommand also inspects a method given its full name (in the format of <package>.<service>.<method>).sbt:your-project> grpc-cli ls helloworld.Greeter.SayHello -lhelloworld.Greeter.SayHello is full name of the method. output: rpc SayHello(helloworld.HelloRequest) returns (helloworld.HelloReply) {}
We can use grpc-cli type  command to inspect request/response types given the
full name of the type (in the format of <package>.<type>).
- 
Get information about the request type sbt:your-project> grpc-cli type helloworld.HelloRequesthelloworld.HelloRequestis the full name of the request type.output: message HelloRequest { string name = 1[json_name = "name"]; } 
We can send RPCs to a server and get responses using grpc-cli call command.
- 
Call a unary method Send a rpc to a helloworld sbt:your-project> grpc-cli call helloworld.Greeter.SayHello reading request message from stdin... {name:"gRPC CLI SBT"}output: message: "Hello gRPC CLI SBT"
- 
Use local proto files If the server does not have the server reflection service, you will need to provide local proto files containing the service definition. The plugin assumes your protofiles are undersrc/main/protobuf, however this is configurable using thegRPCProtoSourcessetting.
Apache License, Version 2.0