The test task. Creating a tiny service which allows to monitor Bitcoin prices over a specified period of time with specified frequency.
The task is it to create a tiny service which allows to monitor Bitcoin prices over a specified period of time with specified frequency. For example a user sends a request to the service to monitor Bitcoin price for a period of 5 minutes with frequency every 10 seconds. User is assumed to be able to do 2 operations:
- Call the service with period and frequency parameters, which will start monitoring. Returns monitoring ID. A user can start many monitors in parallel without waiting for previous monitors to finish.
- Call the service with monitoring ID to check if monitoring is complete and to get results (if monitoring is not finished yet, return some kind of error).
Full task description:
I have chosen first approach.
ERP
- Docker and Docker Compose
- Be sure that your system support Makefile more_info
- Optional Go (for local development) Go install
And set up envs: PM_POSTGRES_USER
and PM_POSTGRES_PASSWORD
Like this (cat .env):
PM_POSTGRES_USER=pm
PM_POSTGRES_PASSWORD=superpswd
From root of the repository:
make start
make stop
-
Health check
curl --request GET --url http://localhost:4000/health
-
Start monitoring
curl --request POST --url http://localhost:4000/api/v1/monitoring?cur=btcusd&period=1m&freq=10s
-
Get results of monitoring
curl --request GET --url http://localhost:4000/api/v1/monitoring/1
Optional:
-
Get result monitoring and delete monitoring record from db
curl --request GET --url http://localhost:4000/api/v1/monitoring/1?delete=true
see in folder -> .insomnia
- Refactor a little (see many todo's)
- Full-implementing hexagonal-architecture -> https://medium.com/@matiasvarela/hexagonal-architecture-in-go-cfd4e436faa3
- Tests-tests-tests -> Increase test coverage (http api tests cases, consul - MUST!)
- Add more errors handlers
- Think about better sql select where case (select prices)
- Add pagination
- Add Swagger docs
- Implements 2 and 3 variants of architecture =) 7.1) Compare them in real world with benchmarks
make dev_env_up
After that can run go app (in JetBrains IDE or VSCode) (do not forget set up .env file and add ENVs)
make docker_clean_all
make rebuild
Made by Arseny Sazanov 2022
MIT