07.4.3.18.1 — Runtime Event Skeleton Architecture

This commit is contained in:
2026-05-09 18:21:02 +03:00
parent 3181ac680c
commit 7e5ecc2ed9
22 changed files with 641 additions and 99 deletions

View File

@@ -0,0 +1,9 @@
# app/src/runtime_events/__init__.py
from src.runtime_events.event_types import RuntimeEventType
from src.runtime_events.models import RuntimeEvent
__all__ = [
"RuntimeEvent",
"RuntimeEventType",
]

View File

@@ -0,0 +1,17 @@
# app/src/runtime_events/event_types.py
from __future__ import annotations
from enum import Enum
class RuntimeEventType(str, Enum):
AUTO_SIGNAL_READY = "auto_signal_ready"
POSITION_OPENED = "position_opened"
POSITION_CLOSED = "position_closed"
POSITION_FLIPPED = "position_flipped"
EXECUTION_BLOCKED = "execution_blocked"
RISK_ALERT = "risk_alert"
SYSTEM_ALERT = "system_alert"

View File

@@ -0,0 +1,20 @@
# app/src/runtime_events/models.py
from __future__ import annotations
from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import Any
from src.runtime_events.event_types import RuntimeEventType
@dataclass(slots=True)
class RuntimeEvent:
event_type: RuntimeEventType
source: str
title: str
payload: dict[str, Any] = field(default_factory=dict)
priority: str = "normal"
dedupe_key: str | None = None
created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))

View File

@@ -0,0 +1,19 @@
# app/src/runtime_events/publisher.py
from __future__ import annotations
import asyncio
from src.notifications.service import NotificationService
from src.runtime_events.models import RuntimeEvent
class RuntimeEventPublisher:
@classmethod
def publish(cls, event: RuntimeEvent) -> None:
try:
loop = asyncio.get_running_loop()
except RuntimeError:
return
loop.create_task(NotificationService().handle_runtime_event(event))