ansq - Async NSQ
Written with native Asyncio NSQ package
Installation
python -m pip install ansq
Overview
Reader— high-level class for building consumers withnsqlookupdsupportWriter— high-level producer class supporting async publishing of messages tonsqdover the TCP protocolNSQConnection— low-level class representing a TCP connection tonsqd:- full TCP wrapper
- one connection for
subandpub - self-healing: when the connection is lost, reconnects, sends identify and auth commands, subscribes to previous topic/channel
Features
- SUB
- PUB
- Discovery
- Backoff
- TLS
- Deflate
- Snappy
- Sampling
- AUTH
Usage
Consumer
A simple consumer reads messages from "example_topic" and prints them to stdout.
import asyncio
import ansq
async def main():
reader = await ansq.create_reader(
topic="example_topic",
channel="example_channel",
)
async for message in reader.messages():
print(f"Message: {message.body}")
await message.fin()
await reader.close()
if __name__ == "__main__":
asyncio.run(main())
Producer
A simple producer sends a "Hello, world!" message to "example_topic".
import asyncio
import ansq
async def main():
writer = await ansq.create_writer()
await writer.pub(
topic="example_topic",
message="Hello, world!",
)
await writer.close()
if __name__ == "__main__":
asyncio.run(main())
Contributing
Create and activate a development virtual environment.
python -m venv venv
source venv/bin/activate
Install ansq in editable mode and its testing dependencies.
python -m pip install -e .[testing]
Run tests.
pytest
Metadata
Release files for ansq 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ansq-0.3.0.tar.gz | 28.8 kB | Without provenance | Details for ansq-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ansq-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for ansq-0.3.0-py3-none-any.whl |
Total release size: 57.5 kB
Release files / ansq-0.3.0.tar.gz
| Download URL | ansq-0.3.0.tar.gz |
|---|---|
| Size | 28.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec35ad42eed8f100ac0f14067b1bda43938b68de22bc0f22ec990e05036dabfb
|
|
BLAKE2b-256 checksum How to use checksums |
418992a1027653401655a947b755ae17e857623d62305ef14e75b71894a217cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ansq-0.3.0-py3-none-any.whl
| Download URL | ansq-0.3.0-py3-none-any.whl |
|---|---|
| Size | 28.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40659c6b25aef0e03608aadf6b4c78f235273afafd8b002bfde8f0e1d64ade36
|
|
BLAKE2b-256 checksum How to use checksums |
258083aca9e509ac0c34c19adae8d7cce36db89d7f0aba7a3d070ee4c05b6da7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for ansq 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.