chore: update protobuf + gRPC toolchains

This commit is contained in:
Nex Zhu
2024-03-06 15:37:53 +08:00
parent b74f3fe89c
commit d607cb6a7b
9 changed files with 338 additions and 252 deletions

View File

@@ -10,52 +10,41 @@ See [API documentation](..\docs\apis.md)
##### Installling tools
Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-3.21.9-*)+ for
Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-25.3-*)+ for
your platform and add `protoc` to `PATH` environment variable
For generating Go code, install `protoc-gen-go` (v1.28.1+):
For generating Go code, install `protoc-gen-go` (v1.33.0+):
```shell
GIT_TAG="v1.28.1"
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
```sh
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
```
Also install `protoc-gen-go-grpc` v1.2.0+:
Also install `protoc-gen-go-grpc` v1.3.0+:
```shell
go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc
```
Or install using [gobin](https://github.com/myitcv/gobin):
```shell
gobin google.golang.org/protobuf/cmd/protoc-gen-go
gobin google.golang.org/grpc/cmd/protoc-gen-go-grpc
```sh
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
```
For generating HTTP JSON APIs with [grpc-gateway](https://grpc-ecosystem.github.io/grpc-gateway/) **v2.2.0**, follow
the [documentation](https://github.com/grpc-ecosystem/grpc-gateway#installation).
For generating validators
install [go-proto-validators](https://github.com/mwitkow/go-proto-validators/tree/master/protoc-gen-govalidators):
For generating validators, install [go-proto-validators](https://github.com/mwitkow/go-proto-validators/tree/master/protoc-gen-govalidators) v0.3.2+:
```shell
go get github.com/mwitkow/go-proto-validators/protoc-gen-govalidators
```sh
go install github.com/mwitkow/go-proto-validators/protoc-gen-govalidators@latest
```
For generating Java code: From `bdledger-sdk-java` run `gradle generateProto`
For generating Node.js code and/or TypeScript definitions), install Node.js then run:
```shell
```sh
npm install
```
For frontend JavaScript:
```shell
```sh
git clone https://github.com/grpc/grpc-web
cd grpc-web
sudo make install-plugin
@@ -75,19 +64,19 @@ Run:
For generating TypeScript client code with `ts-proto`, run:
```shell
```sh
invoke gen -t ts
```
For generating TypeScript definitions to be used with `@grpc/proto-loader`, run:
```shell
```sh
invoke gen -t types
```
Others:
```shell
```sh
./scripts/gen [-a, --async] [go] [gohttp] [nodejs] [docs]
```
@@ -96,11 +85,11 @@ Others:
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
#### Generating documentation
Install Go then run:
```shell
go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
```sh
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
./scripts/gen [-a, --async] docs
```