-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"_type":"export","__export_format":4,"__export_date":"2022-07-03T18:26:47.090Z","__export_source":"insomnia.desktop.app:v2022.4.2","resources":[{"_id":"req_3b62467ff2d34227b94a4924a88b83cd","parentId":"wrk_5ccef32599db4c8cbaaa93b0d6115d9e","modified":1656871847615,"created":1656864004223,"url":"{{ _.url }}/api/v1/monitoring/4","name":"Monitoring data","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1656864004223,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_5ccef32599db4c8cbaaa93b0d6115d9e","parentId":null,"modified":1656718293187,"created":1656718293187,"name":"Price_Monitor","description":"","scope":"collection","_type":"workspace"},{"_id":"req_311f8cf87d764da8aa9f73f3efc3aa26","parentId":"wrk_5ccef32599db4c8cbaaa93b0d6115d9e","modified":1656871831883,"created":1656863460547,"url":"{{ _.url }}/api/v1/monitoring?cur=btcusd&period=20s&freq=4s","name":"Monitoring","description":"","method":"POST","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1656863460547,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_47d327ecb90d4dbcb7fafb6264c220dd","parentId":"wrk_5ccef32599db4c8cbaaa93b0d6115d9e","modified":1656863440068,"created":1656718296495,"url":"{{ _.url }}/health","name":"Health","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1656718296495,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_e68d5f47c7f04549b6f7d0a7b3bff176","parentId":"wrk_5ccef32599db4c8cbaaa93b0d6115d9e","modified":1656863447942,"created":1656863314120,"url":"{{ _.url }}/ready","name":"Ready","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1655013609760.25,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_676a12f9383caffcc46d91b1b81c6ebfe9f1e149","parentId":"wrk_5ccef32599db4c8cbaaa93b0d6115d9e","modified":1656863353650,"created":1656718293193,"name":"Base Environment","data":{},"dataPropertyOrder":{},"color":null,"isPrivate":false,"metaSortKey":1656718293193,"_type":"environment"},{"_id":"jar_676a12f9383caffcc46d91b1b81c6ebfe9f1e149","parentId":"wrk_5ccef32599db4c8cbaaa93b0d6115d9e","modified":1656718293195,"created":1656718293195,"name":"Default Jar","cookies":[],"_type":"cookie_jar"},{"_id":"spc_ecaa4596ed7d4f73b693fd3ec16a99d6","parentId":"wrk_5ccef32599db4c8cbaaa93b0d6115d9e","modified":1656718293189,"created":1656718293189,"fileName":"Price_Monitor","contents":"","contentType":"yaml","_type":"api_spec"},{"_id":"env_e410588d353e478aaab1d3726d298787","parentId":"env_676a12f9383caffcc46d91b1b81c6ebfe9f1e149","modified":1656863411578,"created":1656863358274,"name":"Local","data":{"url":"http://localhost:8080"},"dataPropertyOrder":{"&":["url"]},"color":"#34b80f","isPrivate":false,"metaSortKey":1656863358274,"_type":"environment"},{"_id":"env_bc74addc9c214ec1a294452830da0b72","parentId":"env_676a12f9383caffcc46d91b1b81c6ebfe9f1e149","modified":1656863423974,"created":1656863374166,"name":"Compose","data":{"url":"http://localhost:4000"},"dataPropertyOrder":{"&":["url"]},"color":"#d40c0c","isPrivate":false,"metaSortKey":1656863374166,"_type":"environment"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ sends a request to the service to monitor Bitcoin price for a period of 5 minute | |
1. 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. | ||
2. 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: | ||
|
||
![img](./.img/task_description.png) | ||
|
||
## Solution | ||
|
||
|
@@ -56,9 +59,52 @@ From root of the repository: | |
```curl --request GET --url http://localhost:4000/api/v1/monitoring/1``` | ||
|
||
|
||
TODOS: | ||
Refactor a little bit | ||
1) Implement hexagonal-architecture -> https://medium.com/@matiasvarela/hexagonal-architecture-in-go-cfd4e436faa3 | ||
2) Increase test coverage | ||
3) Add more errors handlers | ||
4) | ||
#### Insomnia examples: | ||
|
||
see in folder -> `.insomnia` | ||
|
||
![img](./.img/example_post.png) | ||
![img](./.img/example_get.png) | ||
|
||
|
||
#### Docker Compose run | ||
|
||
![img](./.img/result_running_service_in_docker_compose.png) | ||
|
||
# TODOS: | ||
|
||
0) Refactor a little (see many todo's) | ||
1) Full-implementing hexagonal-architecture -> https://medium.com/@matiasvarela/hexagonal-architecture-in-go-cfd4e436faa3 | ||
2) Tests-tests-tests -> Increase test coverage (http api tests cases, consul - MUST!) | ||
3) Add more errors handlers | ||
4) Think about better sql select where case (select prices) | ||
5) Add pagination | ||
6) Add Swagger docs | ||
7) Implements 2 and 3 variants of architecture =) | ||
7.1) Compare them in real world with benchmarks | ||
|
||
|
||
## Development | ||
|
||
#### Env up | ||
|
||
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) | ||
|
||
![img](./.img/ide_settings_1.png) | ||
![img](./.img/ide_settings_2.png) | ||
|
||
#### Remove old container or volumes | ||
|
||
make docker_clean_all | ||
|
||
#### Rebuild prod app container | ||
|
||
make rebuild | ||
|
||
Made by Arseny Sazanov 2022 | ||
|
||
[email protected] | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters