A lightweight publish, subscribe library
Project description
Github can be found here
Setup
pip install yaps
CLI tools
To use the executables, ensure that yaps is installed which should put yaps-publish, yaps-subscribe and yaps-server available your path.
CLI Publish
yaps-publish --topic weather --message "Very cold today!"
CLI Subscribe
yaps-publish --topic weather
Python API
The client can be used either asynchronous or synchronous.
Publish Synchronous
from yaps.client import Client
client = Client('127.0.0.1', 8999)
client.publish(topic='weather', message='Very cold today!')
Subscribe Synchronous
from yaps.client import Client
client = Client('127.0.0.1', 8999)
client.subscribe(topic='weather',
data_received=lambda msg: print(f'New data: {msg}'))
Publish Asynchronous
import asyncio
from yaps.client import AsyncClient
client = AsyncClient('127.0.0.1', 8999)
asyncio.run(client.publish(topic='weather', message='Very cold today!'))
Subscribe Asynchronous
import asyncio
from yaps.client import AsyncClient
client = AsyncClient('127.0.0.1', 8999)
callback = lambda msg: print(f'New data: {msg}')
asyncio.run(client.subscribe(topic='test',
data_received=callback))
Server (Asynchronous only)
import asyncio
from yaps.server import Server
server = Server('127.0.0.1', 8999)
asyncio.run(server.start())
Logging
Logging is enabled by default and can be disabled by calling disable()
on either a client or server.
You can set the logging level by calling set_loglevel(string)
with either a string, or an int directly from the logging
module.
Logging output is by default directed to both stdin and a log file, located at ~/.yaps
on Unix systems (not 100% sure where this is located in Windows).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file yaps-lib-0.0.1.tar.gz
.
File metadata
- Download URL: yaps-lib-0.0.1.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 635a84228d3a752a0bbd22f9404311007a75d2621328e2738265f0622d4a5bae |
|
MD5 | 668fb07a822644f6a3244d1e0bdca38e |
|
BLAKE2b-256 | 084706e70600e77ae29ff74c12ef698c8a6729b587ef4326b8de15762e1a7b0e |
File details
Details for the file yaps_lib-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: yaps_lib-0.0.1-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 597ff477591978db37c2e04490a2e0b13405011ee19da62cd89444ef9f81991a |
|
MD5 | c4071a144cd4613495669f84a1a71e0f |
|
BLAKE2b-256 | 7609d83cede3f090e62074021c02efa2eb300ba149dd11dc61ebc9d8a2b44fe6 |