Metadata-Version: 2.4
Name: forestmq
Version: 0.1.0
Summary: Python client for ForestMQ
Home-page: https://github.com/josefdigital/forestmq-python
Author: Josef Digital
Author-email: contact@josef.digital
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: summary

![ForestMQ](assets/fmq_logo.png)
Python client for [ForestMQ](https://github.com/josefdigital/forestmq)


### Install
```
pip install forestmq
```

### Running ForestMQ
```
docker run -p 8005:8005 josefdigital/forestmq:0.6.2
```

### Examples
#### Using the provider API
```python
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
```python
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
```python
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))

```


