Skip to content

Commit d5b6989

Browse files
author
FirstUnicorn
committed
docs: add python-domain-events section to README
1 parent 083e686 commit d5b6989

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
66
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
77

8-
Comprehensive Python web development toolkit organized as a monorepo with 16 independent micro-libraries.
8+
Comprehensive Python web development toolkit organized as a monorepo with 17 independent micro-libraries.
99

1010
## What each library solves
1111

@@ -414,6 +414,35 @@ class UserCreated(IOutboxEvent):
414414
```
415415
</details>
416416

417+
<details>
418+
<summary><b>python-domain-events</b> — in-process domain event dispatch</summary>
419+
420+
BEFORE (without library):
421+
```python
422+
# ad-hoc event handling scattered across services
423+
class UserService:
424+
def create_user(self, data):
425+
user = self.repo.save(data)
426+
self.email_service.send_welcome(user) # tight coupling
427+
self.cache_service.invalidate("users") # more coupling
428+
self.activity_log.record("user_created") # even more
429+
```
430+
431+
AFTER (using library):
432+
```python
433+
from python_domain_events import BaseDomainEvent, InProcessEventDispatcher
434+
435+
class UserCreated(BaseDomainEvent):
436+
event_type: str = "user.created"
437+
user_id: int
438+
439+
dispatcher = InProcessEventDispatcher()
440+
dispatcher.register(UserCreated, SendWelcomeEmailHandler())
441+
dispatcher.register(UserCreated, InvalidateCacheHandler())
442+
await dispatcher.dispatch(UserCreated(user_id=42))
443+
```
444+
</details>
445+
417446
### Summary
418447

419448
| Library | BEFORE (without) | AFTER (with) |
@@ -433,6 +462,7 @@ class UserCreated(IOutboxEvent):
433462
| **postgres-data-sanitizers** | Crashes on null chars / surrogates in Postgres writes | Auto-strip before insert — zero silent data corruption |
434463
| **python-cqrs-dispatcher** | Wiring commands to handlers manually each time | Auto-dispatch: register handler once, dispatcher routes |
435464
| **pydantic-response-models** | Inconsistent API response shapes across endpoints | `ApiResponse[T]`, `PaginatedResponse[T]` — uniform contract |
465+
| **python-domain-events** | Ad-hoc event handling, tight coupling to side-effects | `InProcessEventDispatcher` — register/dispatch with tracing |
436466
| **python-outbox-core** | Lost events on crash / inconsistent event publishing | Transactional outbox — events saved atomically with data |
437467

438468
## Project Structure

0 commit comments

Comments
 (0)