RequestDAG — Aquilia Documentation
Comprehensive guide and documentation for RequestDAG in the Aquilia framework. View API reference, examples, and implementation patterns.
Dependency Injection / RequestDAG RequestDAG & Inline Injection The RequestDAG resolves dependencies declared inline via Dep() in route signatures. It compiles a deduplicated, concurrent execution graph per request. One engine. Aquilia previously ran two resolution engines — the Container and a separate FastAPI-Depends-style DAG. They are now unified: the container owns the single engine, and RequestDAG is a thin compatibility shim. The public API is unchanged — RequestDAG(container, request), await dag.resolve(dep, param_type), and await dag.teardown() still work — but the real work now lives in container.resolve_dep(...). All resolution state (cache, teardowns, resolving-set) is held by the container, so inline Dep() deps and constructor-injected services share one deduplicated graph. Core Execution Mechanics , , , , ].map((card, i) => ( ))} Resolution Flow Consider a route handler with deeply nested dependencies: from typing import Annotated from aquilia.di import Dep async def get_db(): print("Opening DB") yield "DB_SESSION" print("Closing DB") async def get_user_repo(db: Annotated[str, Dep(get_db)]): print("Creating UserRepo") return async def get_auth_service(db: Annotated[str, Dep(get_db)]): print("Creating AuthService") return # In your controller class: class MyController(Controller): @get("/dashboard") async def dashboard_view( self, ctx, repo: Annotated[dict, Dep(get_user_repo)], auth: Annotated[dict, Dep(get_auth_service)], ): return Execution Output Trace: Opening DB // Executed only once due to deduplication! Creating UserRepo // Resolved concurrently Creating AuthService HTTP Response sent to client Closing DB // Teardown executed in LIFO order after response Decorators Extractors )
Go to Homepage