From bd3165747c93efcb0914652102a44f3439682827 Mon Sep 17 00:00:00 2001 From: Nex Date: Tue, 22 Sep 2020 16:21:24 +0800 Subject: [PATCH] chore: update protobuf * gRPC toolchains --- docs/apis.md | 19 ------------------- grpc/README.md | 28 ++++++++++++++++++++-------- grpc/scripts/gen.bat | 2 +- grpc/scripts/gen.sh | 2 +- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/docs/apis.md b/docs/apis.md index 8933005..7b11ae4 100644 --- a/docs/apis.md +++ b/docs/apis.md @@ -11,17 +11,10 @@ - [Contract.ContractUnitRequestType](#bdware.bdledger.api.Contract.ContractUnitRequestType) - [TransactionType](#bdware.bdledger.api.TransactionType) - - - - [bdware/bdledger/api/error_details.proto](#bdware/bdledger/api/error_details.proto) - [InvalidArgument](#bdware.bdledger.api.InvalidArgument) - [InvalidArgument.FieldViolation](#bdware.bdledger.api.InvalidArgument.FieldViolation) - - - - - [bdware/bdledger/api/ledger.proto](#bdware/bdledger/api/ledger.proto) - [CreateLedgerRequest](#bdware.bdledger.api.CreateLedgerRequest) - [CreateLedgerResponse](#bdware.bdledger.api.CreateLedgerResponse) @@ -30,19 +23,13 @@ - [SendTransactionRequest.Transaction](#bdware.bdledger.api.SendTransactionRequest.Transaction) - [SendTransactionResponse](#bdware.bdledger.api.SendTransactionResponse) - - - [Ledger](#bdware.bdledger.api.Ledger) - - [bdware/bdledger/api/node.proto](#bdware/bdledger/api/node.proto) - [ClientVersionResponse](#bdware.bdledger.api.ClientVersionResponse) - - - [Node](#bdware.bdledger.api.Node) - - [bdware/bdledger/api/query.proto](#bdware/bdledger/api/query.proto) - [BlockFilter](#bdware.bdledger.api.BlockFilter) - [BlocksRequest](#bdware.bdledger.api.BlocksRequest) @@ -62,17 +49,11 @@ - [IncludeTransactions](#bdware.bdledger.api.IncludeTransactions) - - [Query](#bdware.bdledger.api.Query) - - [google/protobuf/empty.proto](#google/protobuf/empty.proto) - [Empty](#google.protobuf.Empty) - - - - - [Scalar Value Types](#scalar-value-types) diff --git a/grpc/README.md b/grpc/README.md index 9b0e0eb..30599a8 100644 --- a/grpc/README.md +++ b/grpc/README.md @@ -10,16 +10,28 @@ See [API documentation](..\docs\apis.md) ##### Installling tools -Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-3.11.4-*) for your platform and add `protoc` to `PATH` environment variable +Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-3.13.0-*) for your platform and add `protoc` to `PATH` environment variable -For generating Go code: +For generating Go code, install `protoc-gen-go` (v1.32.0): ```bash -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 +GIT_TAG="v1.32.0" +go get -d -u google.golang.org/protobuf/cmd/protoc-gen-go +git -C "$(go env GOPATH)"/src/google.golang.org/protobuf checkout $GIT_TAG +go install google.golang.org/protobuf/cmd/protoc-gen-go ``` -(Update to google.golang.org/protobuf when https://github.com/grpc/grpc-go/pull/3435 resolves) + +Also install `protoc-gen-go-grpc`: +```bash +go get -u google.golang.org/protobuf/cmd/protoc-gen-go +``` + +Or install using [gobin](https://github.com/myitcv/gobin): +```bash +gobin google.golang.org/protobuf/cmd/protoc-gen-go +gobin google.golang.org/grpc/cmd/protoc-gen-go-grpc +``` + +For generating HTTP JSON APIs with [grpc-gateway](https://grpc-ecosystem.github.io/grpc-gateway/), follow the [documentation](https://github.com/grpc-ecosystem/grpc-gateway/tree/v2#installation). For generating Java code: From `bdledger-sdk-java` run `gradle generateProto` @@ -50,7 +62,7 @@ References: Run: ```bash -./scripts/gen [-a, --async] [go] [nodejs] [ts] [docs] +./scripts/gen [-a, --async] [go] [gohttp] [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) diff --git a/grpc/scripts/gen.bat b/grpc/scripts/gen.bat index 59196a1..bf9046f 100644 --- a/grpc/scripts/gen.bat +++ b/grpc/scripts/gen.bat @@ -18,7 +18,7 @@ for %%A in (%*) do ( set out=%gen%\go if not exist !out! mkdir !out! echo Generating Go code - !exec! --go_out=plugins=grpc:!out! --govalidators_out=!out! %pbs% + !exec! --go-grpc_out=!out! --govalidators_out=!out! %pbs% ) if "%%A"=="gohttp" ( set plugin=protoc-gen-grpc-gateway diff --git a/grpc/scripts/gen.sh b/grpc/scripts/gen.sh index c9a82d1..9925e19 100755 --- a/grpc/scripts/gen.sh +++ b/grpc/scripts/gen.sh @@ -46,7 +46,7 @@ do mkdir -p $out fi echo "Generating Go code" - $exec --go_out=plugins=grpc:$out --govalidators_out=$out $pb_files $async_tag + $exec --go-grpc_out=$out --govalidators_out=$out $pb_files $async_tag fi if [ $aug == "gohttp" ]; then plugin=protoc-gen-grpc-gateway