[Heroku retracted its free tier, therefore all my demos are unavailable until further notice.]
This is a recruitment task for a Junior Software Developer position.
The project is a REST service supporting the following GET operation:
/random/mean?requests={r}&length={l}
which performs {r}
concurrent requests to random.org API asking for {l}
number of random integers.
Additionally, the application calculates standard deviation of each drawn integers set and of the sum of all sets.
The project also has a Semaphore CI/CD pipeline with deployment to Heroku via Docker container:
I decided to use runtime.GOMAXPROCS(1)
, since random.org guidelines (https://www.random.org/clients/) prohibit sending simultaneous requests by automated clients. In accordance with the guidelines the timeout is set to 180 seconds.
- random.org API
- Go 1.18
- go-chi/chi/v5 5.0.7
- google/go-cmp 0.5.8
- joho/godotenv 1.4.0
- montanaflynn/stats 0.6.6
- cosmtrek/air 1.40.4
- Docker
If you want to run the application, you have to supply your own API key and your email address (the guidelines require random.org API client's email supplied in the "User-Agent" header) in the .env file .
-
Create an
.env
file basing on.env_sample_file
from the repository. SetPORT
to 8080. -
Run
docker run --env-file .env -p 8080:8080 bsski/random-ints-st-dev-api:latest
in the.env
file directory. -
Access
localhost:8080/random/mean?requests=2&length=3
.
To run this project, you have to set up the following environment variables in the .env
file (the values below are exemplary):
RANDOM_ORG_API_KEY=af83r3m2-mv82-z327-12m9238hjqdn
[email protected]
PORT=8080
- more tests