forked from mtusi2026/mtusi2026lab5
Bring the application, own tests, Dockerfile, toolchain, compose stack, HAProxy, k6 and RustFS configuration, migrations, hooks, evidence and scenario scripts and the CI job from the lab 4 solution commit d2744bc, merge the lab 4 Makefile targets into the lab 5 skeleton Makefile without touching its targets, and append the lab 4 solution variables to the skeleton .env.example. The package and the application follow the contract version 1.5.0, and the image and the throwaway test containers are tagged lab5 so they do not collide with a lab 4 stand on the same host. This is the starting point of the lab 5 cycle: lint, own tests and the offline skeleton check pass before any lab 5 change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
26 lines
695 B
Python
26 lines
695 B
Python
from threading import Event
|
|
|
|
from dishka.integrations.fastapi import FromDishka, inject
|
|
from fastapi import APIRouter
|
|
|
|
from messenger.shared.application.errors import Unavailable
|
|
from messenger.shared.entrypoints.schemas import HealthOut
|
|
from messenger.shared.infrastructure.postgres import Database
|
|
|
|
router = APIRouter(tags=["health"])
|
|
DRAINING = Event()
|
|
|
|
|
|
@router.get("/health/live")
|
|
async def live() -> HealthOut:
|
|
return HealthOut()
|
|
|
|
|
|
@router.get("/health/ready")
|
|
@inject
|
|
async def ready(database: FromDishka[Database]) -> HealthOut:
|
|
if DRAINING.is_set():
|
|
raise Unavailable("Реплика выходит из ротации")
|
|
await database.ping()
|
|
return HealthOut()
|