Metadata-Version: 2.2
Name: relppy
Version: 0.2
Summary: RELP protocol server
Home-page: https://github.com/wtnb75/relppy
Author: Watanabe Takashi
Author-email: wtnb75@gmail.com
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: System :: Networking
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click
Dynamic: requires-dist

# RELP server/client for python

[![main](https://github.com/wtnb75/relppy/actions/workflows/main.yml/badge.svg)](https://github.com/wtnb75/relppy/actions/workflows/main.yml)

## install

- pip install relppy

## example

### server

```python
import socketserver
from relppy.server import RelpStreamHandler
from relppy.protocol import Message


class MyHandler(RelpStreamHandler):
    def do_syslog(self, msg: Message):
        print(msg.data.decode("ascii"))


if __name__ == "__main__":
    srv = socketserver.TCPServer(("localhost", 10514), MyHandler)
    srv.serve_forever()
```

### client

```python
from relppy.client import RelpTCPClient

with RelpTCPClient(("localhost", 10514)) as cl:
    for m in ["hello", "world"]:
        fut= cl.send_command(b"syslog", m.encode())
        res = fut.result()
        print(f"sent: {m} -> {res}")
```
