Skip to content

feat: add polling consumer pattern support#296

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

feat: add polling consumer pattern support#296
JerrettDavis merged 1 commit into
mainfrom
feat/polling-consumer-pattern

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Closes #290.

What changed

  • Adds the fluent PollingConsumer<TPayload> runtime pattern for explicit pull-based message consumption.
  • Adds [GeneratePollingConsumer] / [PollingConsumerSource] source generator support with diagnostics and attribute coverage.
  • Adds a production-shaped warehouse replenishment polling example with IServiceCollection registration and aggregate AddPatternKitExamples() integration.
  • Adds runtime, generator, example, catalog, and docs coverage.

Local 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.Abstractions\PatternKit.Generators.Abstractions.csproj /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~PollingConsumerTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~PollingConsumerTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~PollingConsumerGeneratorTests|FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~PollingConsumerGeneratorTests|FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • git diff --check

Local 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.

Copilot AI review requested due to automatic review settings May 22, 2026 01:50
@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

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

  1 files    1 suites   2m 21s ⏱️
887 tests 887 ✅ 0 💤 0 ❌
892 runs  892 ✅ 0 💤 0 ❌

Results for commit 873a345.

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 “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.

Comment on lines +33 to +38
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();
@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 01:55:39
  Coverage date: 05/22/2026 - 01:53:55 - 05/22/2026 - 01:55:29
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1170
  Files: 497
  Line coverage: 94.9%
  Covered lines: 34523
  Uncovered lines: 1849
  Coverable lines: 36372
  Total lines: 80723
  Branch coverage: 76.5% (10072 of 13154)
  Covered branches: 10072
  Total branches: 13154
  Method coverage: 96.4% (6595 of 6837)
  Full method coverage: 88.6% (6058 of 6837)
  Covered methods: 6595
  Fully covered methods: 6058
  Total methods: 6837

PatternKit.Core                                                                                                    96.3%
  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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 97.87234% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.06%. Comparing base (4e8e7ad) to head (873a345).

Files with missing lines Patch % Lines
...mples/Messaging/WarehousePollingConsumerExample.cs 90.00% 2 Missing ⚠️
...t.Generators/Messaging/PollingConsumerGenerator.cs 98.38% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 96.06% <97.87%> (+5.64%) ⬆️

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.

@JerrettDavis JerrettDavis merged commit c1c18b0 into main May 22, 2026
13 checks passed
@JerrettDavis JerrettDavis deleted the feat/polling-consumer-pattern branch May 22, 2026 02:00
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 Polling Consumer enterprise integration pattern

2 participants