Skip to main content

an other async nsq client library

Project description

aonsq

an other async nsq client library

Example

import orjson
import asyncio
from datetime import datetime, timezone
from loguru import logger

from aonsq import NSQMessage, NSQ

async def msg_handler(msg: NSQMessage) -> bool:
    logger.debug(f"msg: {msg.id}")
    return True


async def test():
    mq = NSQ(host="127.0.0.1", port=4071)
    await mq.connect()
    await mq.sub("demo", "test", msg_handler)

    while True:
        for j in range(1000):
            await mq.pub("demo", orjson.dumps({"id": j, "ts_created": datetime.now(timezone.utc)}))

        await asyncio.sleep(1)

try:
    asyncio.get_event_loop().run_until_complete(test())
except KeyboardInterrupt:
    pass

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

aonsq-0.0.6.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

aonsq-0.0.6-py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 3

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