|
1 |
| -### Задание 2 |
| 1 | +# Ozon Marketplace Verification API |
2 | 2 |
|
3 |
| -1. Создать репозиторий именование которого указано в таблице прогресса ✅ |
| 3 | +--- |
4 | 4 |
|
5 |
| -2. Описать сущность `{domain}.{Subdomain}` и `{domain}.{Subdomain}Event` в **internal/model/{subdomain}.go** ✅ |
| 5 | +## Build project |
6 | 6 |
|
7 |
| -3. Реализовать паттерн consumer-producer из **db** в **kafka** на основе интерфейсов [EventRepo](https://github.com/ozonmp/omp-demo-api/blob/b847b3ae4a3c9e1d25e31e077c847a22f8b7aa99/internal/app/repo/event.go#L7) и [EventSender](https://github.com/ozonmp/omp-demo-api/blob/b847b3ae4a3c9e1d25e31e077c847a22f8b7aa99/internal/app/sender/event.go#L7) для одного типа события **Created** ✅ |
| 7 | +### Local |
8 | 8 |
|
9 |
| -4. Написать тесты ✅ |
| 9 | +For local assembly you need to perform |
10 | 10 |
|
11 |
| -5. Синхронизацию работы потоков сделать через `context` 💎 ⌛️ |
| 11 | +```zsh |
| 12 | +$ make deps # Installation of dependencies |
| 13 | +$ make build # Build project |
| 14 | +``` |
| 15 | +## Running |
12 | 16 |
|
13 |
| -6. Создавать задачи у workerpool по обработке батчевых идентификаторов записей событий 💎 ⌛️ |
| 17 | +### For local development |
14 | 18 |
|
15 |
| -7. Поддержать несколько типов событий учитывая корректный порядок 💎 🤔 |
| 19 | +```zsh |
| 20 | +$ docker-compose up -d |
| 21 | +``` |
16 | 22 |
|
17 |
| -8. Реализовать гарантию доставки **At-least-once** 💎 🤔 |
| 23 | +--- |
18 | 24 |
|
19 |
| -9. Найти скрытые ошибки в коде 💎 🤔 |
| 25 | +## Services |
| 26 | + |
| 27 | +### Swagger UI |
| 28 | + |
| 29 | +The Swagger UI is an open source project to visually render documentation for an API defined with the OpenAPI (Swagger) Specification |
| 30 | + |
| 31 | +- http://localhost:8080/swagger |
| 32 | + |
| 33 | +### Grafana: |
| 34 | + |
| 35 | +- http://localhost:3000 |
| 36 | +- - login `admin` |
| 37 | +- - password `MYPASSWORT` |
| 38 | + |
| 39 | +### gRPC: |
| 40 | + |
| 41 | +- http://localhost:8082 |
| 42 | + |
| 43 | +```sh |
| 44 | +[I] ➜ grpc_cli call localhost:8082 DescribeVerificationV1 "id: 1" |
| 45 | +connecting to localhost:8082 |
| 46 | +Rpc failed with status code 5, error message: verification not found |
| 47 | +``` |
| 48 | + |
| 49 | +### Gateway: |
| 50 | + |
| 51 | +It reads protobuf service definitions and generates a reverse-proxy server which translates a RESTful HTTP API into gRPC |
| 52 | + |
| 53 | +- http://localhost:8080/api' |
| 54 | + |
| 55 | +```sh |
| 56 | +[I] ➜ curl -s -X 'POST' \ |
| 57 | + 'http://localhost:8080/api/v1/verifications'' \ |
| 58 | + -H 'accept: application/json' \ |
| 59 | + -H 'Content-Type: application/json' \ |
| 60 | + -d '{ |
| 61 | + "id": "1" |
| 62 | +}' | jq . |
| 63 | +{ |
| 64 | + "code": 5, |
| 65 | + "message": "verification not found", |
| 66 | + "details": [] |
| 67 | +} |
| 68 | +``` |
| 69 | +
|
| 70 | +### Metrics: |
| 71 | +
|
| 72 | +Metrics GRPC Server |
| 73 | +
|
| 74 | +- http://localhost:9100/metrics |
| 75 | +
|
| 76 | +### Status: |
| 77 | +
|
| 78 | +Service condition and its information |
| 79 | +
|
| 80 | +- http://localhost:8000 |
| 81 | +- - `/live`- Layed whether the server is running |
| 82 | +- - `/ready` - Is it ready to accept requests |
| 83 | +- - `/version` - Version and assembly information |
| 84 | +
|
| 85 | +### Prometheus: |
| 86 | +
|
| 87 | +Prometheus is an open-source systems monitoring and alerting toolkit |
| 88 | +
|
| 89 | +- http://localhost:9090 |
| 90 | +
|
| 91 | +### Kafka |
| 92 | +
|
| 93 | +Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. |
| 94 | +
|
| 95 | +- http://localhost:9094 |
| 96 | +
|
| 97 | +### Kafka UI |
| 98 | +
|
| 99 | +UI for Apache Kafka is a simple tool that makes your data flows observable, helps find and troubleshoot issues faster and deliver optimal performance. Its lightweight dashboard makes it easy to track key metrics of your Kafka clusters - Brokers, Topics, Partitions, Production, and Consumption. |
| 100 | +
|
| 101 | +- http://localhost:9001 |
| 102 | +
|
| 103 | +### Jaeger UI |
| 104 | +
|
| 105 | +Monitor and troubleshoot transactions in complex distributed systems. |
| 106 | +
|
| 107 | +- http://localhost:16686 |
| 108 | +
|
| 109 | +### Graylog |
| 110 | +
|
| 111 | +Graylog is a leading centralized log management solution for capturing, storing, and enabling real-time analysis of terabytes of machine data. |
| 112 | +
|
| 113 | +- http://localhost:9000 |
| 114 | +- - login `admin` |
| 115 | +- - password `admin` |
| 116 | +
|
| 117 | +### PostgreSQL |
| 118 | +
|
| 119 | +For the convenience of working with the database, you can use the [pgcli](https://github.com/dbcli/pgcli) utility. Migrations are rolled out when the service starts. migrations are located in the **./migrations** directory and are created using the [goose](https://github.com/pressly/goose) tool. |
| 120 | +
|
| 121 | +```sh |
| 122 | +$ pgcli "postgresql://docker:docker@localhost:5432/srv_verification_api" |
| 123 | +``` |
| 124 | +
|
| 125 | +### Python client |
| 126 | +
|
| 127 | +```shell |
| 128 | +$ python -m venv .venv |
| 129 | +$ . .venv/bin/activate |
| 130 | +$ make deps |
| 131 | +$ make generate |
| 132 | +$ cd pypkg/srv-verification-api |
| 133 | +$ python setup.py install |
| 134 | +$ cd ../.. |
| 135 | +$ docker-compose up -d |
| 136 | +$ python scripts/grpc_client.py |
| 137 | +``` |
| 138 | +
|
| 139 | +
|
| 140 | +### Thanks |
| 141 | +
|
| 142 | +- [Evald Smalyakov](https://github.com/evald24) |
| 143 | +- [Michael Morgoev](https://github.com/zerospiel) |
0 commit comments