mirror of
https://github.com/TECHNOFAB11/powerproto.git
synced 2025-12-11 23:50:04 +01:00
chore(*): update plugin default options && add examples
Signed-off-by: storyicon <yuanchao@bilibili.com>
This commit is contained in:
parent
bc28762992
commit
4f4006ee7d
18 changed files with 342 additions and 10 deletions
29
examples/using-googleapis/README.md
Normal file
29
examples/using-googleapis/README.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Using Googleapis
|
||||
|
||||
This example uses the following public libraries:
|
||||
* [googleapis](https://github.com/googleapis/googleapis)
|
||||
|
||||
The following plug-ins are used:
|
||||
* [protoc-gen-go](google.golang.org/protobuf/cmd/protoc-gen-go)
|
||||
* [protoc-gen-go-grpc](google.golang.org/grpc/cmd/protoc-gen-go-grpc)
|
||||
* [protoc-gen-grpc-gateway](github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway)
|
||||
|
||||
You can compile the proto file in this directory by executing the following command:
|
||||
```
|
||||
powerproto build -r ./apis
|
||||
```
|
||||
|
||||
Not surprisingly, you will get the following output:
|
||||
```
|
||||
➜ tree
|
||||
.
|
||||
├── README.md
|
||||
├── apis
|
||||
│ ├── service.pb.go
|
||||
│ ├── service.pb.gw.go
|
||||
│ ├── service.proto
|
||||
│ └── service_grpc.pb.go
|
||||
└── powerproto.yaml
|
||||
|
||||
1 directory, 6 files
|
||||
```
|
||||
28
examples/using-googleapis/apis/service.proto
Normal file
28
examples/using-googleapis/apis/service.proto
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package powerproto.examples.using_googleapis;
|
||||
option go_package = "github.com/storyicon/powerproto/examples/using_googleapis/apis;apis";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
service Mocker {
|
||||
rpc Echo (EchoRequest) returns (EchoResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/echo"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
message EchoRequest {
|
||||
string message = 1;
|
||||
int64 timestamp = 2;
|
||||
uint32 code = 3;
|
||||
uint32 delay = 4;
|
||||
}
|
||||
|
||||
message EchoResponse {
|
||||
string message = 1;
|
||||
int64 timestamp = 2;
|
||||
string server = 3;
|
||||
}
|
||||
25
examples/using-googleapis/powerproto.yaml
Normal file
25
examples/using-googleapis/powerproto.yaml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
scopes:
|
||||
- ./
|
||||
protoc: v3.17.3
|
||||
protocWorkDir: ""
|
||||
plugins:
|
||||
protoc-gen-go: google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
|
||||
protoc-gen-go-grpc: google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0
|
||||
protoc-gen-grpc-gateway: github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.5.0
|
||||
repositories:
|
||||
GOOGLE_APIS: https://github.com/googleapis/googleapis@75e9812478607db997376ccea247dd6928f70f45
|
||||
options:
|
||||
- --go_out=.
|
||||
- --go_opt=paths=source_relative
|
||||
- --go-grpc_out=.
|
||||
- --go-grpc_opt=paths=source_relative
|
||||
- --grpc-gateway_out=.
|
||||
- --grpc-gateway_opt=paths=source_relative
|
||||
importPaths:
|
||||
- .
|
||||
- $GOPATH
|
||||
- $POWERPROTO_INCLUDE
|
||||
- $SOURCE_RELATIVE
|
||||
- $GOOGLE_APIS/github.com/googleapis/googleapis
|
||||
postActions: []
|
||||
postShell: ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue