DjangoBackend
Bases: TransactionalBackend
Django integration backend for Event Sourcery.
Provides a fully configured TransactionalBackend for Django projects, including
event store, outbox, and subscription strategies. Supports configuration via the
DjangoConfig class.
Source code in event_sourcery_django/__init__.py
configure(config=None)
Sets the backend configuration for outbox and subscription behavior. If no config is provided, the default configuration is used. This method must be called before using the backend in production to ensure correct event publishing and subscription reliability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
DjangoConfig | None
|
Optional custom configuration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The configured backend instance (for chaining). |
Source code in event_sourcery_django/__init__.py
DjangoConfig
Bases: BaseModel
Configuration for DjangoBackend event store integration.
Attributes:
| Name | Type | Description |
|---|---|---|
outbox_attempts |
PositiveInt
|
Maximum number of outbox delivery attempts per event. |
gap_retry_interval |
timedelta
|
Time to wait before retrying a subscription gap. If the subscription detects a gap in event identifiers (e.g., missing event IDs), it assumes there may be an open transaction and the database has already assigned IDs for new events that are not yet committed. This interval determines how long the subscription waits before retrying to fetch events, preventing loss of events that are in the process of being written to the database. |