Skip to main content

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. This means the core functionality is available, but completely untested, and more functionality is expected to be added before it reaches the alpha stage.

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')

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

lonelypsp-0.0.22.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lonelypsp-0.0.22-py3-none-any.whl (54.6 kB view details)

Uploaded Python 3

File details

Details for the file lonelypsp-0.0.22.tar.gz.

File metadata

  • Download URL: lonelypsp-0.0.22.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for lonelypsp-0.0.22.tar.gz
Algorithm Hash digest
SHA256 1d98658def1e98f5544debb51bfd869e257dca2a7c6689c793826a00948bfdc8
MD5 59efaa40635463ed2b2f1b82faa774fe
BLAKE2b-256 d300b2a88c453c76d4185937faf8ca885d6b282e661de988b6bc7b56c5afcb15

See more details on using hashes here.

Provenance

The following attestation bundles were made for lonelypsp-0.0.22.tar.gz:

Publisher: publish.yml on Tjstretchalot/lonelypsp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lonelypsp-0.0.22-py3-none-any.whl.

File metadata

  • Download URL: lonelypsp-0.0.22-py3-none-any.whl
  • Upload date:
  • Size: 54.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for lonelypsp-0.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 717f3267bcfd9b8e2f53097120edac3c425842be47b6d4adee59bc771b056a63
MD5 7a70607c10180221d7fd587627d8d5ef
BLAKE2b-256 1bbeacb38492039a7bb8c9f3f44b0d74e6e05d7906d38ab821098760bf65ff4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lonelypsp-0.0.22-py3-none-any.whl:

Publisher: publish.yml on Tjstretchalot/lonelypsp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page