Metadata-Version: 2.4
Name: quantnet-mq
Version: 1.0.0
Summary: A messaging library for the Quant-Net Control Plane
Home-page: https://github.com/quant-net/quant-net-mq
Author: ESnet
Author-email: quant-net@es.net
License: BSD license
Keywords: quant-net message queue
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gmqtt==0.6.11
Requires-Dist: uvloop==0.21.0
Requires-Dist: jsonschema==4.18.0
Requires-Dist: referencing==0.36.2
Requires-Dist: python-jsonschema-objects==0.5.7
Requires-Dist: pyaml==23.9.7
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

The QUANT-NET Message Queue Module (quantnet_mq)
================================================

The QUANT-NET Message Queue module provide RPC and Publish/Subscribe capabilities for the control plane, and the package is a common dependency for the QNCP Controller, Agent, and API packages. The module includes:

* Remote procedure call (RPC) client and server implementations
* Publish/Subscribe (pub/sub) client and server implementations
* Core schemas for the QUANT-NET Control Plane network data model
* Auto-generated Python objects for all defined schema


Installing
----------

```
pip3 install .   # or pip3 install -e .
```


Building
--------

```
python3 -m build
```

Testing
-------

```
MQ_HOST=<broker_host> pytest -v
```

Example Usage
-------------

* RPC client

```
import asyncio
from quantnet_mq.rpcclient import RPCClient

async def main():
    client = RPCClient("example_client")
    client.set_handler("myRequest", None,
        "quantnet_mq.schema.models.myns.myRequest")
    await client.start()

    # send a message and wait up to for a response 5s
    msg = {"arg1": "value1", "arg2": 999.99}
    req = await client.call("myRequest, msg, timeout=5.0)
    print (req)

if __name__ == "__main__":
    asyncio.run(main())
```

* Pub/Sub receiver

```
import asyncio
from quantnet_mq.rpcclient import MsgServer

async def handle_msg(data):
    print (data)

async def main():
    client = MsgServer()
    mclient.subscribe("mytopic", self.handle_msg)
    await mclient.start()
    # wait as long as needed here ...

if __name__ == "__main__":
    asyncio.run(main())
```
