0.6.0rc0
Pre-releaseDescription
Taskiq-aio-pika 0.6 is a significant technical release that aimed to address many of the current project design issues and unlock further improvements. We tried our best to minimize breaking changes, but unfortunately, some aspects were simply not working well. Therefore, we decided to break them in order to move forward.
This release includes:
- Multi-queue support;
- Custom settings for queues and exchanges for tasks;
- Support for diffrent types of queues/exchanges;
- A range of minor refactors and improvements.
Breaking changes
Broker parameters
AioPikaBroker now accepts new arguments during initialization. Queues and exchanges are configured using the Queue and Exchange classes and then passed to the broker. The old style of passing only names, routing keys or even unvalidated key arguments is no longer supported.
from taskiq_aio_pika import AioPikaBroker, Queue, QueueType, Exchange
from aio_pika.abc import ExchangeType
broker = AioPikaBroker(
exchange=Exchange(
name="custom_exchange",
type=ExchangeType.TOPIC,
declare=True,
durable=True,
auto_delete=False,
)
task_queues=[
Queue(
name="custom_queue",
type=QueueType.CLASSIC,
declare=True,
durable=True,
max_priority=10,
routing_key="custom_queue",
)
]
)If declare=True is set, the queues and exchange will be declared automatically during broker initialization.
Multi-queue support
You can now define multiple queues for your tasks. Each queue can have its own routing key and settings, and workers can listen either to specific queues or to multiple queues at once.
broker = AioPikaBroker(
exchange=Exchange(
name="custom_exchange",
type=ExchangeType.TOPIC,
declare=True,
durable=True,
auto_delete=False,
)
task_queues=[
Queue(
name="custom_queue",
routing_key="custom_queue",
),
Queue(
name="custom_queue_2",
routing_key="custom_queue_2",
),
]
)Once the broker is configured, you can route a task to a specific queue by adding a label:
await your_cool_task.kicker().with_labels(queue_name='custom_queue').kiq()You can customize the label name used for routing in the broker configuration. Make sure that this label name does not collide with any other labels used in your project.
Full Changelog: 0.5.0...0.6.0rc0