arq¶
Though it is not required, you can use dishka-arq integration. It features:
automatic REQUEST scope management using middleware
injection of dependencies into task handler function using decorator.
How to use¶
Import
from dishka.integrations.arq import (
FromDishka,
inject,
setup_dishka,
)
Create provider and container as usual
Mark those of your handlers parameters which are to be injected with
FromDishka[]and decorate them using@inject
@inject
async def get_content(
context: dict[Any, Any],
gateway: FromDishka[Gateway],
):
...
Setup
dishkaintegration on yourWorkerclass or directly onWorkerSettings
setup_dishka(container=container, worker_settings=WorkerSettings)