Skip to content

feat: implement fan-out — multiple handlers per Dispatcher projection#13

Merged
Raezil merged 2 commits into
mainfrom
feature/fan-out-dispatcher
May 21, 2026
Merged

feat: implement fan-out — multiple handlers per Dispatcher projection#13
Raezil merged 2 commits into
mainfrom
feature/fan-out-dispatcher

Conversation

@Raezil
Copy link
Copy Markdown
Member

@Raezil Raezil commented May 21, 2026

Dispatcher type changes from map[interface{}]HandlerFunc to map[interface{}][]HandlerFunc. A new Register(projection, ...HandlerFunc) method accumulates handlers for the same key. Publish() and Transaction.Commit() iterate over all handlers per event projection; each handler gets its own middleware chain, before/after/error hooks, and processedCount increment, so subscribers are fully independent — an error in one does not prevent siblings from running.

Examples updated to use Register. Tests updated with hs() helper and three new fan-out tests covering sync, error-independence, and async modes.

Raezil and others added 2 commits May 21, 2026 19:16
Dispatcher type changes from map[interface{}]HandlerFunc to
map[interface{}][]HandlerFunc. A new Register(projection, ...HandlerFunc)
method accumulates handlers for the same key. Publish() and
Transaction.Commit() iterate over all handlers per event projection;
each handler gets its own middleware chain, before/after/error hooks,
and processedCount increment, so subscribers are fully independent —
an error in one does not prevent siblings from running.

Examples updated to use Register. Tests updated with hs() helper and
three new fan-out tests covering sync, error-independence, and async modes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reflects the current API surface: Dispatcher is now map[interface{}][]HandlerFunc
with Register(), fan-out section added, middleware and lifecycle hook examples
included, Transaction example fixed, __ctx magic key removed, internal struct
fields removed from API reference, and all code samples verified against the
live codebase.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Raezil Raezil merged commit be9539d into main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant