PLBA2-2. Реализация

This commit is contained in:
2026-10-10 19:36:32 +03:00
parent 473cde126f
commit 71998a6b13
120 changed files with 3675 additions and 21 deletions
+48
View File
@@ -0,0 +1,48 @@
from collections.abc import Awaitable, Callable, Mapping
from dataclasses import dataclass, field
from enum import StrEnum
from typing import Any
class HealthStatus(StrEnum):
OK = "ok"
DEGRADED = "degraded"
UNHEALTHY = "unhealthy"
class WorkerLifecycle(StrEnum):
NEW = "new"
STARTING = "starting"
RUNNING = "running"
STOPPING = "stopping"
STOPPED = "stopped"
FAILED = "failed"
@dataclass(frozen=True, slots=True)
class ComponentHealth:
status: HealthStatus = HealthStatus.OK
critical: bool = True
detail: str | None = None
meta: Mapping[str, Any] = field(default_factory=dict)
HealthCheck = Callable[[], Awaitable[ComponentHealth]]
WorkerProcess = Callable[[], Awaitable[None]]
@dataclass(frozen=True, slots=True)
class WorkerDefinition:
name: str
process: WorkerProcess
critical: bool = True
health_check: HealthCheck | None = None
@dataclass(frozen=True, slots=True)
class WorkerSnapshot:
name: str
lifecycle: WorkerLifecycle
health: ComponentHealth
last_error: BaseException | None = None