feat: add polling consumer pattern support#296
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 2m 21s ⏱️ Results for commit 873a345. |
There was a problem hiding this comment.
Pull request overview
Adds first-class “Polling Consumer” support across PatternKit’s runtime API, Roslyn source generators, examples, and documentation to cover the explicit pull-based message consumption pattern (closes #290).
Changes:
- Introduces
PollingConsumer<TPayload>runtime fluent API + result type for synchronous polling. - Adds
[GeneratePollingConsumer]/[PollingConsumerSource]attributes and an incremental generator with diagnostics (PKPOLL001-003). - Adds a warehouse replenishment polling example with DI registration, plus pattern/example catalog + docs/test coverage.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Messaging/Consumers/PollingConsumerTests.cs | Adds runtime API tests for polling behavior and builder validation. |
| test/PatternKit.Generators.Tests/PollingConsumerGeneratorTests.cs | Adds generator tests for source output and diagnostics. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Extends attribute coverage to include polling consumer attributes/defaults. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates catalog expectations to include the new pattern. |
| test/PatternKit.Examples.Tests/Messaging/WarehousePollingConsumerExampleTests.cs | Adds example-level tests for fluent, generated, and DI-imported polling consumer. |
| src/PatternKit.Generators/Messaging/PollingConsumerGenerator.cs | New incremental generator for polling consumer factories + diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Records new analyzer diagnostic IDs for the generator. |
| src/PatternKit.Generators.Abstractions/Messaging/PollingConsumerAttributes.cs | Adds new generator attributes for polling consumer generation. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Registers Polling Consumer in the production-readiness pattern catalog. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Registers the warehouse polling consumer example in the example catalog. |
| src/PatternKit.Examples/Messaging/WarehousePollingConsumerExample.cs | Adds the warehouse replenishment polling consumer example + DI registration. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires the new example into AddPatternKitExamples() aggregation. |
| src/PatternKit.Core/Messaging/Consumers/PollingConsumer.cs | Adds runtime PollingConsumer<TPayload> and PollingConsumerResult<TPayload>. |
| docs/patterns/toc.yml | Adds Polling Consumer to the patterns TOC. |
| docs/patterns/messaging/polling-consumer.md | New pattern documentation page. |
| docs/guides/pattern-coverage.md | Adds Polling Consumer to the coverage matrix. |
| docs/generators/toc.yml | Adds Polling Consumer to the generators TOC. |
| docs/generators/polling-consumer.md | New generator documentation page + diagnostic list. |
| docs/generators/index.md | Adds Polling Consumer to the generator index table. |
| docs/examples/warehouse-polling-consumer.md | New example documentation page. |
| docs/examples/toc.yml | Adds the warehouse polling consumer example to the examples TOC. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private static readonly Queue<Message<ReplenishmentRequest>> Messages = new(); | ||
|
|
||
| public static void Enqueue(ReplenishmentRequest request) => Messages.Enqueue(Message<ReplenishmentRequest>.Create(request)); | ||
|
|
||
| [PollingConsumerSource] | ||
| private static Message<ReplenishmentRequest>? Poll(MessageContext context) => Messages.Count == 0 ? null : Messages.Dequeue(); |
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #296 +/- ##
==========================================
+ Coverage 90.41% 96.06% +5.64%
==========================================
Files 404 408 +4
Lines 34822 34963 +141
Branches 4916 4939 +23
==========================================
+ Hits 31485 33586 +2101
+ Misses 1483 1377 -106
+ Partials 1854 0 -1854
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:
|
Closes #290.
What changed
PollingConsumer<TPayload>runtime pattern for explicit pull-based message consumption.[GeneratePollingConsumer]/[PollingConsumerSource]source generator support with diagnostics and attribute coverage.IServiceCollectionregistration and aggregateAddPatternKitExamples()integration.Local validation
dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f netstandard2.0 /p:UseSharedCompilation=falsedotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net8.0 /p:UseSharedCompilation=falsedotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net10.0 /p:UseSharedCompilation=falsedotnet build src\PatternKit.Generators.Abstractions\PatternKit.Generators.Abstractions.csproj /p:UseSharedCompilation=falsedotnet build src\PatternKit.Generators\PatternKit.Generators.csproj /p:UseSharedCompilation=falsedotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~PollingConsumerTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falsedotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~PollingConsumerTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falsedotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~PollingConsumerGeneratorTests|FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falsedotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~PollingConsumerGeneratorTests|FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falsegit diff --checkLocal full examples build is blocked by the existing compiler/analyzer mismatch (
CS9057) that prevents unrelated generated example types from being produced; hosted CI remains the full matrix gate.