Skip to content

feat: add event-driven consumer pattern support#297

Merged
JerrettDavis merged 1 commit into
mainfrom
feat/event-driven-consumer-pattern
May 22, 2026
Merged

feat: add event-driven consumer pattern support#297
JerrettDavis merged 1 commit into
mainfrom
feat/event-driven-consumer-pattern

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Closes #291.

Summary

  • Adds EventDrivenConsumer runtime support with fluent handlers and error policy handling.
  • Adds [GenerateEventDrivenConsumer] / [EventDrivenConsumerHandler] source generator support with diagnostics.
  • Adds DI-ready order event-driven consumer example, catalog entries, docs, and TinyBDD coverage.

Validation

  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f netstandard2.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net8.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net10.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Generators\PatternKit.Generators.csproj /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~EventDrivenConsumerTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~EventDrivenConsumerTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedNameEventDrivenConsumerGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedNameEventDrivenConsumerGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • git diff --check

Local examples build remains blocked by the existing analyzer/compiler mismatch (CS9057) and generated demo types; hosted CI remains authoritative for examples/docs.

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

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 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);
@github-actions
Copy link
Copy Markdown
Contributor

Test Results

  1 files    1 suites   1m 10s ⏱️
893 tests 893 ✅ 0 💤 0 ❌
898 runs  898 ✅ 0 💤 0 ❌

Results for commit 5a9fdc3.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 90.56604% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.02%. Comparing base (c1c18b0) to head (5a9fdc3).

Files with missing lines Patch % Lines
...it.Core/Messaging/Consumers/EventDrivenConsumer.cs 76.38% 17 Missing ⚠️
...mples/Messaging/OrderEventDrivenConsumerExample.cs 94.11% 2 Missing ⚠️
...nerators/Messaging/EventDrivenConsumerGenerator.cs 98.50% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 96.02% <90.56%> (+5.61%) ⬆️

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.

@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 02:23:39
  Coverage date: 05/22/2026 - 02:22:32 - 05/22/2026 - 02:23:29
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1185
  Files: 502
  Line coverage: 94.8%
  Covered lines: 34716
  Uncovered lines: 1871
  Coverable lines: 36587
  Total lines: 81178
  Branch coverage: 76.5% (10131 of 13232)
  Covered branches: 10131
  Total branches: 13232
  Method coverage: 96.3% (6650 of 6899)
  Full method coverage: 88.5% (6108 of 6899)
  Covered methods: 6650
  Fully covered methods: 6108
  Total methods: 6899

PatternKit.Core                                                                                                    96.1%
  PatternKit.Application.AntiCorruption.AntiCorruptionLayer<T1, T2>                                                90.4%
  PatternKit.Application.AntiCorruption.AntiCorruptionResult<T>                                                     100%
  PatternKit.Application.AuditLog.AuditLogAppendResult<T>                                                          85.7%
  PatternKit.Application.AuditLog.InMemoryAuditLog<T1, T2>                                                         95.4%
  PatternKit.Application.DataMapping.DataMapper<T1, T2>                                                            94.6%
  PatternKit.Application.DataMapping.DataMapperError                                                                 90%
  PatternKit.Application.DataMapping.DataMapperResult<T>                                                           84.6%
  PatternKit.Application.DomainEvents.DomainEventDispatcher<T>                                                     95.4%
  PatternKit.Application.DomainEvents.DomainEventDispatchResult                                                     100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                       100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                  97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                           80%
  PatternKit.Application.FeatureToggles.FeatureToggleDecision                                                      87.5%
  PatternKit.Application.FeatureToggles.FeatureToggleRule<T>                                                        100%
  PatternKit.Application.FeatureToggles.FeatureToggleSet<T>                                                        96.9%
  PatternKit.Application.IdentityMap.IdentityMap<T1, T2>                                                            100%
  PatternKit.Application.IdentityMap.IdentityMapResult<T>                                                          92.8%
  PatternKit.Application.MaterializedViews.MaterializedView<T1, T2>                                                98.4%
  PatternKit.Application.Repository.InMemoryRepository<T1, T2>                                                     92.8%
  PatternKit.Application.Repository.RepositoryResult<T>                                                            93.3%
  PatternKit.Application.ServiceLayer.ServiceLayerOperation<T1, T2>                                                96.7%
  PatternKit.Application.ServiceLayer.ServiceLayerResult<T>                                                        94.7%
  PatternKit.Application.ServiceLayer.ServiceLayerRule<T>                                                           100%
  PatternKit.Application.Specification.Specification<T>                                                             100%
  PatternKit.Application.Specification.SpecificationRegistry<T>                                                    93.3%
  PatternKit.Application.TableDataGateway.InMemoryTableDataGateway<T1, T2>                                           86%
  PatternKit.Application.TableDataGateway.TableGatewayResult<T>                                                    82.3%
  PatternKit.Application.TransactionScript.TransactionScript<T1, T2>                                                 97%
  PatternKit.Application.TransactionScript.TransactionScriptError                                                    90%
  PatternKit.Application.TransactionScript.TransactionScriptResult<T>                                               100%
  PatternKit.Application.UnitOfWork.UnitOfWork                                                                     90.9%
  PatternKit.Application.UnitOfWork.UnitOfWorkResult                                                               94.7%
  PatternKit.Application.UnitOfWork.UnitOfWorkRollbackResult                                                        100%
  PatternKit.Application.UnitOfWork.UnitOfWorkStep                                                                  100%
  PatternKit.Behavioral.Chain.ActionChain<T>                                                                        100%
  PatternKit.Behavioral.Chain.AsyncActionChain<T>                                                                   100%
  PatternKit.Behavioral.Chain.AsyncResultChain<T1, T2>                                                             97.7%
  PatternKit.Behavioral.Chain.ResultChain<T1, T2>                                                                   100%

@github-actions
Copy link
Copy Markdown
Contributor

🔍 PR Validation Results

Version: ``

✅ Validation Steps

  • Build solution
  • Run tests
  • Build documentation
  • Dry-run NuGet packaging

📊 Artifacts

Dry-run artifacts have been uploaded and will be available for 7 days.


This comment was automatically generated by the PR validation workflow.

@JerrettDavis JerrettDavis merged commit eb08291 into main May 22, 2026
13 checks passed
@JerrettDavis JerrettDavis deleted the feat/event-driven-consumer-pattern branch May 22, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Event-Driven Consumer enterprise integration pattern

2 participants