Skip to content

feat: add backpressure pattern#494

Merged
JerrettDavis merged 1 commit into
mainfrom
feature/backpressure-pattern-489
Jun 1, 2026
Merged

feat: add backpressure pattern#494
JerrettDavis merged 1 commit into
mainfrom
feature/backpressure-pattern-489

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Summary

  • add Backpressure runtime policy with reject, wait, drop newest, drop oldest, shed, and observe saturation modes
  • add source generator, diagnostics, TinyBDD runtime/generator/example/hosting/catalog coverage
  • add IServiceCollection registration, production example, benchmark route, and docs/catalog updates

Validation

  • dotnet build PatternKit.slnx --no-restore -p:UseSharedCompilation=false
  • dotnet format PatternKit.slnx --verify-no-changes --verbosity minimal
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj --no-build -p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj --no-build -p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Hosting.Extensions.Tests\PatternKit.Hosting.Extensions.Tests.csproj --no-build -p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Examples.Tests\PatternKit.Examples.Tests.csproj --no-build -p:UseSharedCompilation=false

Closes #489

Copilot AI review requested due to automatic review settings June 1, 2026 07:07
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

⚠️ 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

github-actions Bot commented Jun 1, 2026

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

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 a new Backpressure messaging reliability pattern to PatternKit, including a runtime policy API, a Roslyn source generator + diagnostics, DI registration, production-style example, benchmarks, and catalog/docs/test coverage to meet the production-readiness matrix expectations.

Changes:

  • Introduces BackpressurePolicy<TResult> runtime policy with multiple saturation modes and result reporting.
  • Adds [GenerateBackpressurePolicy] + incremental generator (PKBP00x diagnostics) and generator test coverage.
  • Integrates Backpressure into hosting extensions, examples/catalog, benchmarks, and documentation tables/TOCs.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/PatternKit.Tests/Messaging/Reliability/Backpressure/BackpressurePolicyTests.cs Adds runtime behavior/validation scenarios for backpressure policy.
test/PatternKit.Hosting.Extensions.Tests/DependencyInjection/PatternKitServiceCollectionExtensionsTests.cs Verifies DI registration path for backpressure policy and input validation.
test/PatternKit.Generators.Tests/BackpressurePolicyGeneratorTests.cs Adds generator scenarios + diagnostic validation for backpressure generator.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates catalog assertions to include Backpressure in production-readiness audits.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs Updates expected benchmark route-result totals for new pattern.
test/PatternKit.Examples.Tests/BackpressureDemo/CheckoutBackpressureDemoTests.cs Validates example works via fluent/generated policies and DI import.
src/PatternKit.Hosting.Extensions/DependencyInjection/PatternKitServiceCollectionExtensions.cs Adds AddPatternKitBackpressurePolicy<TResult> registration helper.
src/PatternKit.Generators/Backpressure/BackpressurePolicyGenerator.cs Implements incremental generator emitting backpressure policy factories + diagnostics.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Records new analyzer IDs (PKBP001–PKBP004).
src/PatternKit.Generators.Abstractions/Backpressure/BackpressureAttributes.cs Adds [GenerateBackpressurePolicy] attribute surface.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Registers Backpressure in the pattern catalog with docs/source/tests/example pointers.
src/PatternKit.Examples/ProductionReadiness/PatternKitHostingIntegrationCatalog.cs Adds Backpressure to reusable hosting integration catalog.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds “Checkout Backpressure” to the example catalog metadata.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Wires the new example into the examples DI catalog.
src/PatternKit.Examples/BackpressureDemo/CheckoutBackpressureDemo.cs Adds production-style demo (policy + generated factory + DI import).
src/PatternKit.Core/Messaging/Reliability/Backpressure/BackpressurePolicy.cs Adds Backpressure policy runtime implementation and result types.
README.md Updates pattern counts/table and benchmark snapshot rows for Backpressure.
docs/patterns/toc.yml Adds Backpressure to patterns TOC.
docs/patterns/messaging/backpressure.md New pattern documentation page for Backpressure.
docs/index.md Updates top-level pattern counts/table to include Backpressure.
docs/guides/hosting-extensions.md Documents DI registration example + hosting integration matrix entry.
docs/guides/benchmark-results.md Updates benchmark matrices/totals + adds Backpressure rows/hosting integration entry.
docs/generators/toc.yml Adds Backpressure generator doc to generators TOC.
docs/generators/index.md Adds Backpressure generator to generator index and sample block.
docs/generators/backpressure.md New generator documentation page for Backpressure generator + diagnostics list.
docs/examples/toc.yml Adds Checkout Backpressure example to examples TOC.
docs/examples/index.md Adds Checkout Backpressure to examples landing page list.
docs/examples/checkout-backpressure.md New example doc page for Checkout Backpressure.
benchmarks/PatternKit.Benchmarks/Messaging/BackpressureBenchmarks.cs Adds BenchmarkDotNet routes for fluent vs generated backpressure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/PatternKit.Core/Messaging/Reliability/Backpressure/BackpressurePolicy.cs Outdated
Comment thread src/PatternKit.Generators/Backpressure/BackpressurePolicyGenerator.cs Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Test Results

    12 files      12 suites   11m 25s ⏱️
 4 118 tests  4 118 ✅ 0 💤 0 ❌
