hexastack-events
CNCF CloudEvents 1.0 serialization, Transactional Outbox pattern, and distributed event streaming for Hexastack.
Part of the Hexastack Framework.
1. Architectural Overview
hexastack-events extends Hexastack's in-process CQRS buses with enterprise distributed event streaming and reliability patterns:
- CNCF CloudEvents 1.0 Protocol: Automatic serialization and deserialization of domain
Eventmodels into standardized CloudEvents JSON envelopes with W3C correlation ID and multi-tenant partitioning. - Transactional Outbox Engine (Gap 6): Guarantees at-least-once delivery by staging uncommitted domain events in an
OutboxStoragePortwithin the same transaction as business state mutations. - Dual Relay Engines:
- Native Asyncio (
AsyncioOutboxRelay): In-process background task running with zero external dependencies. - Huey Worker (
HueyOutboxRelay): Multi-process worker executing outbox polling in separate worker nodes (pip install hexastack-events[huey]).
- Native Asyncio (
- Relational Database Outbox Storage (
SqlAlchemyOutboxStorage): Pluggable storage adapter supporting SQLAlchemy tables and transactions (pip install hexastack-events[sql]). - Distributed Event Bus (
DistributedEventBusPort): Standardized cross-service messaging interface for Redis, NATS, Kafka, and in-memory brokers.
graph TD
CMD["CQRS Command Handler"]
UOW["Unit of Work Transaction"]
OUTBOX_MW["OutboxCaptureMiddleware"]
OUTBOX_STORE["OutboxStoragePort\n(SQLAlchemy / DB Outbox Table)"]
RELAY["OutboxRelayPort\n(Asyncio / Huey Worker)"]
BUS["DistributedEventBusPort\n(Redis / NATS / Kafka)"]
CMD --> UOW
CMD --> OUTBOX_MW
OUTBOX_MW -->|Stages Record| OUTBOX_STORE
UOW -->|Atomic Commit| OUTBOX_STORE
RELAY -->|Polls Pending| OUTBOX_STORE
RELAY -->|Publishes CloudEvent| BUS
2. Key Exports & Package Structure
hexastack_events/
├── domain/ # EventContext, OutboxRecord, OutboxStatus, CloudEventEnvelope, EventError
├── ports/ # OutboxStoragePort, OutboxRelayPort, DistributedEventBusPort
├── adapters/
│ ├── cloudevents/ # to_cloudevent, from_cloudevent, cloudevent_to_json/dict
│ ├── outbox/ # AsyncioOutboxRelay, HueyOutboxRelay, InMemoryOutboxStorage, SqlAlchemyOutboxStorage
│ └── buses/ # InMemoryDistributedEventBus
└── infra/ # EventsBootstrapper (order=22), HexastackEventsConfig, OutboxCaptureMiddleware
3. Quickstart & Installation
# Core CloudEvents & Asyncio Outbox Relay (zero extra dependencies)
pip install hexastack-events
# With SQLAlchemy relational database outbox storage
pip install "hexastack-events[sql]"
# With Huey multi-process worker support
pip install "hexastack-events[huey]"
Configuration (hexastack.toml or pyproject.toml)
[hexastack.events]
source = "billing-service"
relay_mode = "asyncio" # "asyncio", "huey", "manual", "disabled"
poll_interval_seconds = 1.0
batch_size = 50
max_retries = 5
enabled = true
Transactional Outbox Example with SQLAlchemy
from hexastack_core.domain import Event
from hexastack_events.adapters.outbox.sqlalchemy import OutboxEventMixin
from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
pass
class OrderOutboxEvent(Base, OutboxEventMixin):
__tablename__ = "outbox_events"
class OrderPlacedEvent(Event):
order_id: str
total_amount: float
customer_id: str
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hexastack_events-0.1.0.tar.gz
(13.7 kB
view details)
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 hexastack_events-0.1.0.tar.gz.
File metadata
- Download URL: hexastack_events-0.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a29fc6d790a4577dc4a3b38ef33f538f3ca0fc1fe56bc189b0371b8467b38e2
|
|
| MD5 |
750608166e3d49867657e7b196de969c
|
|
| BLAKE2b-256 |
3564ab8e15e161000f3641d4121469314a1afed820b0c6b9ef98d10d9c92d626
|
File details
Details for the file hexastack_events-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hexastack_events-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f9c334af1e00e0aa62a2a3406fd9949df1d207e33250ff3493de693b8216ecf
|
|
| MD5 |
cbba8e9da555030146ae6e799c4c8c2e
|
|
| BLAKE2b-256 |
7271341b86320db3dc8c080091a25ccbb249220ba894e8acc87f4d1c40e5cd01
|