Configuration — Aquilia Documentation
Comprehensive guide and documentation for Configuration in the Aquilia framework. View API reference, examples, and implementation patterns.
Background Tasks / Configuration Tasks Configuration Complete configuration specifications for background tasks. Learn how to configure workers, retries, periodic intervals, and custom backends at the workspace and module levels. Integration Configuration Styles Aquilia supports two styles of declaring subsystem integrations within workspace.py: the legacy builder-class style and the modern typed-dataclass style. Modern Style: Composed Dataclasses (Recommended) Construct the TasksIntegration class directly. This ensures compile-time validation, IDE type hinting, and strict parameter checking. # workspace.py from aquilia import Workspace, Module from aquilia.integrations import TasksIntegration workspace = ( Workspace("myapp") .module(Module("core")) .integrate(TasksIntegration( backend="memory", num_workers=8, default_queue="default", scheduler_tick=5.0, cleanup_interval=60.0, cleanup_max_age=600.0, max_retries=5, retry_delay=1.5, retry_backoff=2.0, retry_max_delay=120.0, default_timeout=180.0, dead_letter_max=500, auto_start=True )) ) Legacy Style: Static Integration Builders The legacy Integration.tasks() helper delegates to the modern TasksIntegration under the hood. Avoid this in new projects. # workspace.py (Legacy) from aquilia import Workspace from aquilia.integrations import Integration workspace = ( Workspace("myapp") .integrate(Integration.tasks( num_workers=4, scheduler_tick=15.0, )) ) Warning: The legacy static helper Integration.tasks() is deprecated and will be removed in a future release. Migrate to direct constructor calls using TasksIntegration. TasksIntegration Parameters Parameter Type Default Description ))} Module Manifest & ComponentRef Instead of declaring component imports as bare string paths, Aquilia v2 recommends using the ComponentRef class inside manifest.py. This offers typed metadata checks during boot scans. # modules/core/manifest.py from aquilia import AppManifest, ComponentRef, ComponentKind manifest = AppManifest( name="core", controllers=[ # Controller component references ComponentRef( class_path="modules.core.controllers:NotificationsController", kind=ComponentKind.CONTROLLER ) ], tasks=[ # Task component references ComponentRef( class_path="modules.core.tasks:send_notification", kind=ComponentKind.TASK ), ComponentRef( class_path="modules.core.tasks:cleanup_logs", kind=ComponentKind.TASK ) ], ) Direct TaskManager Setup To run task workers in standalone scripts, background processes, or daemon systems, construct the manager manually: import asyncio from aquilia.tasks import TaskManager, MemoryBackend async def run_worker(): backend = MemoryBackend() manager = TaskManager( backend=backend, num_workers=4, scheduler_tick=1.0 ) await manager.start() try: # Keep running while True: await asyncio.sleep(3600) finally: await manager.stop() if __name__ == "__main__": asyncio.run(run_worker()) )
Go to Homepage