Commit 204ebad
authored
feat: generate type-safe event publishers from AsyncAPI specs (#1320)
* feat: generate type-safe event publishers from AsyncAPI specs
Add a Go code generator (tools/gen-event-publishers/) that reads
AsyncAPI 3.0.0 YAML specs and generates typed event publisher packages
in gen/events/. Each generated Publisher wraps OutboxPublisher with
methods that accept the correct proto event type, topic, and event type
string, eliminating string-based configuration errors.
The generator validates proto types against actual .proto files,
skipping services whose proto definitions are not yet available
(audit, financial-accounting, market-information).
Generated packages: current_account (4 events), internal_account (2),
party (3), payment_order (7), position_keeping (9), reconciliation (6).
Also adds `make gen-event-publishers` Makefile target.
* fix: follow explicit $ref chain in event publisher generator
Resolve message-to-schema mapping through the explicit AsyncAPI $ref
chain (message -> component message -> payload schema) instead of
assuming message keys match schema names directly. Extract channel
message resolution into resolveChannelEvents to reduce cognitive
complexity. Iterate channel messages in sorted order for deterministic
output regardless of Go map iteration order.
Also add gen-event-publishers to Makefile help target.
* fix: clean stale gen/events packages before regeneration
Remove the output directory before generating publishers so that
removed or renamed AsyncAPI specs do not leave orphaned packages.
* fix: fail fast on spec errors and add diagnostic warnings
Fail with log.Fatalf instead of silently skipping when an AsyncAPI spec
file has read or parse errors. Add WARN log messages when $ref chains
resolve to unknown channels or component messages to surface spec drift.
---------
Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>1 parent 142368f commit 204ebad
8 files changed
Lines changed: 1364 additions & 1 deletion
File tree
- gen/events
- current_account
- internal_account
- party
- payment_order
- position_keeping
- reconciliation
- tools/gen-event-publishers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
496 | 497 | | |
497 | 498 | | |
498 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
499 | 504 | | |
500 | 505 | | |
501 | 506 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments