Skip to content

devpablocristo/growuphr

Repository files navigation

Numbers Manager API


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.

Run the tests

go test -v ./...

Build the API

go build -o num-man cmd/main.go

Run the API

./num-man

With Docker compose

make up

or

docker-compose up

down all the containers

make down

or

docker-compose down --remove-orphans

check status

docker-compose ps

Check if API is up and running (server response: 200)

curl -X GET \
  http://localhost:8080/heartbeat

Reserve a number

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
}'

List numbers

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages