An open API service indexing awesome lists of open source software.

https://github.com/official-stallion/client.py

Python client SDK for Stallion message broker.
https://github.com/official-stallion/client.py

python python3 sdk-python stallion

Last synced: about 13 hours ago
JSON representation

Python client SDK for Stallion message broker.

Awesome Lists containing this project

README

          


Stallion Python SDK



go version
version

version
version
version


Client SDK for Stallion message broker

## How to use?
Python install:
```shell
pip install stallion-python-sdk
```

### Client
Create a client:
```python
# importing Client module
from stallion.client import Client

# creating a client
# with given stallion server url
c = Client(url="st://localhost:9090")
```

### Publish
```python
# publish an object on a topic
c.Publish("book", {'author': "Amirhossein", 'name': "Stallion"})
```

### Subscribe
```python
# creating a handler
# any published object will be given to this handler as data
def handler(data):
print(f'{data['author']}: {data['name']})

# subscribe over a topic with given handler
c.Subscribe("book", handler)
```

### Unsubscribe
```python
# unsubscribe from a topic
c.Unsubscribe("book")
```