Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build examples with buf #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions _examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## wsechoserver
This example implements a websocket server using the proxy. The proto definition contains three RPCs:
- `Echo` is a bidirectional stream that echoes back the client request.
- `Stream` is a server-side stream that sends a fixed number of messages to the client and closes the connection
- `Heartbeat` is a bidirectional stream that sends back messages to the client at intervals.

## Usage
Ideally, you should be able to run `go run _examples/cmd/wsechoserver` and start the example server.
To build it locally, you'll need to install:
- [buf](https://buf.build/)
- [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-go-grpc-gateway](github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway)

Generate the protobuf files by running:
`buf generate -v .`

You should now be able to start the server with the same run command above.
6 changes: 0 additions & 6 deletions _examples/cmd/wsechoserver/echoserver/Makefile

This file was deleted.

29 changes: 29 additions & 0 deletions _examples/cmd/wsechoserver/echoserver/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/tmc/grpc-websocket-proxy/examples/cmd/wsechoserver/echoserver
except:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
- buf.build/percona/third_party

plugins:
- name: go
path: protoc-gen-go
out: .
opt:
- paths=source_relative

- name: go-grpc
path: protoc-gen-go-grpc
out: .
opt:
- paths=source_relative

- name: grpc-gateway
path: protoc-gen-grpc-gateway
out: .
opt:
- paths=source_relative
- logtostderr=true
7 changes: 7 additions & 0 deletions _examples/cmd/wsechoserver/echoserver/buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 2646de1347094058879360e68cb2ccc6
10 changes: 10 additions & 0 deletions _examples/cmd/wsechoserver/echoserver/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1
deps:
- buf.build/googleapis/googleapis
lint:
use:
- DEFAULT
breaking:
use:
- FILE

Loading