Python bindings for tokio-memq
Project description
tokio-memq-python
Python bindings for tokio-memq.
Installation
pip install tokio-memq-python
Usage
Basic Usage
import asyncio
from tokio_memq import MessageQueue, TopicOptions
async def main():
mq = MessageQueue()
publisher = mq.publisher("test_topic")
# Publish
await publisher.publish({"key": "value"})
# Subscribe
subscriber = await mq.subscriber("test_topic")
msg = await subscriber.recv()
print(msg)
if __name__ == "__main__":
asyncio.run(main())
Partitioned Topics
You can create topics with multiple partitions to scale consumption and manage data distribution.
import asyncio
from tokio_memq import MessageQueue
async def main():
mq = MessageQueue()
topic = "partitioned_topic"
# Create a topic with 3 partitions
await mq.create_partitioned_topic(topic, 3)
# Set routing strategy (optional, default is RoundRobin)
# Available strategies: "RoundRobin", "Random", "Hash", "Fixed"
# Example 1: Round Robin (default) - distributes messages evenly
await mq.set_partition_routing(topic, "RoundRobin")
# Example 2: Hash routing - ensures messages with same key go to same partition
# Use "message" to use the message key provided during publish
await mq.set_partition_routing(topic, "Hash", key="message")
# Create publisher
pub = mq.publisher(topic)
# Publish with key for Hash routing
# All messages with key="user1" will go to the same partition
await pub.publish({"user": "user1", "data": "A"}, key="user1")
await pub.publish({"user": "user1", "data": "B"}, key="user1")
# Subscribe to a specific partition (e.g., partition 0)
sub0 = await mq.subscribe_partition(topic, 0)
# Receive messages
while True:
msg = await sub0.recv()
print(f"Received from P0: {msg}")
if __name__ == "__main__":
asyncio.run(main())
API Reference
MessageQueue
publisher(topic): Get a publisher for a topic.subscriber(topic): Subscribe to a topic (auto-creates if not exists).subscriber_with_options(topic, options): Subscribe with custom options.create_partitioned_topic(topic, partition_count, options=None): Create a partitioned topic.set_partition_routing(topic, strategy, key=None, fixed_id=None): Set routing strategy.subscribe_partition(topic, partition_id): Subscribe to a specific partition.get_partition_stats(topic, partition_id): Get stats for a partition.list_partitioned_topics(): List all partitioned topics.delete_partitioned_topic(topic): Delete a partitioned topic.
Publisher
publish(data, key=None): Publish a message (dict/object).keyis used for Hash routing.
Subscriber
recv(): Receive next message (async).try_recv(): Try to receive (non-blocking).
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tokio_memq_python-0.1.1.tar.gz.
File metadata
- Download URL: tokio_memq_python-0.1.1.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2258c6d8adf8b5a034f807d292293dcd3319012d5b0dc4e2ad1536327819f156
|
|
| MD5 |
762f54b474738e1c523aa00be210c256
|
|
| BLAKE2b-256 |
1a25c00a9c4653147993bdcf874aa7ffb3356ed0550a5191c57663b41647e9a4
|
File details
Details for the file tokio_memq_python-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ae5193565ad7ef731848bf3b395fb65742899e83220fbb420430183597f815d
|
|
| MD5 |
ab9679d2ee484e17f3d0dd57e2835c99
|
|
| BLAKE2b-256 |
3a3b0637492cbc477257e470ccd726a42678aa067407827b12cd33916cc487d9
|
File details
Details for the file tokio_memq_python-0.1.1-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 1.5 MB
- Tags: PyPy, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f47a3348de3cc15f1c33d9fd35a8fe76d12466d0a2429607b87b0be2db93682
|
|
| MD5 |
e5aac109b876c482ee735bcf06ab833b
|
|
| BLAKE2b-256 |
3268a96afa39654a4b3043be7f2c7d4ba1e96e231f7d875c1c53059b6ff44e0c
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51697378633f0027340a92a4650b470fba8c619acdbf8eb4fe0211a9b9077344
|
|
| MD5 |
608d0868b5caad7c1a9084de14c03796
|
|
| BLAKE2b-256 |
b4ea9dcef2afbec14f2908fed8b1129b751af69369a316fc1bbadbf51f67a1fc
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3c0a226505a3cb4df3634db77b1577fef5743c0d0a2ca4b2f2b9bbd0ef2d17f
|
|
| MD5 |
aa6eb4560c8a0287872aacfc114ce5d6
|
|
| BLAKE2b-256 |
963c73c0f70ab329ec1b5d7f67e1f4d033ce88691e5ca49f21c6ca58c544f6d6
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe52a89ada494049fc5fd6e5d5c53e9282cc10ce232c3ba6f6c1a4cd6e07fc2b
|
|
| MD5 |
b47d572cc42192b26890d45010d374ae
|
|
| BLAKE2b-256 |
8cf3850e663764729b1aceac811a6a98ed4d144f73640dd15fd5f25a04951ea9
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25d15640829e3a0c1a897df6110e5096d13d2d7ef8452cd6344366f2946bdc86
|
|
| MD5 |
10d55145521af6eb051728c41282f817
|
|
| BLAKE2b-256 |
50d41b112232b7e225ca88f29e9d7f326d5400a8017f156124e045c19ac562af
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e2deabd3e2e6ee6816bdb789ae2f31aa45c7bff6de3a551a25aead6de7b26b0
|
|
| MD5 |
50cc4692bb16734b497bb263b1308b95
|
|
| BLAKE2b-256 |
189655dba57d49e6417754fa13970d5dffa204b14d04993ffc24d2f55c1cf255
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa4832063bf83fe675c0a7a078689ee27fed1ee8c2514ad18d631010324b49e1
|
|
| MD5 |
f6d5660ba7b73b6d4b993b8de7285d61
|
|
| BLAKE2b-256 |
cc52e6d273bdb76a6bea0024e086d1b937402392f685208ed4f83bc24a9afb6e
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbd39a451873b275849f5a3628672e36f407724096453ed3e832117e292a65a9
|
|
| MD5 |
4bb2f16bbd5b16656d50bf810b3d2985
|
|
| BLAKE2b-256 |
7db24d5f947c7415edbbb2fe555384eeaf387887e8233a40e75735d58aea3713
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7dd3ff0e7d62e7fb700a56a3382a87da61e0466d2e966cc5d7157ea6b13b718
|
|
| MD5 |
d63eef889c168b84469091a83fec2a98
|
|
| BLAKE2b-256 |
fa20fc2f8db0f952aeedfdb12bcbff9b21a5df9fa0fb3ac084dd2085fde7130a
|
File details
Details for the file tokio_memq_python-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: tokio_memq_python-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0467c5dfea743bdff8e67f5145d82071ed9728fe2393a1e36db21e1aabe952b1
|
|
| MD5 |
6a1e1f588222f8f7378c90d35f971a69
|
|
| BLAKE2b-256 |
2988c09260935cc2bb50a92d16c8b0f5a8854d2a179584b71bd802d97a3d132f
|