Skip to main content

A small command bus with pluggable queue adapters and response stores (e.g. SQS, RabbitMQ, Redis, etc.)

Project description

DeegzLibs CommandBus (Python)

A small command bus with pluggable queue adapters. Define command messages as Pydantic models, register handlers, and execute commands in-process or via a queue (e.g. AWS SQS, RabbitMQ, Redis).

Installation

pip install deegzlibs-command-bus

Optional extras: [sqs], [redis], [rabbitmq]. See Installation.

Quick start

from command_bus import CommandBus, CommandBusRouter, CommandMessage, CommandHandler
from command_bus.adapters import InMemoryCommandBusAdapter

router = CommandBusRouter()
adapter = InMemoryCommandBusAdapter(queue_name="commands")
bus = CommandBus(queue_adapter=adapter, command_router=router)

@router.command()
def on_order_created(order_id: str, amount_cents: int):
    print(f"Order {order_id}: {amount_cents} cents")

# Fire-and-forget
await bus.execute(on_order_created(order_id="ord-1", amount_cents=1999), wait=False)

# Worker: poll and dispatch
await bus.work()

For full examples (messages, handlers, SQS/Redis, execute-and-wait), see the documentation.

Documentation

Topic Description
Installation Package and extras.
Quick start Messages, handlers, register, execute.
Handler decorator @router.command() and message factory.
Message formats and parsers Repr, JSON, Base64, custom parser.
Client and worker Shared module, producer, consumer.
Queue adapters In-memory, SQS, RabbitMQ, Redis.
Execute and wait Response store, request/response.
API reference Types and methods overview.

License

MIT

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

deegzlibs_command_bus-2.0.0.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

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

deegzlibs_command_bus-2.0.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file deegzlibs_command_bus-2.0.0.tar.gz.

File metadata

  • Download URL: deegzlibs_command_bus-2.0.0.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for deegzlibs_command_bus-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1ec7c9d4261f46f59c7370d3fb90cf41133b0baf2005426c71c8233629a07299
MD5 1e749c490903f08edbbbc36427ac6770
BLAKE2b-256 8b9a7a9283eaa189a31061b7e166d6bed37ad9f39b0d65fcf7e4df9dfcce4111

See more details on using hashes here.

File details

Details for the file deegzlibs_command_bus-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for deegzlibs_command_bus-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9253fe07f57606352cc20b837bf120a73afae8dfb265904b0ad29b0cbb4a5bee
MD5 819c250ab1073fb8b54ea9434c81650a
BLAKE2b-256 3b4fa6a862609cc4e4dfa61bb8319df117274a9c52f06772c0d33429d822b325

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