decomposer: generate deliverable files for Define the service contract and project architecture for the FastAPI endpoint monitoring service.; Implement the typed monitor CRUD API and concurrency-safe in-memory state according to the service design.; Implement secure on-demand endpoint checks with status updates, latency measurement, robust error handling, and redacted structured logs.; Add operational API endpoints and environment-driven runtime configuration to the monitoring service.; Create automated tests for the monitoring service.; Package the service with Docker and developer documentation.; Validate the complete project.

This commit is contained in:
2026-08-09 15:38:28 +00:00
parent 9a8f3f8d06
commit ba485e182b

View File

@@ -1 +1,25 @@
# Env var setup that must run before app.config is imported.
from collections.abc import AsyncIterator
import httpx
import pytest
from httpx import ASGITransport, AsyncClient
from monitor_service.api import create_app
from monitor_service.checker import CheckOutcome
from monitor_service.config import Settings
from monitor_service.models import CurrentStatus, MonitorState, utc_now
class StubChecker:
async def check(self, monitor_id: object, url: str) -> CheckOutcome:
return CheckOutcome(url.split("?", 1)[0], CurrentStatus(
state=MonitorState.up, checked_at=utc_now(), latency_ms=1.25, http_status=204
))
@pytest.fixture
async def client() -> AsyncIterator[AsyncClient]:
app = create_app(Settings(), checker=StubChecker()) # type: ignore[arg-type]
async with app.router.lifespan_context(app):
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as api:
yield api