Effects Acquisition — Aquilia Documentation
Comprehensive guide and documentation for Effects Acquisition in the Aquilia framework. View API reference, examples, and implementation patterns.
MIDDLEWARE / EFFECTS ACQUISITION EffectMiddleware & FlowContextMiddleware These middlewares integrate the Effects capability-resolution system with the ASGI HTTP pipeline, enabling automatic acquisition and releasing of transactional resources. 1. EffectMiddleware The EffectMiddleware inspects handler route declarations (like @requires()) at request start, calls the active providers to acquire the resources, and cleans them up after the handler finishes executing. effect_registry: EffectRegistry | None = None — The registry carrying registered side-effect providers. auto_detect: bool = True — Enables automatic inspection of __flow_effects__ on route handlers. 2. FlowContextMiddleware The FlowContextMiddleware sets up a thread-safe context object carrying request and capability states, exposing them to sub-guards or nested call pipelines. Usage Example from aquilia.middleware_ext import EffectMiddleware, FlowContextMiddleware from aquilia.workspace import Workspace from aquilia.integrations import MiddlewareChain workspace = Workspace("myapp").middleware( MiddlewareChain() .use("aquilia.middleware_ext.effect_middleware:FlowContextMiddleware", priority=15) .use("aquilia.middleware_ext.effect_middleware:EffectMiddleware", priority=16) ) Overview )
Go to Homepage