feat: add event-driven consumer pattern support#297
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Adds first-class Event-Driven Consumer support across PatternKit’s runtime, source generators, examples, and documentation to close #291.
Changes:
- Introduces
EventDrivenConsumer<TPayload>runtime API with fluent handler registration and error policy behavior. - Adds
[GenerateEventDrivenConsumer]/[EventDrivenConsumerHandler]attributes plus an incremental generator and diagnostics (PKEVT001-003). - Adds DI-importable order example, catalog entries, docs, and TinyBDD-backed tests (runtime + generator + examples).
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Messaging/Consumers/EventDrivenConsumerTests.cs | Adds runtime behavior coverage for handler invocation, context propagation, error policy, and builder validation. |
| test/PatternKit.Generators.Tests/EventDrivenConsumerGeneratorTests.cs | Adds generator coverage for successful factory generation and expected diagnostics. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Extends attribute coverage to include the new event-driven consumer attributes. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates catalog expectations to include the new pattern and adjusts enterprise integration count. |
| test/PatternKit.Examples.Tests/Messaging/OrderEventDrivenConsumerExampleTests.cs | Adds example-level validation for fluent, generated, and DI-registered consumer paths. |
| src/PatternKit.Generators/Messaging/EventDrivenConsumerGenerator.cs | Implements the incremental generator that emits a factory building an EventDrivenConsumer<TPayload> via .Handle(...).Build(). |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new analyzer/generator diagnostic IDs and descriptions for release notes. |
| src/PatternKit.Generators.Abstractions/Messaging/EventDrivenConsumerAttributes.cs | Adds public generator attributes consumed by user code and the generator. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Registers the new pattern in the pattern catalog with linked implementation/tests/docs paths. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Registers the new example in the example catalog with surfaces and docs pointers. |
| src/PatternKit.Examples/Messaging/OrderEventDrivenConsumerExample.cs | Adds a DI-ready order accepted consumer example (fluent + generated) with an audit sink and runner. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires the new example into AddPatternKitExamples() and provides a typed example service descriptor. |
| src/PatternKit.Core/Messaging/Consumers/EventDrivenConsumer.cs | Introduces the runtime consumer, result types, handler result type, and error policy enum. |
| docs/patterns/toc.yml | Adds the new pattern page to the docs TOC under Messaging. |
| docs/patterns/messaging/README.md | Adds an overview entry and link for Event-Driven Consumer. |
| docs/patterns/messaging/event-driven-consumer.md | Adds the pattern documentation page with a minimal usage snippet and guidance. |
| docs/guides/pattern-coverage.md | Updates the coverage table to include Event-Driven Consumer and its generator. |
| docs/generators/toc.yml | Adds the generator docs page to the generators TOC. |
| docs/generators/index.md | Adds Event-Driven Consumer to the generator index table. |
| docs/generators/event-driven-consumer.md | Adds generator-specific documentation and diagnostic descriptions. |
| docs/examples/toc.yml | Adds the new example page to the examples TOC. |
| docs/examples/order-event-driven-consumer.md | Adds documentation for importing/running the order consumer example. |
| docs/examples/index.md | Adds the example to the examples landing page list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| catch (Exception ex) | ||
| { | ||
| result = EventDrivenConsumerHandlerResult.Failure(registration.Name, ex.Message, ex); |
| EventDrivenConsumerHandlerResult result; | ||
| try | ||
| { | ||
| result = registration.Handler(message, effectiveContext); |
Test Results 1 files 1 suites 1m 10s ⏱️ Results for commit 5a9fdc3. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #297 +/- ##
==========================================
+ Coverage 90.41% 96.02% +5.61%
==========================================
Files 408 412 +4
Lines 34963 35175 +212
Branches 4939 4973 +34
==========================================
+ Hits 31612 33778 +2166
+ Misses 1485 1397 -88
+ Partials 1866 0 -1866
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Coverage |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Closes #291.
Summary
Validation
EventDrivenConsumerGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falseEventDrivenConsumerGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falseLocal examples build remains blocked by the existing analyzer/compiler mismatch (CS9057) and generated demo types; hosted CI remains authoritative for examples/docs.