Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Runnel

Distributed event processing for Python based on Redis Streams.

https://runnel.dev

Runnel allows you to easily create scalable stream processors, which operate on partitions of event streams in Redis. Runnel takes care of assigning partitions to workers and acknowledging events automatically, so you can focus on your application logic.

Whereas traditional job queues do not provide ordering guarantees, Runnel is designed to process partitions of your event stream strictly in the order events are created.

Installation

pip install runnel

Basic Usage

from datetime import datetime

from runnel import App, Record

app = App(name="myapp", redis_url="redis://127.0.0.1")


# Specify event types using the Record class.
class Order(Record):
    order_id: int
    created_at: datetime
    amount: float


orders = app.stream("orders", record=Order, partition_by="order_id")


# Every 4 seconds, send an example record to the stream.
@app.timer(interval=4)
async def sender():
    await orders.send(Order(order_id=1, created_at=datetime.utcnow(), amount=9.99))


# Iterate over a continuous stream of events in your processors.
@app.processor(orders)
async def printer(events):
    async for order in events.records():
        print(f"processed {order.amount}")

Meanwhile, run the worker (assuming code in example.py and PYTHONPATH is set):

$ runnel worker example:app

Features

Designed to support a similar paradigm to Kafka Streams, but on top of Redis.

  • At least once processing semantics
  • Automatic partitioning of events by key
  • Each partition maintains strict ordering
  • Dynamic rebalance algorithm distributes partitions among workers on-the-fly
  • Support for nested Record types with custom serialisation and compression
  • Background tasks, including timers and cron-style scheduling
  • User-defined middleware for exception handling, e.g. dead-letter-queueing
  • A builtin batching mechanism to efficiently process events in bulk
  • A runnel[fast] bundle for C or Rust extension dependencies (uvloop, xxhash, orjson, lz4)

Documentation

Full documenation is available at https://runnel.dev.

Blog posts

Essays about this project or the technology it's using:

Local development

To run the test suite locally, clone the repo and install the optional deps (e.g. via poetry install -E fast). Make sure Redis is running on localhost at port 6379, then run pytest.

See also

For a traditional task queue that doesn't provide ordering guarantees, see our sister project Fennel.

Release files for runnel 0.1.0b1

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

Source distribution (sdist)

Source distribution for runnel 0.1.0b1
File Size Uploaded
runnel-0.1.0b1.tar.gz 33.0 kB Details

Built distribution (wheel)

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

Total release size: 74.4 kB

Release files / runnel-0.1.0b1.tar.gz

Download URL runnel-0.1.0b1.tar.gz
Size 33.0 kB
Tags Source
SHA-256 checksum
How to use checksums
12f3dd6156d2580c31643bf8af5f7ae78a2160b7a74af37f704fdc403f0da8c7
BLAKE2b-256 checksum
How to use checksums
cb3c54e471c4e297aed4618bb1037fff3223964f78e9026013aefe893a63f379
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.5 Linux/5.3.0-1034-azure

Release files / runnel-0.1.0b1-py3-none-any.whl

Download URL runnel-0.1.0b1-py3-none-any.whl
Size 41.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0accbebca0f2098a8f5138077ac388163c124dca610032df66f8b45e12ecced
BLAKE2b-256 checksum
How to use checksums
f6033edeecf927fe3cdd1e2f67c2551afbf7f55ee6e90ab57493d35199e29981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.5 Linux/5.3.0-1034-azure
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