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-redis
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.1.2.tar.gz
(2.8 kB
view details)
Built Distribution
File details
Details for the file taskiq_nats-0.1.2.tar.gz
.
File metadata
- Download URL: taskiq_nats-0.1.2.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.9.16 Linux/5.15.0-1034-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff84f2be99ffe50b2bbb91e938ab4151d1cf2f88f7a0686ab1de47a103f9c9cb |
|
MD5 | 188040e7e1cdeb7ca3603dce8f6354b7 |
|
BLAKE2b-256 | df9fb7eb0ad9135de6af4a7549a4b749a05b565e23e4ee1ace9d027393a778b7 |
File details
Details for the file taskiq_nats-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: taskiq_nats-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.9.16 Linux/5.15.0-1034-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4e4efc87c4cda05adabe8d3334eb27b783c56fb88c0f299064472f14198f6c1 |
|
MD5 | 7c9e391ff617460756b9668663f505fb |
|
BLAKE2b-256 | 0ae1e2153a4685def1c7dfc235f2503ab352262535667700c9c07c9dd1d8a4ed |