This repository is a solution for a Golang Developer role in Nobl9.
It's an implementation of a service that gets random numbers from random.org and calculates standard deviation of the drawn integers and additionally standard deviation of sum of all sets.
- api - OpenAPI definitions
- docker - Dockerfiles, one for production (optimized one ~8Mb, running the application as nonroot) and one for development with live-reload
- cypress/integration - e2e tests specification
- random-generator - application code, it is written using clean architecture approach
Make sure you have installed all of the following prerequisites on your development machine:
- Git - Download & Install Git. OSX and Linux machines typically have this already installed.
- Node.js - Download & Install Node.js and the npm package manager. If you encounter any problems, you can also use this GitHub Gist to install Node.js.
- Docker - Download & Install Docker. Docker is used for building images and running the end-to-end tests.
- Golang - Download & Install Golang.
The applications requires setting up 2 environment variables (when running from docker image, they are set to default values):
- PORT=8080
- CONCURRENT_REQUESTS=5 - Limit of concurrent requests
As the provided date range in a single request might be broad, the random API should be queried concurrently. However, in order not to be recognized as a malicious user, a limit of concurrent requests to this external API must exist.
In order to run the service you can simply run:
make run_app_from_repository
It will automatically get the image from the repository and expose the port on 8080.
In order to run the development environment, that enables the auto-reload so that we can see live changes, run:
make dev_env
In order to run the unit tests, run:
make unit_test
Once the api specification got changed in api/swagger.yml we need to update the code generated from that template. In order to do that, run:
make openapi
In order to run the end-to-end tests using cypress, run:
make e2e_test