Skip to main content

A simple and synchronous message queue for commands and events for Django

Project description

PyPI release Downloads Coverage Linting Coding Style Documentation Status

A simple and synchronous message queue for commands and events for Django.

PyPI | GitHub | Full documentation

Creator & Maintainer: Ambient Digital

Features

  • Split up your business logic in commands and events
  • Commands are imperatives telling your system what to do, events reflect that something has happened
  • Register light-weight functions via a decorator to listen to your commands and events
  • Message handlers receive the context of the message (command or event), providing an explicit API
  • No magic, no side effects since the queue works synchronously
import dataclasses

from queuebie.runner import handle_message
from queuebie.messages import Command, Event
from queuebie import message_registry


# Example command
@dataclasses.dataclass(kw_only=True)
class BuyProduct(Command):
    product_id: int
    customer_id: int
    price: float
    currency: str


# Example event
@dataclasses.dataclass(kw_only=True)
class ProductBought(Event):
    product_id: int
    customer_id: int


# Example handler
@message_registry.register_command(BuyProduct)
def handle_buy_product(context: BuyProduct) -> Event:
    # Here lives your business logic

    return ProductBought(
        product_id=context.product_id,
        customer_id=context.customer_id,
    )


# Start queue and process messages
handle_message(
    BuyProduct(
        product_id=product.id,
        customer_id=customer.id,
        price=12.99,
        currency="EUR",
    )
)

Installation

  • Install the package via pip:

    pip install django_queuebie

    or via uv:

    uv add django_queuebie

  • Add module to INSTALLED_APPS within the main django settings.py:

INSTALLED_APPS = (
    # ...
    "queuebie",
)

Publish to ReadTheDocs.io

  • Fetch the latest changes in GitHub mirror and push them
  • Trigger new build at ReadTheDocs.io (follow instructions in admin panel at RTD) if the GitHub webhook is not yet set up.

Preparation and building

This package uses uv for dependency management and building.

  • Update documentation about new/changed functionality

  • Update the CHANGES.md

  • Increment version in main __init__.py

  • Create pull request / merge to "main"

  • This project uses uv to publish to PyPI. This will create distribution files in the dist/ directory.

    uv build
    

Publishing to PyPI

To publish to the production PyPI:

uv publish

To publish to TestPyPI first (recommended for testing):

uv publish --publish-url https://test.pypi.org/legacy/

You can then test the installation from TestPyPI:

uv pip install --index-url https://test.pypi.org/simple/ ambient-package-update

Maintenance

Please note that this package supports the ambient-package-update. So you don't have to worry about the maintenance of this package. This updater is rendering all important configuration and setup files. It works similar to well-known updaters like pyupgrade or django-upgrade.

To run an update, refer to the documentation page of the "ambient-package-update".

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

django_queuebie-0.3.8.tar.gz (74.8 kB view details)

Uploaded Source

Built Distribution

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

django_queuebie-0.3.8-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file django_queuebie-0.3.8.tar.gz.

File metadata

  • Download URL: django_queuebie-0.3.8.tar.gz
  • Upload date:
  • Size: 74.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.1

File hashes

Hashes for django_queuebie-0.3.8.tar.gz
Algorithm Hash digest
SHA256 1e0b1d20be322abf93c4b7d532c49030ae27e38dd5b30636cc3b0fe6bdad28ac
MD5 923aee7e48b8bedc4ddd03c66cbccf05
BLAKE2b-256 61e4bb3e2777f444d4c231141c288e586809a8ffc28032aa8d7dfc98bf700a9f

See more details on using hashes here.

File details

Details for the file django_queuebie-0.3.8-py3-none-any.whl.

File metadata

File hashes

Hashes for django_queuebie-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b5477148e4aab36ef140d89142aac931324352e77ed29b48468e37785da8460a
MD5 fa8e85ac7538cf64b9a0bd1f1b863e7f
BLAKE2b-256 908e9e014ae0983c728eae6b42cd6c744ffc04b437f2afaa519f28b4c501378c

See more details on using hashes here.

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