P2P high-level library
Project description
py-unsserv
py-unsserv is high-level Python library, designed to offer out-of-the-box peer-to-peer (p2p) network, as well as a bunch of functionalities on top of it. These functionalities include:
- Membership (or p2p network creation)
- Clustering
- Metrics aggregation
- Nodes sampling
- Dissemination (or broadcasting)
- Data searching (key-value caching oriented)
Look how easy it is to use:
import asyncio
from typing import Tuple
from unsserv import join_network, get_dissemination_service
Host = Tuple[str, int]
async def broadcaster(host: Host):
# join p2p network
membership = await join_network(host, "network.id")
# initialize dissemination service
dissemination = await get_dissemination_service(membership, "dissemination.id")
# wait for receiver to join network
await asyncio.sleep(1)
# broadcast data
for _ in range(10):
await dissemination.broadcast(b"data.alert")
await asyncio.sleep(1)
async def receiver(host: Host, broadcaster_host: Host):
# wait for broadcaster to join network
await asyncio.sleep(1)
# join p2p network
membership = await join_network(host, "network.id", bootstrap_nodes=[broadcaster_host])
# initialize dissemination service and add broadcast handler
async def handler(data: bytes):
print(data)
await get_dissemination_service(membership, "dissemination.id", broadcast_handler=handler)
# wait for broadcast
await asyncio.sleep(10)
if __name__ == "__main__":
broadcaster_host = ("127.0.0.1", 7771)
receiver_host = ("127.0.0.1", 7772)
loop = asyncio.new_event_loop()
loop.create_task(broadcaster(broadcaster_host))
loop.create_task(receiver(receiver_host, broadcaster_host=broadcaster_host))
loop.run_forever()
Installation
pip install unsserv
More about UnsServ
py-unsserv is the Python implementation of UnsServ, which is the academic work behind it. For a more detailed understanding you can check the UnsServ non-published paper: Original UnsServ academic paper
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unsserv-0.0.2.tar.gz
(41.2 kB
view details)
Built Distribution
unsserv-0.0.2-py3-none-any.whl
(75.7 kB
view details)
File details
Details for the file unsserv-0.0.2.tar.gz
.
File metadata
- Download URL: unsserv-0.0.2.tar.gz
- Upload date:
- Size: 41.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fbe0038eb7d79d05def03fc121b1a42e07a876dc3c63eae3633e2ae16bc0f31 |
|
MD5 | 5679d811dc06027ac1de9e2c7f4c943a |
|
BLAKE2b-256 | 4a965c4e7c56d5c002471a1da261a531d3e8e15e79135597959622082072782e |
File details
Details for the file unsserv-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: unsserv-0.0.2-py3-none-any.whl
- Upload date:
- Size: 75.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c44b0a1441f595887b7ad5656dafce449d63ad01bf7ed7a333f926c6b222dc70 |
|
MD5 | c3cd3188428131ee371697444b4fdc7c |
|
BLAKE2b-256 | 147cb9278d04cb15ca74c0af82055b632adcd1337efa35a6bafc58efa99fd4a7 |