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:
@@ -1 +1,24 @@
|
|||||||
# Env var setup that must run before app.config is imported.
|
from collections.abc import AsyncIterator, Awaitable, Callable
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
import pytest
|
||||||
|
from httpx import ASGITransport, AsyncClient
|
||||||
|
|
||||||
|
from app.checker import EndpointChecker
|
||||||
|
from app.main import app
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
async def api_client() -> AsyncIterator[AsyncClient]:
|
||||||
|
async with app.router.lifespan_context(app):
|
||||||
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||||
|
yield client
|
||||||
|
|
||||||
|
|
||||||
|
async def public_resolver(host: str, port: int) -> list[str]:
|
||||||
|
return ["93.184.216.34"]
|
||||||
|
|
||||||
|
|
||||||
|
def install_checker(handler: Callable[[httpx.Request], httpx.Response], resolver: Callable[[str, int], Awaitable[list[str]]] = public_resolver) -> None:
|
||||||
|
client = httpx.AsyncClient(transport=httpx.MockTransport(handler))
|
||||||
|
app.state.checker = EndpointChecker(client, timeout=1, max_redirects=2, max_response_bytes=1024, resolver=resolver)
|
||||||
|
|||||||
Reference in New Issue
Block a user