Files
2125_GCE/runtime_executor/events.py
T

38 lines
713 B
Python
Raw Normal View History

from dataclasses import dataclass
from typing import List, Callable, Any
@dataclass
class SegmentStartEvent:
segment_id: str
timestamp: float
@dataclass
class SegmentEndEvent:
segment_id: str
duration: float
timestamp: float
@dataclass
class ExecutionErrorEvent:
segment_id: str
error_msg: str
timestamp: float
class RuntimeEventBus:
def __init__(self):
self._subscribers: List[Callable] = []
def subscribe(self, callback: Callable):
self._subscribers.append(callback)
def publish(self, event: Any):
for callback in self._subscribers:
try:
callback(event)
except Exception:
pass