Skip to content

official-stallion/client.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stallion Python SDK


go version version
version version version

Client SDK for Stallion message broker

How to use?

Python install:

pip install stallion-python-sdk

Client

Create a client:

# importing Client module
from stallion.client import Client

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

Publish

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

Subscribe

# 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

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