-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,14 @@ Input is exactly the same as any other protoc plugin. | |
|
||
Output is exactly the same as the [good old protoc-gen-python-grpc](https://github.com/grpc/grpc/blob/master/src/compiler/python_generator.cc) provides. | ||
|
||
Please rise the issue in case of any difference found in these plugins output. | ||
Please rise the issue in case of any difference found in these plugins output. | ||
|
||
## How it works | ||
|
||
### Install | ||
|
||
``` | ||
go install github.com/Djarvur/protoc-gen-python-grpc/cmd/[email protected].5 | ||
```sh | ||
go install github.com/Djarvur/protoc-gen-python-grpc/cmd/[email protected].7 | ||
``` | ||
|
||
Make sure your [protoc](https://grpc.io/docs/protoc-installation/)/[buf](https://buf.build/docs/installation) compiler can see the `protoc-gen-python-grpc` in the path. | ||
|
@@ -29,7 +29,7 @@ Exactly the same as any other protoc plugin. | |
|
||
#### Parameters | ||
|
||
``` | ||
```txt | ||
protoc plugin to generate Python gRPC code | ||
Usage: | ||
|
@@ -48,28 +48,32 @@ There is the embedded template for the `_pb2_grpc.py` files in the program. | |
Of course, you can provide your own in Go [text/template](https://pkg.go.dev/text/template) format utilising the following placeholders: | ||
|
||
For each file: | ||
|
||
- `{{.Name}}` - name of the source file as it is provided by protoc/buf | ||
- `{{.Package}}` - proto package name | ||
- `{{.Services}}` - list of the services defined in the proto file (see below) | ||
|
||
For each service: | ||
|
||
- `{{.Name}}` - name of the service | ||
- `{{.Comment}}` - service-related comment, might be multi-line | ||
- `{{.Methods}}` - list of the methods defined for this service in proto file (see below) | ||
|
||
For each method: | ||
|
||
- `{{.Name}}` - name of the method | ||
- `{{.Comment}}` - method-related comment, might be multi-line | ||
- `{{.Request}}` - name of the method request message | ||
- `{{.Response}}` - name of the method response message | ||
- `{{.Request}}` - name of the method request message | ||
- `{{.Response}}` - name of the method response message | ||
- `{{.ClientStreaming}}` - boolean indicates is this method client-streaming | ||
- `{{.ServerStreaming}}` - boolean indicates is this method server-streaming | ||
|
||
Also, the following functions are available to be used as template pipelines: | ||
|
||
- `{{trimSuffix separator value}}` - returns a substring with the after-the-last-separator part removed | ||
- `{{baseName separator value}}` - returns a substring after-the-last-separator | ||
- `{{replace from to value}}` - returns a string with all the occurrences of `from` replaced to `to` | ||
- `{{split separator value}}` - splitting value by separator and returns a list of substrings | ||
- `{{split separator value}}` - splitting value by separator and returns a list of substrings | ||
- `{{join separator ...values}}` - joining a values list to one string with values divided by separator | ||
|
||
See [embedded template](cmd/protoc-gen-python-grpc/internal/flags/pb2_grpc.py.tmpl) for example. | ||
|