mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-22 07:56:48 +00:00
refactor(gateway): restructure gateway with new dependency injection and services
Reorganize app/gateway/ with: - common/ - lifespan management - dependencies/ - FastAPI dependency injection (db, checkpointer, repositories, stream_bridge) - services/runs/ - run execution services (facade_factory, input adapters, store operations) - registrar.py - router registration - router.py - main router setup Simplify app.py to use the new modular structure. Remove deprecated utils.py. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Depends, HTTPException, Request
|
||||
from langgraph.types import Checkpointer
|
||||
|
||||
|
||||
def get_checkpointer(request: Request) -> Checkpointer:
|
||||
"""Get checkpointer from app.state.persistence."""
|
||||
persistence = getattr(request.app.state, "persistence", None)
|
||||
if persistence is None:
|
||||
raise HTTPException(status_code=503, detail="Persistence not available")
|
||||
checkpointer = getattr(persistence, "checkpointer", None)
|
||||
if checkpointer is None:
|
||||
raise HTTPException(status_code=503, detail="Checkpointer not available")
|
||||
return checkpointer
|
||||
|
||||
|
||||
CurrentCheckpointer = Annotated[Checkpointer, Depends(get_checkpointer)]
|
||||
Reference in New Issue
Block a user