https://github.com/alpancs/protoc-gen-pubsub-schema
protoc-gen-pubsub-schema is a protoc plugin that assembles protocol buffer messages into a single-valid message for defining Pub/Sub schemas
https://github.com/alpancs/protoc-gen-pubsub-schema
protobuf pubsub schema
Last synced: 5 months ago
JSON representation
protoc-gen-pubsub-schema is a protoc plugin that assembles protocol buffer messages into a single-valid message for defining Pub/Sub schemas
- Host: GitHub
- URL: https://github.com/alpancs/protoc-gen-pubsub-schema
- Owner: alpancs
- License: apache-2.0
- Created: 2021-07-26T02:32:54.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-30T09:33:20.000Z (about 2 years ago)
- Last Synced: 2024-07-30T20:06:12.670Z (almost 2 years ago)
- Topics: protobuf, pubsub, schema
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# protoc-gen-pubsub-schema
[](https://github.com/alpancs/protoc-gen-pubsub-schema/actions/workflows/go.yml)
This is a [protoc](https://github.com/protocolbuffers/protobuf) plugin
that assembles protocol buffer messages into a single-valid message for defining [Pub/Sub schemas](https://cloud.google.com/pubsub/docs/schemas).
## Installation
Run the following command to install `protoc-gen-pubsub-schema`.
```sh
go install github.com/alpancs/protoc-gen-pubsub-schema@latest
```
## Usage
You need to have `protoc` installed.
Follow for instruction.
To use this plugin, just run `protoc` with an option `--pubsub-schema_out`.
`protoc` will automatically use `protoc-gen-pubsub-schema` executable file.
`protoc` and `protoc-gen-pubsub-schema` must be found in shell's `$PATH`.
```sh
# generate pubsub-proto-schema files using proto2 syntax that accept binary message encoding
protoc PROTO_FILES --pubsub-schema_out=OUT_DIR
# generate pubsub-proto-schema files using proto2 syntax that accept JSON message encoding
protoc PROTO_FILES --pubsub-schema_out=OUT_DIR --pubsub-schema_opt=message-encoding=json
# generate pubsub-proto-schema files using proto3 syntax that accept JSON message encoding
protoc PROTO_FILES --pubsub-schema_out=OUT_DIR --pubsub-schema_opt=message-encoding=json --pubsub-schema_opt=schema-syntax=proto3
```
## Example
The following example shows how to generate [example/article_commented.pps](example/article_commented.pps) from [example/article_commented.proto](example/article_commented.proto).
```sh
# include go compiled binaries in the $PATH if it hasn't been there yet
export PATH=$PATH:$(go env GOPATH)/bin
# generate example/article_commented.pps
protoc example/article_commented.proto --pubsub-schema_out=.
```