12 785 runs  12 785 ✅ 0 💤 0 ❌

Results for commit b6b2075.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

🔍 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 Jun 1, 2026

Codecov Report

❌ Patch coverage is 98.61111% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.41%. Comparing base (00ee468) to head (b6b2075).

Files with missing lines Patch % Lines
...rators/Backpressure/BackpressurePolicyGenerator.cs 97.76% 3 Missing ⚠️
...ing/Reliability/Backpressure/BackpressurePolicy.cs 98.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main     #494     +/-   ##
=========================================
  Coverage   97.40%   97.41%             
=========================================
  Files         587      591      +4     
  Lines       48026    48386    +360     
  Branches     3101       34   -3067     
=========================================
+ Hits        46782    47133    +351     
- Misses       1244     1253      +9     
Flag Coverage Δ
unittests 97.41% <98.61%> (+<0.01%) ⬆️

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 force-pushed the feature/backpressure-pattern-489 branch from 3a3494b to 725614e Compare June 1, 2026 07:25
Copilot AI review requested due to automatic review settings June 1, 2026 07:40
@JerrettDavis JerrettDavis force-pushed the feature/backpressure-pattern-489 branch from 725614e to 1b106ad Compare June 1, 2026 07:40
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

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

@JerrettDavis JerrettDavis force-pushed the feature/backpressure-pattern-489 branch from 1b106ad to b6b2075 Compare June 1, 2026 08:02
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Code Coverage

Summary
  Generated on: 06/01/2026 - 08:09:41
  Coverage date: 06/01/2026 - 08:07:53 - 06/01/2026 - 08:09:30
  Parser: MultiReport (8x Cobertura)
  Assemblies: 5
  Classes: 1748
  Files: 591
  Line coverage: 97.4%
  Covered lines: 47131
  Uncovered lines: 1255
  Coverable lines: 48386
  Total lines: 102895
  Branch coverage: 84.3% (15088 of 17877)
  Covered branches: 15088
  Total branches: 17877
  Method coverage: 97.2% (9165 of 9422)
  Full method coverage: 91.5% (8624 of 9422)
  Covered methods: 9165
  Fully covered methods: 8624
  Total methods: 9422

PatternKit.Core                                                                                                     96.1%
  PatternKit.Application.ActivityTracking.ActivityGateState                                                          100%
  PatternKit.Application.ActivityTracking.ActivityLease                                                              100%
  PatternKit.Application.ActivityTracking.ActivityRecord                                                             100%
  PatternKit.Application.ActivityTracking.ActivityTracker                                                            100%
  PatternKit.Application.Aggregates.AggregateCommandHandler<T1, T2, T3>                                              100%
  PatternKit.Application.Aggregates.AggregateCommandResult<T>                                                        100%
  PatternKit.Application.Aggregates.AggregateRoot<T1, T2>                                                            100%
  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.BoundedContexts.BoundedContextAdapter                                                       100%
  PatternKit.Application.BoundedContexts.BoundedContextCapability                                                   83.3%
  PatternKit.Application.BoundedContexts.BoundedContextDescriptor                                                   95.4%
  PatternKit.Application.ContextMaps.ContextMapDescriptor                                                           96.8%
  PatternKit.Application.ContextMaps.ContextMapRelationship                                                          100%
  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.DomainServices.DomainServiceOperation<T1, T2>                                               100%
  PatternKit.Application.DomainServices.DomainServiceRegistry<T1, T2>                                                100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                        100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                   97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                            80%
  PatternKit.Application.EventualConsistency.EventualConsistencyEvaluation<T>                                       92.3%
  PatternKit.Application.EventualConsistency.EventualConsistencyMonitor<T>                                          97.2%
  PatternKit.Application.EventualConsistency.EventualConsistencyMonitorState<T>                                      100%
  PatternKit.Application.EventualConsistency.EventualConsistencyWatermarks<T>                                       96.7%
  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.ManualTaskGates.ManualTaskGate<T>                                                          98.5%
  PatternKit.Application.ManualTaskGates.ManualTaskGateState<T>                                                      100%
  PatternKit.Application.ManualTaskGates.ManualTaskRecord<T>                                                        96.9%

@JerrettDavis JerrettDavis merged commit c6c36d7 into main Jun 1, 2026
12 checks passed
@JerrettDavis JerrettDavis deleted the feature/backpressure-pattern-489 branch June 1, 2026 08:15
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 Backpressure pattern

2 participants