Simple and easy to use message bus, supporting IPC and TCP.
Project description
pyaduct
Sometimes all you need is duct tape.
Model actor-based systems in IPC, and then deploy securely using TCP/IP, using the same abstractions.
Installation
pip install pyaduct
The Abstraction
pydduct provides two main classes - the Broker and Client. A Broker can
be be bound to a IPC or TCP socket, and is the central message router
for the system. Any number of Clients can be connected to the Broker,
and these clients expose two primary message patterns:
- Request/Response
- Publish/Subscribe
Using the ZeroMQ DEALER and ROUTER sockets under the hood, pyaduct
supports a fully asynchonrous messaging model.
Examples
See the examples/ for more details on how to integrate the Broker
and Client into an actor based messaging system.
Or run pyaduct demo to see a live demo of the nodes coming online,
sending various messages, events, and pings, and cleanly shutting down.
Convenient
There are other conveience methods exposed by Clients to help them communicate with one another -
- Get a complete list of clients from the broker
- Ping other clients
Message Store
Boasting UUID7 message IDs for global messager ordering, pyaduct also
supports a simple in-memory message store for now, with support for a
sqlite backend coming soon.
Production?
Is pyaduct fault tolerant? Resilent to network failures? Complicated
leader consensus mechanisms? None of the above! pyaduct proudly
supports a single point of failure (namely, the Broker). Use in
production at your own risk.
However, it is great for standing up a proof of concept which could later be implemented with a more robust system such as Kafka.
Demo
❯ pyaduct demo
Timestamp: 2025-04-01 01:11:25.862587+00:00
Client 1 subscribed to test_topic
Client 2 generated event: id=UUID('067eb3d3-f5fc-7a31-8000-1791d1d000f2') type=<MessageType.EVENT: 'EVENT'> timestamp=datetime.datetime(2025, 4, 1, 1, 11, 27, 374193,
tzinfo=datetime.timezone.utc) source='client_2' body='hello world' topic='test_topic'
{
"id": "067eb3d3-f5fc-7a31-8000-1791d1d000f2",
"type": "EVENT",
"timestamp": "2025-04-01T01:11:27.374193Z",
"source": "client_2",
"body": "hello world",
"topic": "test_topic"
}
Client 1 received event: id=UUID('067eb3d3-f5fc-7a31-8000-1791d1d000f2') type=<MessageType.EVENT: 'EVENT'> timestamp=datetime.datetime(2025, 4, 1, 1, 11, 27, 374193, tzinfo=TzInfo(UTC))
source='client_2' body='hello world' topic='test_topic'
Client 1 pinged Client 2 successfully
⠋ Shutting down...
broker Messages
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Message ID ┃ Direction ┃ Type ┃ Body ┃ Timestamp ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 067eb3d3-ddf2-7e9c-8000-30db67ee7cd1 │ RX │ REGISTER │ REGISTER │ 2025-04-01 01:11:25.871870+00:00 │
│ 067eb3d3-df31-7a5c-8000-46ef8674eb7f │ TX │ ACK │ ACK │ 2025-04-01 01:11:25.962198+00:00 │
│ 067eb3d3-ebd1-7cc1-8000-18b44eecff10 │ RX │ REGISTER │ REGISTER │ 2025-04-01 01:11:26.739001+00:00 │
│ 067eb3d3-ec9e-78b3-8000-8b29c6f65ece │ TX │ ACK │ ACK │ 2025-04-01 01:11:26.788720+00:00 │
│ 067eb3d3-f562-7fce-8000-3b27a6b7b629 │ RX │ SUBSCRIBE │ SUBSCRIBE │ 2025-04-01 01:11:27.336683+00:00 │
│ 067eb3d3-f5fc-7a31-8000-1791d1d000f2 │ RX │ EVENT │ hello world │ 2025-04-01 01:11:27.374193+00:00 │
│ 067eb3d3-f64d-7834-8000-041750548e5c │ TX │ ACK │ ACK │ 2025-04-01 01:11:27.412569+00:00 │
│ 067eb3d4-0824-7c1e-8000-044195a83c09 │ RX │ PING │ PING │ 2025-04-01 01:11:28.508987+00:00 │
│ 067eb3d4-1756-7084-8000-aab4169c1e9a │ RX │ PONG │ PONG │ 2025-04-01 01:11:29.458518+00:00 │
└──────────────────────────────────────┴───────────┴───────────┴─────────────┴──────────────────────────────────┘
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 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 pyaduct-0.1.1.tar.gz.
File metadata
- Download URL: pyaduct-0.1.1.tar.gz
- Upload date:
- Size: 37.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6b6ee3edea3fd663665b517a867ce3e8a3c11e64338bfbdd2e81748eb75e03a
|
|
| MD5 |
b2d51f3bf10482d100feeb06f92ae930
|
|
| BLAKE2b-256 |
12bdcd95eaaed0d2e049c8012f6df8a7dbf7fbc0e0bd7400fa719e8336d58f08
|
File details
Details for the file pyaduct-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyaduct-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa80963b3b47a47b170b8041316fae2008aeac89b5bb5cddc4fae12d1a8b2240
|
|
| MD5 |
a55e4a745faabe44808b61a0fdfe5b67
|
|
| BLAKE2b-256 |
bef31fe156fdceb467cbe9b6f2b55899fe3854b1f8bfaa378a65ae9b49f3f622
|