All Projects → johanbrandhorst → gopherjs-grpc-websocket

johanbrandhorst / gopherjs-grpc-websocket

Licence: MIT license
An example implementation of bridging gRPC with a GopherJS frontend over Websockets

Programming Languages

go
31211 projects - #10 most used programming language
python
139335 projects - #7 most used programming language
HTML
75241 projects
Protocol Buffer
295 projects

gopherjs-grpc-websocket

An example implementation of bridging a gRPC backend with a GopherJS frontend over Websockets, XHR requests and the grpc-gateway.

A large focus of this project is to show that you can implement both simple HTTP requests and complex bi-directional websocket streaming without compromising generated file size. The generated js for this example weighs in at 942KB.

This takes inspiration from projects like https://github.com/philips/grpc-gateway-example.

Generate the proto files

This requires installing the go programs from the vendor folder and protoc. It also assumes you have python3 in your $PATH.

Download the latest protoc from github.com

Install go dependencies:

$ go install ./vendor/...

Generate!

$ ./generate.py

Generate the client

Install gopherjs (note that gopherjs cannot be vendored, see gopherjs/gopherjs#415):

$ go get -u github.com/gopherjs/gopherjs/js

Generate!

$ go generate ./client/

This creates a go-bindata-compiled file which can easily be served from the server.

Running the server

$ go run main.go

Navigate to localhost and check it out!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].