Examples of streaming and otherwise sending gRPC from a go backend to clients using a dog tracker. Data is sent from the backend via these methods:
- gRPC
- gRPC-gateway(JSON over http)
- grpc-websocket-proxy(JSON over websockets),
- grpc-web
These sending methods enable you to generate interfaces and models with gRPC once, and to be called in multiple different ways. The most important way this helps you leverage code is by streaming to a web client.
go run backend/cmd/server/main.go
Javascript web client using json over websockets for streaming
npm i
npm start
- Navigate to http://localhost:8080
Javascript web client using grpc over grpc-web
npm i
npm start
- Navigate to http://localhost:8080
Per the example, our JSON documentation generates to :8082/docs/{proto_name}
http://localhost:8082/docs/dog
Look at the backend logs to see the initialization of each dog location ID. The IDs listed can be entered into the client and used to receive dogs that are currently in those locations.