Skip to main content

rulfo

Messaging between processes where a request gets zero, one or many replies and always an end. A Python package on a C core, for asyncio.

Status: early. The API can change.

Install

uv add rulfo

Linux with CPython 3.12 or later. Free-threaded Python is not supported. The wheel is for x86_64. Other machines build the package from source, with a C compiler and the Python headers (python3-dev for a Debian system Python).

Quickstart

import asyncio

import rulfo


async def greet(request: rulfo.Request) -> bytes:
    return b"hello " + request.body  # one reply, then the end


async def count(request: rulfo.Request) -> None:
    for number in range(int(request.body)):
        await request.reply(f"item {number}".encode())  # many replies, then the end


async def main() -> None:
    # One Peer for each remote party. This server has one client.
    server = rulfo.Peer(handlers={"greet": greet, "count": count})

    async def accept(reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
        await server.serve(rulfo.StreamTransport(reader, writer))

    listener = await asyncio.start_server(accept, "127.0.0.1", 0)
    port = listener.sockets[0].getsockname()[1]

    client = rulfo.Peer()
    reader, writer = await asyncio.open_connection("127.0.0.1", port)
    connection = asyncio.create_task(client.serve(rulfo.StreamTransport(reader, writer)))
    await client.wait_connected()

    greeting = await client.request("greet", b"world", timeout=5)
    print(greeting.outcome.value, greeting.one())

    numbers = await client.request("count", b"3", timeout=5)
    print(numbers.outcome.value, [reply.body for reply in numbers.replies])

    missing = await client.request("unknown", timeout=5)
    print(missing.outcome.value)

    await client.aclose()
    await server.aclose()
    await connection
    listener.close()
    await listener.wait_closed()


asyncio.run(main())

Output:

completed b'hello world'
completed [b'item 0', b'item 1', b'item 2']
unroutable

Features

  • Four outcomes: completed, busy, expired, unroutable. Two of them say it did not run.
  • A deadline on every request, also when the two clocks differ.
  • Zero, one or many replies, in order.
  • A request survives a reconnect and runs once while the other process lives. Replies lost in the reconnect are sent again, up to a memory limit.
  • Any byte stream: TCP and unix sockets included, WebSocket adapters in the docs.
  • A model checks the rules, and the library replays runs of that model.

Not designed yet: latest value per key, work with acknowledgement, presence.

License

MIT. See LICENSE.

Metadata

Release files for rulfo 0.1.7

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

Source distribution (sdist)

Source distribution for rulfo 0.1.7
File Size Uploaded Provenance Actions
rulfo-0.1.7.tar.gz 65.2 kB Without provenance Details for rulfo-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rulfo 0.1.7
File Interpreter ABI Platform Actions
rulfo-0.1.7-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for rulfo-0.1.7-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Total release size: 105.4 kB

Release files / rulfo-0.1.7.tar.gz

Download URL rulfo-0.1.7.tar.gz
Size 65.2 kB
Tags Source
SHA-256 checksum
How to use checksums
165bfacee25e9ef72fcfa1a6cebc9a0ad1c14655a82250944d811a187fe2378c
BLAKE2b-256 checksum
How to use checksums
d5e732579fdbe5c4ef098bf28483238591b268b7b970215d6dac5619dfb3522a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rulfo-0.1.7-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL rulfo-0.1.7-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 40.3 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
5a23a03024b66aff94a3005e2eee865254512e34b491c02f693b3a9af06e13e1
BLAKE2b-256 checksum
How to use checksums
efd5e65173d1cd4ade0049d917b8d8159bf502a58ced2c540188393195439029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for rulfo 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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