Skip to content

feat(eventbus): add PublishEvent method for pre-built CloudEvents#197

Merged
tomhv-ctl merged 4 commits intomainfrom
mnawa/PLT-318/publish-encrypted-event
Mar 16, 2026
Merged

feat(eventbus): add PublishEvent method for pre-built CloudEvents#197
tomhv-ctl merged 4 commits intomainfrom
mnawa/PLT-318/publish-encrypted-event

Conversation

@maxnawa
Copy link

@maxnawa maxnawa commented Mar 11, 2026

Summary

  • Add PublishCloudEvent method to EventBusModule that accepts a pre-built CloudEvents event and routes it directly, bypassing the internal event construction in Publish
  • The event is cloned before routing so the module owns an immutable snapshot, preventing caller mutations and data races with async subscribers
  • This enables callers to set custom CloudEvent extensions (e.g., encryption metadata like encryption, encryptedfields, keyid) before publishing

Context

Part of PLT-318 (messaging event encryption). The existing Publish(ctx, topic, payload) method constructs the CloudEvent internally, which doesn't allow callers to attach encryption extensions. PublishCloudEvent lets the caller build the full CloudEvent — including field-level encryption metadata per ADR-010 — and hand it off for routing.

The timing, error formatting, and telemetry emission shared between Publish and PublishCloudEvent are centralised in a private publishEvent helper to keep the two paths from drifting.

@github-actions
Copy link

github-actions bot commented Mar 11, 2026

📋 API Contract Changes Summary

No breaking changes detected - only additions and non-breaking modifications

Changed Components:

Core Framework

Contract diff saved to artifacts/diffs/core.json

Module: auth

Contract diff saved to artifacts/diffs/auth.json

Module: cache

Contract diff saved to artifacts/diffs/cache.json

Module: chimux

Contract diff saved to artifacts/diffs/chimux.json

Module: database

Contract diff saved to artifacts/diffs/database.json

Module: eventbus

Contract diff saved to artifacts/diffs/eventbus.json

Module: eventlogger

Contract diff saved to artifacts/diffs/eventlogger.json

Module: httpclient

Contract diff saved to artifacts/diffs/httpclient.json

Module: httpserver

Contract diff saved to artifacts/diffs/httpserver.json

Module: jsonschema

Contract diff saved to artifacts/diffs/jsonschema.json

Module: letsencrypt

Contract diff saved to artifacts/diffs/letsencrypt.json

Module: logmasker

Contract diff saved to artifacts/diffs/logmasker.json

Module: reverseproxy

Contract diff saved to artifacts/diffs/reverseproxy.json

Module: scheduler

Contract diff saved to artifacts/diffs/scheduler.json

Artifacts

📁 Full contract diffs and JSON artifacts are available in the workflow artifacts.

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.62%. Comparing base (185d00d) to head (58b5185).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #197      +/-   ##
==========================================
- Coverage   61.54%   56.62%   -4.92%     
==========================================
  Files          82       82              
  Lines       17706    17708       +2     
==========================================
- Hits        10897    10028     -869     
- Misses       5769     6576     +807     
- Partials     1040     1104      +64     
Flag Coverage Δ
auth ?
bdd-auth 70.97% <ø> (ø)
bdd-cache 67.15% <ø> (ø)
bdd-chimux 73.80% <ø> (ø)
bdd-database 51.85% <ø> (ø)
bdd-eventbus 69.00% <ø> (-0.91%) ⬇️
bdd-eventlogger 61.59% <ø> (ø)
bdd-httpclient 41.81% <ø> (ø)
bdd-httpserver 62.59% <ø> (ø)
bdd-jsonschema 77.31% <ø> (ø)
bdd-letsencrypt 19.70% <ø> (ø)
bdd-logmasker 36.02% <ø> (ø)
bdd-reverseproxy 54.68% <ø> (ø)
bdd-scheduler 60.97% <ø> (ø)
cache ?
chimux ?
cli 47.27% <ø> (ø)
core-bdd 17.70% <ø> (ø)
database ?
eventbus 76.44% <ø> (+4.83%) ⬆️
eventlogger ?
httpclient ?
httpserver ?
jsonschema ?
letsencrypt ?
logmasker ?
merged-bdd 45.99% <ø> (+<0.01%) ⬆️
reverseproxy ?
scheduler ?
total 57.11% <ø> (ø)
unit 64.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new PublishEvent API to the eventbus module so callers can publish a fully constructed CloudEvents event (including custom extensions like encryption metadata) without the module rebuilding/wrapping it.

Changes:

  • Add EventBusModule.PublishEvent(ctx, event) to route a pre-built CloudEvent directly through the engine router.
  • Add a unit test verifying PublishEvent routes the event and preserves extensions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
modules/eventbus/module.go Introduces PublishEvent to publish pre-built CloudEvents events via the router while keeping existing publish metrics/emission behavior.
modules/eventbus/module_test.go Adds coverage ensuring PublishEvent delivers the event to subscribers and preserves CloudEvent extensions.

You can also share your feedback on Copilot code review. Take the survey.

- Capture event.SetData error in test
- Assert no error on deferred Stop and Cancel calls
- Suppress gosec G118 false positives for context.WithCancel stored on struct
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


You can also share your feedback on Copilot code review. Take the survey.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

@tomhv-ctl tomhv-ctl merged commit e7f1341 into main Mar 16, 2026
30 of 32 checks passed
@tomhv-ctl tomhv-ctl deleted the mnawa/PLT-318/publish-encrypted-event branch March 16, 2026 20:22
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.

4 participants