add http server

This commit is contained in:
2024-08-10 02:15:00 +03:00
parent 6a2489a65c
commit ba6ac26bac
9 changed files with 380 additions and 14 deletions

View File

@ -16,3 +16,29 @@ Plans to add the following databases:
TODO, but!
All dependencies will be covered by docker.
## Architecture
This application contains just of two layers:
- External Layer that accepts http connections
- Store Layer that stores entities inside some store hidden by implementation for specific database.
During to simple logic, there is no need to add additional business-logic layer since its all about
saving incoming metrics into database.
### External Layer
Typically simple HTTP Server which allows to interact with application by the following handlers:
| Handler | Request | Parameters | Description |
| ------------- | ------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------- |
| Upsert metric | POST `/api/v1/stats/{id}` | {id} -- ID of the device. String. JSON-encoded body for stats (see below for model) | Upserts stats for the passed device |
| List metrics | GET `/api/v1/stats` | <Not Applicable> | Lists all available metrics |
### Store Layer
Provides two methods to interacts with statistics:
- `List` - list available metrics;
- `Upsert` - update metric by device id.