Skip to main content

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


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.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

taskiq_nats-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file taskiq_nats-0.1.0.tar.gz.

File metadata

  • Download URL: taskiq_nats-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-1034-azure

File hashes

Hashes for taskiq_nats-0.1.0.tar.gz
Algorithm Hash digest
SHA256 460fb69c8cd4f3ec8389aa9139494ad092b6d7842a9b9e740aa6791b74fec005
MD5 07fcd4d416f48d35ced56a742ae3b57c
BLAKE2b-256 57174a5791a5e2e6fcbe8153262c8b9980ad0b72c36b111167228dd3c67f1472

See more details on using hashes here.

File details

Details for the file taskiq_nats-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: taskiq_nats-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-1034-azure

File hashes

Hashes for taskiq_nats-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 675d1762609304c4924ff1950b04bcb996755cc7ac66ab6b64bf743963db0daa
MD5 f8ae8e1849833e1e8df3bc9123eb7938
BLAKE2b-256 a03875f4916223beabdf278588c416dbcd7616e1e1fe3e05a60ba775ae515072

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page