Python client for ForestMQ
Project description
Python client for ForestMQ
Install
pip install forestmq
Running ForestMQ
docker run -p 8005:8005 josefdigital/forestmq:0.6.2
Examples
Using the provider API
from forestmq import ForestMQ
def sync_example():
fmq = ForestMQ(domain="http://localhost:8005")
result = fmq.provider.send_msg_sync({
"name": "Sync message",
})
print(result)
sync_example() # {'queue_length': 38, 'message_size': 5120, 'message': {'name': 'Sync message'}}
Using the provider's async client
import asyncio
from forestmq import ForestMQ
async def async_example():
fmq = ForestMQ(domain="http://localhost:8005")
result = await fmq.provider.send_msg({
"name": "Async message!",
})
print(result)
asyncio.run(async_example()) # {'queue_length': 39, 'message_size': 5120, 'message': {'name': 'Async message!'}}
Using the consumer API
import asyncio
from forestmq import ForestMQ
def callback(message: dict) -> None:
print(f"Consumer message: {message['message']}")
if __name__ == "__main__":
fmq = ForestMQ(domain="http://localhost:8005", interval=1)
asyncio.run(fmq.consumer.poll(callback))
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
forestmq-0.1.0.tar.gz
(5.5 kB
view details)
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 forestmq-0.1.0.tar.gz.
File metadata
- Download URL: forestmq-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86fd1eeaf82f3168307b1045b7fbca42dd23e6bf5bd955161b4f41117f19a1d9
|
|
| MD5 |
908500a761ad57de441e08107447932e
|
|
| BLAKE2b-256 |
ebb2004f2c9c76408ffacd4bb9f0152fbdf898d4e3ffc098d371940c7a5c7b84
|
File details
Details for the file forestmq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: forestmq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29b42908fabb32aa50501427d8042c2630efadef0eaad963e8aa957f12747aa3
|
|
| MD5 |
4643f51fb30a5656069354858569a313
|
|
| BLAKE2b-256 |
75077b4bc3d914c1a29b54bdb2abe585a5f4d20de526292cc20dd59556438ec6
|