Connectionless Pub-Sub Protocol
Project description
lonelypsp
Lonely Pub-Sub Protocol (lonely being the opposite of connected!)
PROJECT STAGE - PRE ALPHA
This project is in the development stage 2 - pre-alpha. There is some testing in
the lonelypst repository, but
there are constant sweeping changes that break the api still ongoing to
facilitate all the desired functionality
Overview
This is the Python specification for the protocol used by the canonical implementation lonelypss. It serves both as a reference for the protocol and as a helper library for the Python server and client.
The types here are intended to facilitate alternate server and client implementations in a variety of languages, such as Ruby, TypeScript, and Rust.
This library is fully mypy checked and has a flat class heirarchy (no subclasses); as soon as you check e.g. the type field, mypy and pylance will be able to deduce specific and accurate information about the remaining fields.
This library is designed intentionally so you can pick and choose any part of the implementation to use relatively painlessly.
Although the message packets are named for the initial transport layer (websockets), they will work in any reliable protocol where every message below a known size > 1024 bytes is not fragmented and the total length of the message is known. Thus, it can used directly on TCP with a bit of buffering and framing the message length for a significant performance boost compared to websockets (mostly due to not having to mask the data).
Usage
Parsing:
import io
from lonelypsp.stateful.parser import S2B_AnyMessageParser
from lonelypsp.stateful.parser_helpers import parse_s2b_message_prefix
message_body: io.BytesIO = ...
prefix = parse_s2b_message_prefix(message_body)
message = S2B_AnyMessageParser.parse(prefix.flags, prefix.type, message_body)
if message.type == SubscriberToBroadcasterStatefulMessageType.SUBSCRIBE_EXACT:
print(message.topic)
Serialization:
from lonelypsp.stateful.constants import SubscriberToBroadcasterStatefulMessageType
from lonelypsp.stateful.messages.subscribe import S2B_SubscribeExact, serialize_s2b_subscribe_exact
message = serialize_s2b_subscribe_exact(
S2B_SubscribeExact(
type=SubscriberToBroadcasterStatefulMessageType.SUBSCRIBE_EXACT,
authorization=None,
topic=b"foo/bar",
),
minimal_headers=True
)
# message: bytearray(b'\x00\x01\x00\x02\x00\x00\x00\x07foo/bar')
Tracing
To facilitate all types of tracing requirements (logging, metrics, debugging, etc), this protocol supports a tracing header which can be passed along with every message. The details of how this tracing header is used are up to the broadcaster and subscriber implementation, but typically the subscriber will send timestamps/ids that are then stored by the broadcaster, while the broadcaster sends back its own timestamps/ids for logging on the subscriber side
Tracing data is required to be less than 2^16 bytes and is included in the authorization checks where relevant (e.g., hmac)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lonelypsp-0.0.37.tar.gz.
File metadata
- Download URL: lonelypsp-0.0.37.tar.gz
- Upload date:
- Size: 62.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7f23534a03629d9107302e9724959a08f2d9f75ae2bc633e858bc1d89cd598b
|
|
| MD5 |
d8f927036bd020f4d54c4a8507ac6927
|
|
| BLAKE2b-256 |
4486944a4292e2c3d0ce28e284889b93ac3640d022025f3bf9a6adfae909051d
|
Provenance
The following attestation bundles were made for lonelypsp-0.0.37.tar.gz:
Publisher:
publish.yml on Tjstretchalot/lonelypsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lonelypsp-0.0.37.tar.gz -
Subject digest:
a7f23534a03629d9107302e9724959a08f2d9f75ae2bc633e858bc1d89cd598b - Sigstore transparency entry: 165190200
- Sigstore integration time:
-
Permalink:
Tjstretchalot/lonelypsp@013e8094f0e0abcd8643d25f1cda11de46ba537f -
Branch / Tag:
refs/tags/0.0.37 - Owner: https://github.com/Tjstretchalot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@013e8094f0e0abcd8643d25f1cda11de46ba537f -
Trigger Event:
push
-
Statement type:
File details
Details for the file lonelypsp-0.0.37-py3-none-any.whl.
File metadata
- Download URL: lonelypsp-0.0.37-py3-none-any.whl
- Upload date:
- Size: 94.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80bfb177aea84a28a4d764379c859e5d5538013f6332001710d9099ff8d6bdb4
|
|
| MD5 |
1103f792c1c03ffbe896b1daafc22ec9
|
|
| BLAKE2b-256 |
97a0804c815abdd31c945af25574b9a7095612488125723afe98964886cf3be4
|
Provenance
The following attestation bundles were made for lonelypsp-0.0.37-py3-none-any.whl:
Publisher:
publish.yml on Tjstretchalot/lonelypsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lonelypsp-0.0.37-py3-none-any.whl -
Subject digest:
80bfb177aea84a28a4d764379c859e5d5538013f6332001710d9099ff8d6bdb4 - Sigstore transparency entry: 165190201
- Sigstore integration time:
-
Permalink:
Tjstretchalot/lonelypsp@013e8094f0e0abcd8643d25f1cda11de46ba537f -
Branch / Tag:
refs/tags/0.0.37 - Owner: https://github.com/Tjstretchalot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@013e8094f0e0abcd8643d25f1cda11de46ba537f -
Trigger Event:
push
-
Statement type: