mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-11 01:45:58 +00:00
refactor(runtime): add run DDD boundary skeleton
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
"""Realtime stream contracts for run application use cases."""
|
||||
|
||||
from .run_stream_broker import RunStreamBroker, RunStreamEvent
|
||||
|
||||
__all__ = [
|
||||
"RunStreamBroker",
|
||||
"RunStreamEvent",
|
||||
]
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Realtime run stream broker contract."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import AsyncIterator
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Protocol
|
||||
|
||||
from ..domain import RunId
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RunStreamEvent:
|
||||
id: str
|
||||
event: str
|
||||
data: Any
|
||||
|
||||
|
||||
class RunStreamBroker(Protocol):
|
||||
"""Realtime publish/subscribe boundary for run streams."""
|
||||
|
||||
async def publish(self, run_id: RunId, event: str, data: Any) -> None: ...
|
||||
|
||||
async def publish_terminal(self, run_id: RunId, *, event: str = "end", data: Any = None) -> None: ...
|
||||
|
||||
def subscribe(
|
||||
self,
|
||||
run_id: RunId,
|
||||
*,
|
||||
last_event_id: str | None = None,
|
||||
heartbeat_interval: float = 15.0,
|
||||
) -> AsyncIterator[RunStreamEvent]: ...
|
||||
|
||||
async def cleanup(self, run_id: RunId, *, delay: float = 0) -> None: ...
|
||||
|
||||
|
||||
__all__ = [
|
||||
"RunStreamBroker",
|
||||
"RunStreamEvent",
|
||||
]
|
||||
Reference in New Issue
Block a user