feat: add scatter-gather pattern support#287
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 Scatter-Gather support to PatternKit, including a fluent runtime API, a Roslyn incremental source generator + diagnostics, and a DI-friendly supplier quote example with documentation and test coverage.
Changes:
- Introduces
ScatterGather<TRequest, TResponse, TResult>runtime support (dispatch, recipient predicates, aggregation, result/reply models). - Adds
[GenerateScatterGather]generator support with new PKSCG00x diagnostics plus generator/attribute coverage tests. - Adds supplier quote production example (DI + catalogs) and corresponding docs/ToC updates.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Messaging/Routing/ScatterGatherTests.cs | TinyBDD coverage for runtime scatter-gather dispatch, predicates, and configuration validation. |
| test/PatternKit.Generators.Tests/ScatterGatherGeneratorTests.cs | Validates generated factory output ordering and core diagnostics. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Extends attribute coverage suite to include scatter-gather attributes and their defaults/guards. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates catalog expectations to include Scatter-Gather. |
| test/PatternKit.Examples.Tests/Messaging/SupplierQuoteScatterGatherExampleTests.cs | Verifies fluent vs generated parity and IServiceCollection integration for the example. |
| src/PatternKit.Generators/Messaging/ScatterGatherGenerator.cs | Implements incremental generator for scatter-gather factories and PKSCG diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new analyzer/generator diagnostics in the release notes ledger. |
| src/PatternKit.Generators.Abstractions/Messaging/ScatterGatherAttributes.cs | Adds generator-facing attributes: host, recipient, and aggregator markers. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Adds Scatter-Gather entry to the production readiness pattern catalog. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds “Supplier Quote Scatter-Gather” to the example catalog descriptors. |
| src/PatternKit.Examples/Messaging/SupplierQuoteScatterGatherExample.cs | Adds the supplier quote scatter-gather example (fluent + generated) and DI registration. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires the new example into the aggregate examples DI entry point. |
| src/PatternKit.Core/Messaging/Routing/ScatterGather.cs | Adds runtime implementation for scatter-gather, reply, and result types. |
| docs/patterns/toc.yml | Adds Scatter-Gather to patterns TOC. |
| docs/patterns/messaging/scatter-gather.md | New pattern guide page for Scatter-Gather usage and generator mention. |
| docs/guides/pattern-coverage.md | Updates coverage table to include Scatter-Gather runtime + generator. |
| docs/generators/toc.yml | Adds Scatter-Gather generator doc to generator TOC. |
| docs/generators/scatter-gather.md | New generator guide page documenting usage and diagnostics. |
| docs/generators/index.md | Adds Scatter-Gather to generator index table. |
| docs/examples/toc.yml | Adds supplier quote scatter-gather example to examples TOC. |
| docs/examples/supplier-quote-scatter-gather.md | New example guide for supplier quote scatter-gather. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| services.AddSupplierQuoteScatterGatherDemo(); | ||
|
|
||
| var service = provider.GetRequiredService<SupplierQuoteService>(); | ||
| var summary = service.RequestQuotes(new SupplierQuoteRequest("SKU-100", 120, requiresColdChain: false)); |
| var aggregator = type.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(static method => | ||
| method.GetAttributes().Any(static attr => attr.AttributeClass?.ToDisplayString() == "PatternKit.Generators.Messaging.ScatterGatherAggregatorAttribute")); | ||
| if (aggregator is null || !IsAggregator(aggregator, requestType, responseType, resultType)) | ||
| { | ||
| context.ReportDiagnostic(Diagnostic.Create(InvalidAggregator, (aggregator is null ? type.Locations : aggregator.Locations).FirstOrDefault(), aggregator?.Name ?? type.Name)); | ||
| return; | ||
| } |
| | Enterprise Integration | Message Store | `MessageStore<TPayload>` | Message Store generator | | ||
| | Enterprise Integration | Wire Tap | `WireTap<TPayload>` | Wire Tap generator | | ||
| | Enterprise Integration | Control Bus | `ControlBus<TCommand>` | Control Bus generator | | ||
| | Enterprise Integration | Scatter-Gather | `ScatterGather<TRequest,TResponse,TResult>` | Scatter-Gather generator | |
Code Coverage |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #287 +/- ##
==========================================
+ Coverage 90.46% 96.05% +5.58%
==========================================
Files 392 396 +4
Lines 34215 34479 +264
Branches 4809 4868 +59
==========================================
+ Hits 30954 33118 +2164
+ Misses 1462 1361 -101
+ Partials 1799 0 -1799
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:
|
Test Results725 tests 725 ✅ 31s ⏱️ Results for commit f0bac2c. ♻️ This comment has been updated with latest results. |
🔍 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. |
Summary
Closes #282
Local validation
Note: full local examples build remains blocked by local compiler/analyzer mismatch CS9057, so hosted CI is authoritative for source-generated example compilation.