Cross-language Mediator pattern framework — send/stream/publish, 11-middleware pipeline, outbox, inbox, saga, and event bus
Project description
slck-mediator — Python
Cross-language Mediator pattern framework for Python.
Send/stream/publish · 11-middleware pipeline · outbox · inbox · saga · integration event bus · full observability.
Installation
pip install slck-mediator
With optional extras:
pip install "slck-mediator[otel]" # OpenTelemetry adapters
pip install "slck-mediator[sql]" # SQLAlchemy adapters
pip install "slck-mediator[mongo]" # Motor (MongoDB) adapters
pip install "slck-mediator[all]" # Everything
Quick Start
from mediator import Mediator, Request, ConsoleLogger, InMemoryMetrics, InMemoryTracer
class GreetCommand(Request[str]):
def __init__(self, name: str) -> None:
self.name = name
async def greet_handler(ctx, cmd: GreetCommand) -> str:
return f"Hello, {cmd.name}!"
async def main():
logger = ConsoleLogger()
metrics = InMemoryMetrics()
tracer = InMemoryTracer("app", logger, metrics)
m = Mediator(logger=logger, metrics=metrics, tracer=tracer)
m.register_request_handler(GreetCommand, greet_handler)
result = await m.send(GreetCommand("World"))
print(result) # Hello, World!
Code Generation
Generate a build-time direct-dispatch mediator from your feature handlers:
python tools/generate_mediator.py
Development
pip install -e ".[dev]"
pytest
Key modules:
tools/generate_mediator.py: build-time direct-dispatch generator for the example package with duplicate, missing-handler, polymorphic notification, generic-contract, and unsupported-constructor-or-factory diagnostics, and inherited-request-or-stream-contract diagnostics, and handler-or-message-discovery diagnosticsexample/generated_mediator.py: generated direct-dispatch, polymorphic notification resolution, service registration, typed mediator facade, and dependency-wiring factory used by the example composition rootmediator/mediator.py: async runtime mediator withsend,stream, andpublishmediator/registry.py: runtime request, stream, and notification registrymediator/pipeline.py: middleware behaviors including rate limiting and bulkhead controlsmediator/eventbus.py: integration event transports, including concrete Kafka producer, NATS client, RabbitMQ client, and SQS client-backed adapters, plus versioned JSON envelope serializersmediator/outbox.py: file-backed, in-memory, and adapter-backed outbox store, dead-letter store and replay manager, and workermediator/inbox.py: file-backed, in-memory, and adapter-backed idempotent consumer inbox supportmediator/saga.py: saga orchestration with durable file persistence and adapter-backed optimistic storesmediator/lifecycle.py: hosted worker lifecycle, health/readiness, and graceful shutdown coordinationmediator/fastapi.py: FastAPI dependency helperexample/main.py: runnable CQRS, stream, outbox, inbox, and saga demo using the generated service collection/provider integration and typed mediator facade
Built-in notification publishers: ForeachAwaitPublisher, TaskWhenAllPublisher, plus compatibility aliases for SequentialNotificationPublisher and ParallelNotificationPublisher.
Versioned integration messages use a canonical JSON envelope with specVersion, version, schema, occurredAt, and idempotencyKey, and the example logs both the serialized envelope and round-trip deserialization.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slck_mediator-1.0.2.tar.gz.
File metadata
- Download URL: slck_mediator-1.0.2.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07bb1d7f0b800e9b1ff41cf4d614e32b4feb25385944d2d7cf23238253ec7245
|
|
| MD5 |
d90131ac999d62c4da32524c3d263c83
|
|
| BLAKE2b-256 |
e126ba2d8d5982ade323fd14038aa8b9e10634ce9e67d133b6b7b86421f8f58e
|
File details
Details for the file slck_mediator-1.0.2-py3-none-any.whl.
File metadata
- Download URL: slck_mediator-1.0.2-py3-none-any.whl
- Upload date:
- Size: 37.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6cc3db72ed9e2d639ed41a3b85b59c0f0eee81f159f64338a9c1631e1bc6c7e
|
|
| MD5 |
145c32c3d134b2f9e15b1e290a1e99d4
|
|
| BLAKE2b-256 |
7fddfd5028c1dc7fd1b34a17c1a0527de6dc190c979141dc8c5fbb60346054de
|