NATS integration for taskiq
Project description
Taskiq NATS
Taskiq-nats is a plugin for taskiq that adds NATS broker.
Installation
To use this project you must have installed core taskiq library:
pip install taskiq taskiq-nats
Usage
Here's a minimal setup example with a broker and one task.
import asyncio
from taskiq_nats import NatsBroker
broker = NatsBroker(
[
"nats://nats1:4222",
"nats://nats2:4222",
],
queue="random_queue_name",
)
@broker.task
async def my_lovely_task():
print("I love taskiq")
async def main():
await broker.startup()
await my_lovely_task.kiq()
await broker.shutdown()
if __name__ == "__main__":
asyncio.run(main())
NatsBroker configuration
Here's the constructor parameters:
servers
- a single string or a list of strings with nats nodes addresses.subject
- name of the subect that will be used to exchange tasks betwee workers and clients.queue
- optional name of the queue. By default NatsBroker broadcasts task to all workers, but if you want to handle every task only once, you need to supply this argument.result_backend
- custom result backend.task_id_generator
- custom function to generate task ids.- Every other keyword argument will be sent to
nats.connect
function.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
taskiq_nats-0.3.0.tar.gz
(2.7 kB
view details)
Built Distribution
File details
Details for the file taskiq_nats-0.3.0.tar.gz
.
File metadata
- Download URL: taskiq_nats-0.3.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.9.16 Linux/5.15.0-1038-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08a16016a4cfb1043281b0906097147a88d47ffac303f9c7170b124bb407630b |
|
MD5 | 9bf07032348477a0b45454f471bf1c5a |
|
BLAKE2b-256 | b15784a6154158b96d012d1fe2fbd188061ecd6f3c4274cc199aae29ce282d23 |
File details
Details for the file taskiq_nats-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: taskiq_nats-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.9.16 Linux/5.15.0-1038-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e820537d54b9af6fb0086d9d5effeb56a72e34f5f2505e090dab6a14952cbc3 |
|
MD5 | db9a7d697b8d6b0b9504c43b74a072bb |
|
BLAKE2b-256 | 2ba2fea847c532997a31621c152075b896b3eecdb314c54b2b6eda79dc85ef5a |