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.
Some checks failed
ci / validate (push) Has been cancelled
Some checks failed
ci / validate (push) Has been cancelled
This commit is contained in:
54
src/endpoint_monitor/models.py
Normal file
54
src/endpoint_monitor/models.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from enum import Enum
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
from pydantic import AnyHttpUrl, BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
|
|
||||||
|
class MonitorStatus(str, Enum):
|
||||||
|
UNKNOWN = "unknown"
|
||||||
|
UP = "up"
|
||||||
|
DOWN = "down"
|
||||||
|
ERROR = "error"
|
||||||
|
|
||||||
|
|
||||||
|
class MonitorCreate(BaseModel):
|
||||||
|
name: str = Field(min_length=1, max_length=100, pattern=r".*\S.*")
|
||||||
|
url: AnyHttpUrl
|
||||||
|
|
||||||
|
|
||||||
|
class MonitorUpdate(BaseModel):
|
||||||
|
name: str | None = Field(default=None, min_length=1, max_length=100, pattern=r".*\S.*")
|
||||||
|
url: AnyHttpUrl | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class CheckResult(BaseModel):
|
||||||
|
status: MonitorStatus
|
||||||
|
checked_at: datetime
|
||||||
|
latency_ms: float = Field(ge=0)
|
||||||
|
http_status: int | None = None
|
||||||
|
final_url: str | None = None
|
||||||
|
detail: str | None = Field(default=None, max_length=300)
|
||||||
|
|
||||||
|
|
||||||
|
class Monitor(BaseModel):
|
||||||
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
|
id: UUID
|
||||||
|
name: str
|
||||||
|
url: AnyHttpUrl
|
||||||
|
created_at: datetime
|
||||||
|
updated_at: datetime
|
||||||
|
revision: int
|
||||||
|
status: MonitorStatus = MonitorStatus.UNKNOWN
|
||||||
|
last_check: CheckResult | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class StatusView(BaseModel):
|
||||||
|
id: UUID
|
||||||
|
status: MonitorStatus
|
||||||
|
last_check: CheckResult | None
|
||||||
|
|
||||||
|
|
||||||
|
class Health(BaseModel):
|
||||||
|
status: str
|
||||||
Reference in New Issue
Block a user