mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-04-25 11:18:22 +00:00
Add app/infra/ package with: - storage/ - repository adapters for runs, run_events, thread_meta - run_events/ - JSONL-based event store with factory - stream_bridge/ - memory and redis adapters for SSE streaming This layer provides the persistence abstractions used by the gateway services, replacing the old deerflow/persistence modules. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
26 lines
833 B
Python
26 lines
833 B
Python
"""Factory for app-owned run event store backends."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
|
|
|
from app.infra.storage import AppRunEventStore
|
|
from deerflow.config import get_app_config
|
|
|
|
from .jsonl_store import JsonlRunEventStore
|
|
|
|
|
|
def build_run_event_store(session_factory: async_sessionmaker[AsyncSession]) -> AppRunEventStore | JsonlRunEventStore:
|
|
"""Build the run event store selected by app configuration."""
|
|
|
|
config = get_app_config().run_events
|
|
if config.backend == "db":
|
|
return AppRunEventStore(session_factory)
|
|
if config.backend == "jsonl":
|
|
return JsonlRunEventStore(
|
|
base_dir=Path(config.jsonl_base_dir),
|
|
)
|
|
raise ValueError(f"Unsupported run event backend: {config.backend}")
|