Skip to main content

py-unsserv

PyPI version Python 3.7 Build Status codecov

PEP8 black Checked with mypy

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

Metadata

Release files for unsserv 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unsserv 0.0.5
File Size Uploaded
unsserv-0.0.5.tar.gz 41.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unsserv 0.0.5
File Interpreter ABI Platform
unsserv-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 117.9 kB

Release files / unsserv-0.0.5.tar.gz

Download URL unsserv-0.0.5.tar.gz
Size 41.8 kB
Tags Source
SHA-256 checksum
How to use checksums
de8c25dcfda0841b27e07389da82e14567ad9b143bea5f8bbf90732aba391107
BLAKE2b-256 checksum
How to use checksums
c1eda41ff3671aa2841fbf704f9081f2d6053e5c13464a4d0330ecebba64d628
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / unsserv-0.0.5-py3-none-any.whl

Download URL unsserv-0.0.5-py3-none-any.whl
Size 76.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcf7b8d68ca0e45a80c4856532e3df8a4bde0171ae52fa3be41a71fe4bfcdd3f
BLAKE2b-256 checksum
How to use checksums
49f582703b6dcb5b33593d5ec1c0050e6613b957eb03d8aa2739eefd0ab805e9
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page