tyo-mq-client-python
A Python client for tyo-mq — the distributed pub/sub messaging service with durable delivery (ACK / retry / dead-letter queue), MQTT-style topic wildcards, consumer groups, and multi-tenant auth realms.
Built on python-socketio (Socket.IO v4). Python 3.8+.
Install
pip install tyo-mq-client
You'll need a running tyo-mq server:
npm install tyo-mq && node -e "new (require('tyo-mq').Server)().start()",
or Docker — see the server repo.
Quick start
from tyo_mq_client import MessageQueue
mq = MessageQueue(host='localhost', port=17352)
# with auth enabled on the server:
# mq = MessageQueue(auth={'token': 'my-token'})
# consume
consumer = mq.createConsumer('email-service')
consumer.subscribe('order-service', 'order-placed',
lambda order: print('sending confirmation for', order))
consumer.connect()
# produce
producer = mq.createProducer('order-service')
producer.connect()
producer.produce({'orderId': 1001}, 'order-placed')
Connections run on a background thread; call consumer.wait() to block a
worker process on the connection, and disconnect() to stop.
Durable delivery, ACK, and retry
def handle(message, from_whom, ack, raw):
do_work(message) # raising skips the auto-ACK → server retries
consumer.subscribe('order-service', 'payment', handle, options={
'durable': True, # queue while this consumer is offline
'ack': True, # auto-ACK after the handler returns
'retry': {'max_attempts': 3, 'delay': '5s', 'backoff': 'exponential'},
})
With 'manual_ack': True (plus e.g. 'ack_timeout': '30s') the handler
receives an ack callable and acknowledges only when the work truly
succeeded; unacknowledged deliveries are retried on the schedule and
dead-lettered when attempts run out. Handlers may accept 1–4 arguments:
(message), (message, from), (message, from, ack), or
(message, from, ack, raw).
Topics, groups, broadcast
# MQTT-style wildcards: + is one level, # is the rest
consumer.subscribe_topic('orders/+/status', handler)
consumer.subscribe_topic('factory/#', handler, {'durable': True, 'ack': True})
# consumer groups load-balance across workers
consumer.subscribe('dispatcher', 'jobs', handler, options={'group': 'workers'})
# broadcast one copy to every realm member, or every group member
producer.broadcast({'notice': 'maintenance at 22:00'}, 'announcement')
producer.broadcast({'cmd': 'reload'}, 'control', group='workers')
Large messages are chunked automatically in both directions (256 KB frames), matching the Node.js client.
Note on the produce signature
produce(data, event) — data first, then the event name — kept for
compatibility with existing users of this client. (The Node.js client is
produce(event, data).)
Other clients
Node.js (and browsers) ships with the server package; see also Go, Rust, C/C++, Ruby, Java, and C#.
All clients are exercised together by the cross-language conformance suite, which runs the same pub/sub, durable-delivery, topic, group, and auth scenarios against every client (and every producer/consumer language pair) and publishes the resulting matrix.
License
Apache-2.0. Built by TYO Lab.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 tyo_mq_client-0.3.0.tar.gz.
File metadata
- Download URL: tyo_mq_client-0.3.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e33efbb45a392b295e676f02a8355e6cb8a31645501ceb7f1ff3b54539737816
|
|
| MD5 |
41fcbaf54f91e317ad5a8b2d3c4b503d
|
|
| BLAKE2b-256 |
48abf64bfe7853bb9688f533d0bc9cb1e7c17c0ffdcff32026b4f88681f0434c
|
File details
Details for the file tyo_mq_client-0.3.0-py3-none-any.whl.
File metadata
- Download URL: tyo_mq_client-0.3.0-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7d0d220f37e76546835b6c61d735c093a9747f7a868e782b48413d9dd1e1346
|
|
| MD5 |
028cf9bbeab177a7bbaffe1db0684fff
|
|
| BLAKE2b-256 |
dce4b89067e794d2c5834b4d662ad4d44694d35b7a88e225e2e73d29b251c9a2
|