semvec/pypi-packages huggingface dataset:
cosecurity-zero 0.1.0
Cosecurity Zero is a RPC framework to build fast and high performance Python microservices built on top of ØMQ
Requires Python: >=3.10,<4.0

## Getting started

_Ensure Python 3.9+_

```
pip install cosecurity-zero
poetry add cosecurity-zero
```

- Create a `server.py`

```python
from cosecurity.zero import ZeroServer

def echo(msg: str) -> str:
    return msg

async def hello_world() -> str:
    return "hello world"


if __name__ == "__main__":
    app = ZeroServer(port=5559)
    app.register_rpc(echo)
    app.register_rpc(hello_world)
    app.run()

```

- Run it

```
python -m server
```

- Call the rpc methods

```python
import asyncio

from cosecurity.zero import AsyncZeroClient

zero_client = AsyncZeroClient("localhost", 5559)

async def echo():
    resp = await zero_client.call("echo", "Hi there!")
    print(resp)

async def hello():
    resp = await zero_client.call("hello_world", None)
    print(resp)


if __name__ == '__main__':
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    try:
        loop.run_until_complete(echo())
        loop.run_until_complete(hello())
    except KeyboardInterrupt:
        pass

```