Replace custom IEventBus with Wolverine#114
Merged
antosubash merged 6 commits intomainfrom Apr 15, 2026
Merged
Conversation
Phase 1 of the IEventBus -> Wolverine migration. Introduces WolverineFx 5.31 and Scrutor 7.0 packages. The old custom EventBus/BackgroundEvent infrastructure remains registered so no runtime behavior changes yet; subsequent phases will migrate modules to IMessageBus and delete the custom implementation.
Adds a new AuditingMessageBus that decorates Wolverine's IMessageBus via Scrutor and captures an AuditEntry for every IEvent published, sent, or invoked. The audit-extraction logic is factored out into a shared AuditEntryExtractor so AuditingEventBus and AuditingMessageBus produce identical entries during the migration; AuditingEventBus is deleted in a later phase once modules stop using IEventBus. DomainEventInterceptor now dispatches via IMessageBus. Wolverine routes by the runtime type of the message (message.GetType()), so no reflection is needed to preserve concrete-type dispatch.
Sweeps 22 files across Users, Tenants, Products, Orders, PageBuilder, FileStorage, Email, Datasets, FeatureFlags, and Settings. The default publish semantic is Wolverine's PublishAsync (fire-and-forget to the local queue), which matches the fact that no modules currently register IEventHandler<T> handlers — events are broadcast-only today. PublishInBackground (formerly fire-and-forget on the custom bus) and PublishAsync (formerly sync-with-propagation) both map to Wolverine's PublishAsync since no callers actually observe handler failures today. SettingsService keeps its Lazy<> indirection (now Lazy<IMessageBus>) to break the SettingsService -> AuditingMessageBus -> ISettingsContracts construction cycle. Test stubs migrate to a shared TestMessageBus and to NSubstitute. The old IEventBus registration and AuditingEventBus remain in place until Phase 4 cleans them up. The CLI module template (ModuleTemplates.cs) now scaffolds IMessageBus for new modules.
Phase 4 of the Wolverine migration. Removes the now-unused custom event bus, its tests, the shared TestEventBus fake, and AuditingEventBus (replaced by AuditingMessageBus in phase 2). The IEvent marker interface is kept — it costs nothing and remains a documentation hint about which types are domain events. The SM0010 circular-dependency diagnostic now suggests Wolverine handlers instead of IEventHandler<T>. Doc comments on IHasDomainEvents and AuditableAggregateRoot updated to reference IMessageBus. Net deletion: ~600 LOC across seven framework files, four framework tests, the shared fake, and AuditingEventBus + its tests.
Rewrites the event-bus section of .claude/skills/simplemodule/ references/cross-module.md to describe Wolverine's IMessageBus, convention-based handler discovery, and inline/queued publish semantics. Also fixes a dangling cref on AuditEntryExtractor that pointed to the deleted AuditingEventBus class.
Deploying simplemodule-website with
|
| Latest commit: |
47542e9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://04d248a0.simplemodule-website.pages.dev |
| Branch Preview URL: | https://feature-compassionate-morse.simplemodule-website.pages.dev |
…-morse # Conflicts: # framework/SimpleModule.Generator/Emitters/DiagnosticEmitter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the custom 424-LOC event-bus implementation (
IEventBus,EventBus,BackgroundEventChannel,BackgroundEventDispatcher,IEventHandler<T>,IEventPipelineBehavior<T>) withWolverineFx 5.31. The
IEventmarkerinterface is retained as a boundary hint, since keeping it costs
nothing and removing it would churn all 26 event-definition files.
to decorate
IMessageBusfor audit capture)PublishAsync(fire-and-forget to the local queue). No modulescurrently register handlers, so the distinction between the old
PublishAsync/PublishInBackgroundis academic in practice.Commit-by-commit
3809a139— add WolverineFx + wireUseWolverinealongside existing IEventBus1cd31b23— route WolverineIMessageBusthroughAuditingMessageBusdecorator (via Scrutor);DomainEventInterceptornow dispatches viaIMessageBusc22bda92— migrate all 22 module publishers toIMessageBus; test fixtures swap toTestMessageBus/ NSubstitute; CLI scaffolder updated899aae81— delete the old event-bus code, the sharedTestEventBus, andAuditingEventBus+ its tests;SM0010diagnostic rewritten40e83ec9— doc cleanup (cross-module skill, stale cref)Design decisions
IEventmarker. Boundary-enforcement hint with no runtime cost.AuditingMessageBusis a Scrutor decorator, not a Wolverine middleware/handler.Wolverine handler chains only run when a handler exists; auditing here must fire on
every publish regardless of handlers.
Lazy<IMessageBus>inSettingsService. TheSettingsService → IMessageBus → AuditingMessageBus → ISettingsContractscycle still exists with Scrutor decoration, so
Lazy<>indirection is still required.DomainEventInterceptorpasses domain events by their boxedIEventtype; Wolverine'sPublishAsync<T>routes onmessage.GetType()internally, so the concrete-typereflection dance the old interceptor performed is no longer needed.
Test plan
dotnet build— 0 errorsdotnet test— all tests pass across every module project (AuditLogs, BackgroundJobs,Chat, Core, Database, DevTools, Email, FeatureFlags, FileStorage, Generator,
Localization, Map, Marketplace, OpenIddict, Orders, PageBuilder, Permissions, Products,
RateLimiting, Settings, Tenants, Users, Admin, Datasets, Rag)
IEventBus|EventBus|BackgroundEventChannel|BackgroundEventDispatcher|IEventHandler<|IEventPipelineBehaviorin production codeIMessageBus