forked from mtusi2026/mtusi2026lab3
Put readiness behind a port and log the drain window through Logger
The /health/ready route imported the PostgreSQL adapter and kept the drain flag in the HTTP layer, which gunicorn_conf imported to raise it. Readiness is now a port of the shared application layer; its adapter in shared/infrastructure checks the per-process drain flag and pings PostgreSQL, and PlatformProvider assembles it. The route only knows the port, and gunicorn_conf raises the flag through the infrastructure module. Another critical dependency now changes the adapter and the provider, not the HTTP layer. The drain window was logged by a uvicorn logger with a printf string; it is now the service.draining event of a StructlogLogger with the same fields as the application, and failover-evidence looks for it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
aa1485bd86
commit
d99a48a5db
@@ -2,10 +2,10 @@
|
||||
|
||||
- [x] 1.1 `RequestPipeline`: отмена задачи → `request.cancelled`, `503 unavailable` в общем формате, если ответ не начат, затем отмена пробрасывается
|
||||
- [x] 1.2 `test_drain.py`: прерванный при остановке запрос — `503`, `application/json`, `error.code = unavailable`, `request_id` = `X-Request-Id`, непустой `X-Instance-Id`
|
||||
- [ ] 1.3 Порт `Readiness`, адаптер `DatabaseReadiness` с флагом `DRAINING` в `shared/infrastructure/readiness.py`, сборка в `PlatformProvider`, маршрут `/health/ready` через порт; тест состава модулей ядра
|
||||
- [ ] 1.4 `gunicorn_conf.py`: флаг из инфраструктуры, событие `service.draining` через `StructlogLogger`; `failover-evidence.sh` ищет его в логе
|
||||
- [ ] 1.5 `openspec/config.yaml`: карта модулей (`readiness` за портом)
|
||||
- [ ] 1.6 Проверка группы: `make lint`, `make student-test`, `make check`
|
||||
- [x] 1.3 Порт `Readiness`, адаптер `DatabaseReadiness` с флагом `DRAINING` в `shared/infrastructure/readiness.py`, сборка в `PlatformProvider`, маршрут `/health/ready` через порт; тест состава модулей ядра
|
||||
- [x] 1.4 `gunicorn_conf.py`: флаг из инфраструктуры, событие `service.draining` через `StructlogLogger`; `failover-evidence.sh` ищет его в логе
|
||||
- [x] 1.5 `openspec/config.yaml`: карта модулей (`readiness` за портом)
|
||||
- [x] 1.6 Проверка группы: `make lint`, `make student-test`, `make check`
|
||||
|
||||
## 2. Стенд и CI
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ context: |
|
||||
main.py сборка приложения: собирает вклады зон в один процесс
|
||||
migrate.py одноразовая точка входа: применяет SQL-миграции под advisory lock
|
||||
gunicorn_conf.py конфигурация процесса: воркеры, окно вывода из ротации по SIGTERM
|
||||
(DrainingServer, MessengerWorker; флаг готовности — shared/entrypoints/health)
|
||||
(DrainingServer, MessengerWorker; флаг вывода — shared/infrastructure/readiness)
|
||||
identity/ пользователи, пароли и сессии: ошибки, события, команды, значения, порты,
|
||||
адаптеры PostgreSQL/Valkey/Argon2 и весь свой HTTP-слой, включая аутентификацию
|
||||
messaging/ чаты, история и идемпотентная отправка: ошибки, события, команды, агрегат Chat,
|
||||
курсор, адаптеры PostgreSQL и весь свой HTTP-слой
|
||||
shared/ только платформа: domain / application / infrastructure (часы, id, журнал,
|
||||
пул PostgreSQL, UoW-база) и entrypoints/ (конвейер, health, ошибки, настройки,
|
||||
идентификатор реплики)
|
||||
пул PostgreSQL, UoW-база, готовность за портом Readiness) и entrypoints/
|
||||
(конвейер, health, ошибки, настройки, идентификатор реплики)
|
||||
|
||||
Стрелки указывают внутрь: `domain/` не импортирует инфраструктуру, `application/` зависит только
|
||||
от портов, адаптеры подключаются в `ioc.py` зоны. Ядро `shared/` не импортирует веб-фреймворк.
|
||||
|
||||
Reference in New Issue
Block a user