bdledger-apis/grpc
2020-06-11 19:04:05 +08:00
..
pb Update go_path 2020-06-11 19:04:05 +08:00
scripts Add grpc-gateway for HTTP JSON API 2020-06-08 17:25:37 +08:00
README.md Upgrade protoc-gen-go to v1.4.0 2020-04-19 12:07:59 +08:00

BDLedger API

Documentation

See API documentation

Development

Generating gRPC code in languages

Installling tools

Download the Protocol Buffers compiler (protoc-3.11.4-*) for your platform and add protoc to PATH environment variable

For generating Go code:

GIT_TAG="v1.4.0"
go get -d -u github.com/golang/protobuf/protoc-gen-go
git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG
go install github.com/golang/protobuf/protoc-gen-go

(Update to google.golang.org/protobuf when https://github.com/grpc/grpc-go/pull/3435 resolves)

For generating Java code: From bdledger-sdk-java run gradle generateProto

For generating Node.js code, install Node.js then run:

npm install -g grpc-tools 

For generating TypeScript definitions, also run:

npm install -g protoc-gen-ts

For frontend JavaScript:

git clone https://github.com/grpc/grpc-web
cd grpc-web
sudo make install-plugin

References:

TODO: Look into protobuf.js for Nodes.js and frontend TODO: Look into Kroto+ for Kotlin

Generating code

Run:

./scripts/gen [-a, --async] [go] [nodejs] [ts] [docs]

Use -a or --async to speed up generation by asynchronously and concurrently generating all code and documentation (script will exit without waiting for completion)

Generateing documentation

Install Go then run:

go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
./scripts/gen [-a, --async] docs