Skip to content
README.md 1.37 KiB
Newer Older
Gallacchi Mattia's avatar
Gallacchi Mattia committed
# RSVP python

This repo contains the implementation of the *RSVP (Request-and-Stream Variable Protocol)* for python. 
Gallacchi Mattia's avatar
Gallacchi Mattia committed

## Dependencies

| | |
|-|-|
| Poetry | >= 1.2.0 |

Install python packages:

```bash
poetry install
```

## Quick start

Here is an example of how to create a RSVP server running on TCP:

```py
from pyrsvp.rsvpserver import RsvpServer, RsvpServerTcp

# Define commands and their callbacks
@RsvpServer.Command("START")
def start(a: int, b: float, c: bool, d: str, e: dict, f: list) -> str:
    
    print(f"a: {a}, b: {b}, c: {c}, d: {d}, e: {e}, f: {f}")
    return f"REPLY-START=ACK;STATUS=PASS"

if __name__ == "__main__":
    srv = RsvpServerTcp()
    srv.run()
```

The main idea is to use the decorator to add callback based on command names to your server

```py
@RsvpServer.Command(<COMMAND_NAME>)
```

Each callback will receive the user defined arguments and each callback must return a reply string in the form

```py
return f"REPLY-<COMMAND_NAME>=ACK|NACK;ARGS|ERROR"
```

The general protocol is described in more details [here][1].

## Usage examples

In the *examples* folder you'll find some usage examples

## Run tests

```bash
poetry run pytest -v -s tests
```

## Add pyrsvp to your project

Gallacchi Mattia's avatar
Gallacchi Mattia committed
Coming soon
Gallacchi Mattia's avatar
Gallacchi Mattia committed
## TODO list

- [] Add CI/CD for tests and wheel generation
- [] Add serial support

[1]:https://labinfo.ing.he-arc.ch/gitlab/igib/documents-latex/rsvp-specs