Currency Service
A simple example to understand gRPC in golang!
Directory Structure
.
├── currency.proto
├── main.go
├── Makefile
├── protos
│ ├── currency_grpc.pb.go
│ └── currency.pb.go
├── README.md
└── server
└── currency.go
Testing
To test the system install grpccurl which is a command line tool which can interact with gRPC API's
Link to the repo is here!
go install github.com/fullstorydev/grpcurl/cmd/grpcurl
Run the server
List Services
List Methods
- Command:
grpcurl --plaintext localhost:8080 list Currency
- Output:
Currency.GetRate
Method detail for GetRate
RateRequest detail
RateResponse detail
Execute a request
- Command:
grpcurl --plaintext -d '{"Base":"USD","Destination":"INR"}' localhost:8080 Currency.GetRate
- Output:
{
"rate": 0.5
}