Example of gRPC application between node and golang.
This handle high CPU tasks by assiging it to a more performantic language (golang) to do the job.
On this example, it will receive a number called nonce, and it will find what number added to it, that the hash value will start with 6 zeros in a row.
Thats a very long calculation. so we using go to spread this job on multiple CPU cores.
It queue pending jobs using Bull js and store the queue on Redis.
Current list of complete jobs, pending and being processed can be accessed by websocket connection.
Use this route to add a number to be processed.
and then you can watch the progress on the websocket client.
$ pnpm install
# development
$ pnpm start
# watch mode
$ pnpm dev
# production mode
$ pnpm start
This project is currently using a go grpc server
Generating grpc files
Run this command while inside grpc folder
protoc \
--go_out=solver/ \
--go_opt=paths=source_relative \
--go-grpc_out=solver/ \
--go-grpc_opt=paths=source_relative solver.proto
just run
go run main.go
To start go gRPC server
This apllication requires redis running on port 6379 (default) Used to manage queue
located at /api
Auto generated documentation for all routes inside the application.
# create image and containers
docker-compose create
# start server and services
docker-compose start
urls:
# server and api documentation
http://localhost:8000/api
# websocket client to see jobs being processed
http://localhost:3000