Skip to main content

DefStream

Synchronous event/message processing with pluggable broker adapters

DefStream processes broker messages with ordinary Python task methods and can run them in thread or process pools. It requires Python 3.9 or later.

Installation

Install the client extra for the broker you use. A broker server must be available separately.

python -m pip install "DefStream[RabbitMQ]"

For Redis Streams, install DefStream[Redis]. To install both adapters and clients, use DefStream[RabbitMQ,Redis]. The plain DefStream installation includes neither broker implementation nor client. Each extra installs a separate, same-version adapter distribution, preserving existing import paths.

Before migrating an older integrated installation or historical standalone adapters, uninstall DefStream, DefStream-RabbitMQ and DefStream-Redis, then reinstall with the desired extras. Omitting an extra later does not remove an already installed adapter.

Quick start

The following worker listens to a local RabbitMQ server at 127.0.0.1:5672. The example credentials are for local development only.

from signal import SIGINT, signal

from DefStream.Broker.Implements.RabbitMQ import Configuration, Connection, Reject, Subscription
from DefStream.Worker import Run, ThreadPool, Worker, WorkerSetup, declare


class Add(
  Run,
  parameters=Subscription(queue='example.add', error='example.add.error'),
  on_error=Reject(),
):
  def run(self, a: int, b: int):
    print(a + b)
    return a + b


class Prepare(WorkerSetup):
  def __call__(self, worker: Worker) -> None:
    for task in worker.tasks:
      declare(task=task, broker=worker.broker)


if __name__ == '__main__':
  worker = Worker(
    Connection(Configuration(host='127.0.0.1', port=5672, username='guest', password='guest')),
    ThreadPool(4),
    setups=Prepare(),
  )
  worker.add(Add)
  signal(SIGINT, lambda *_: worker.stop())
  worker.run()

Run the script after starting RabbitMQ. The worker declares its task queue and waits for messages. Store production credentials outside source code.

License

See the LICENSE file included with the source distribution for the license terms.

Metadata

Release files for DefStream-Redis 0.1.28

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

Source distribution (sdist)

Source distribution for DefStream-Redis 0.1.28
File Size Uploaded Provenance Actions
defstream_redis-0.1.28.tar.gz 492.0 kB Without provenance Details for defstream_redis-0.1.28.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for DefStream-Redis 0.1.28
File Actions
defstream_redis-0.1.28-126-py3-none-any.whl Python 3 none any Details for defstream_redis-0.1.28-126-py3-none-any.whl
defstream_redis-0.1.28-125-py3-none-any.whl Python 3 none any Details for defstream_redis-0.1.28-125-py3-none-any.whl
defstream_redis-0.1.28-124-py3-none-any.whl Python 3 none any Details for defstream_redis-0.1.28-124-py3-none-any.whl
defstream_redis-0.1.28-123-py3-none-any.whl Python 3 none any Details for defstream_redis-0.1.28-123-py3-none-any.whl

Total release size: 588.6 kB

Release files / defstream_redis-0.1.28.tar.gz

Download URL defstream_redis-0.1.28.tar.gz
Size 492.0 kB
Tags Source
SHA-256 checksum
How to use checksums
49e62e1f4197d1669f831dfa64dcd7b07b41beaea41500dc274c9444fcea65a0
BLAKE2b-256 checksum
How to use checksums
481c9a92d46b21ac1c790e72e44a3e57b213698150b23f0a6d5284f49e5b8fb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / defstream_redis-0.1.28-126-py3-none-any.whl

Download URL defstream_redis-0.1.28-126-py3-none-any.whl
Size 24.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7574952b4bfdb7817964bcbd383c1a779c38dbce89c537e5cbf63ce1c785e50e
BLAKE2b-256 checksum
How to use checksums
0b3d0e534ff4ba7ffe79eff4eb404d2773e8b2870b85c7fa7f1060dda89a0311
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / defstream_redis-0.1.28-125-py3-none-any.whl

Download URL defstream_redis-0.1.28-125-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ea0e7fbd7e9ee5df19b4d92b71f61f3eeb5680117a73f0f90ab14aa74b6c3f3
BLAKE2b-256 checksum
How to use checksums
ec892f59221134518de1df925c29b77145bb1420aca6bafefa93cb58e459b342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / defstream_redis-0.1.28-124-py3-none-any.whl

Download URL defstream_redis-0.1.28-124-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b74e9c780b6b545194a13d67fff24bc174dde7ed5ed8ed8be6f82da454e999eb
BLAKE2b-256 checksum
How to use checksums
a84748b6ce43bbb00430d8b65231b4c80ade6d58a7ef4b0a0776c4f159e496f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / defstream_redis-0.1.28-123-py3-none-any.whl

Download URL defstream_redis-0.1.28-123-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0580f39b97ebf1be8f885c8644293c8042774cc8676e9302fe4712d563622ac7
BLAKE2b-256 checksum
How to use checksums
d20db2366c38b27979b2f0febeb8de1ff5d980c7cc7eccfc42b904694c19439d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for DefStream-Redis 0.1.28

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