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-RabbitMQ 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-RabbitMQ 0.1.28
File Size Uploaded Provenance Actions
defstream_rabbitmq-0.1.28.tar.gz 492.0 kB Without provenance Details for defstream_rabbitmq-0.1.28.tar.gz

Built distributions (wheels)

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

Total release size: 624.1 kB

Release files / defstream_rabbitmq-0.1.28.tar.gz

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

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

Download URL defstream_rabbitmq-0.1.28-126-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c6f194d21fa6b4924492451f386307e163bc84eadffb978f8daf70d9fd230eb
BLAKE2b-256 checksum
How to use checksums
703a4333784ed75b75abb29ceeb8af464cab1058b0e8e2aefd53a12fb5c7bcb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

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

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

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

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

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

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

Security for DefStream-RabbitMQ 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