Skip to content

POC in GoLang/RPC to allow sending stream of data from the server to the client

Notifications You must be signed in to change notification settings

karimelhajoui63/realtime-go-rpc

Repository files navigation

POC realtime in GO/RPC (Connect)

The server send a stream to the clients (like websocket or SSE)

go-realtime-server-demo.mp4

Note: After 2 windows (by browser) the calls to the servers are buffered. I don't know why, but it's certainly a browser limitation.


Quick start

With Task (easier)

Just run:

task docker:up_n_open  # need: brew install go-task

Tip: you can see all available tasks we the command: task --list

... or with Docker (still easy)

Run:

docker-compose up

then visit: http://localhost:45871

... or even without Docker (can by tricky)

In one terminal:

cd backend
go run cmd/rpcserver_[rabbitmq|watermill]/main.go

In an other one:

cd frontend
npm run dev

(See README.md in frontend and backend for more info)


Contribution

You can easly contribute, without having to install anything beside Docker, Docker Desktop (personally, I used OrbStack because it seems faster) and Visual Studio Code.

Once the repo is downloaded locally, you can run the command from the VSCode palette: Dev Containers: Reopen in Container

Here, you have your environment setup with all you need. You can browse the Taskfile to see useful commands. You can even start docker containers within the dev container (i.e. docker-compose up rabbitmq for exemple if you need a rabbitmq instance)

Pro tip: use Dev Environments chrome extension to open the repo in one click from GitHub


To-do list

  • Docker: clean hard coded constants
  • Frontend: use 1 connection with the RPC server per sqare on the UI (not only 1 for all of them)
  • Refacto: use Wire to provide cleaner DI (?)

Impressions on DX

  • Golang

The typing system is really cool and bring a lot of feature that improve the DX. Unlike Python, when I run the program, it works on the first time (because the potentiel runtime bug is catch directly from the IDE wile coding) 🔥

  • Hexagonal architecture

It helps to separate logic that souldn't be in the same files, and it really makes it easier to add/swipe an adapter 🔥

  • Connect RPC

Way easier to generate proto stub than with gRPC. It worked the first time (not the case - at all - of gRPC). Plus, it's retro-compatible with the gRPC's API 🔥

  • Dev containers

No more local env issues (plus, it really smooth, identical to local) 🔥


Troubleshooting

  • Cannot git push because of Permission denied (publickey)?

    • Run ssh-add $HOME/.ssh/github_rsa (source)

About

POC in GoLang/RPC to allow sending stream of data from the server to the client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published