Lifecycle hooks (middleware chain) for events, commands, and projections #118
Labels
No labels
bug
documentation
enhancement
investigation
nice-to-have
performance
production-ready
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ash/eskit#118
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add composable lifecycle hooks at three boundaries: event append, command dispatch, and projection processing. Middleware chain pattern — no event emitters, no reflection.
This makes cross-cutting concerns (metrics, tracing, validation, audit logging) first-class without bloating the core.
Decision: Three Hook Points Only
Hooks earn their place ONLY where interfaces alone are insufficient. After review:
✅ YES — Event Append Hooks
✅ YES — Command Dispatch Hooks
This means
WithCommandAudit(#114) becomes just another hook:✅ YES — Projection Processing Hooks
❌ NO — Places we deliberately exclude hooks
Implementation: Middleware Chain
Go-style functional options. Ordered. Multiple per point. Plain functions — testable, composable.
Hook types
Beforehooks can reject (return error) — acts as a gateAfterhooks are fire-and-forget — no error return, don't block the hot pathWhy Not Event Emitters
interface{}listeners)Testing Requirements
Benchmark Requirements
Build Order
Build BEFORE #114 (command persistence) — so command audit becomes a hook from day one rather than a special case retrofitted later.