Solution for the proposed challenge. It is written entirely in Golang and it uses an in-memory database.
To demonstrate horizontal scaling, I created 3 instances that run concurrently, configured on ports 8080, 8081, and 8082.
go test -v ./...
go build -o num-man cmd/main.go
./num-man
make up
or
docker-compose up
make down
or
docker-compose down --remove-orphans
docker-compose ps
curl -X GET \
http://localhost:8080/heartbeat
curl -X POST \
http://localhost:8080/api/v1/number-manager/reserve/client1 \
-d '{
"number": 1
}'
curl -X POST \
http://localhost:8081/api/v1/number-manager/reserve/client2 \
-d '{
"number": 2
}'
curl -X POST \
http://localhost:8082/api/v1/number-manager/reserve/client3 \
-d '{
"number": 3
}'
curl -X GET \
localhost:8080/api/v1/number-manager/reserved-numbers
curl -X GET \
localhost:8081/api/v1/number-manager/reserved-numbers
curl -X GET \
localhost:8082/api/v1/number-manager/reserved-numbers