feat: add priority queue pattern support#304
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 3m 29s ⏱️ Results for commit 9cb213a. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
Adds the Priority Queue cloud architecture pattern end-to-end in PatternKit (runtime fluent API + source generator + examples + docs/catalog entries), aligning with the repo’s “production readiness” coverage checks.
Changes:
- Introduces
PriorityQueuePolicy<TItem, TPriority>with fluent configuration, enqueue/dequeue/peek results, and FIFO stability for equal priorities. - Adds a Roslyn incremental generator (
[GeneratePriorityQueue]+[PriorityQueuePrioritySelector]) with diagnosticsPKPQ001-003and generator test coverage. - Adds docs, catalogs, and a DI-importable example (plus example tests) and updates pattern coverage/counters.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Cloud/PriorityQueue/PriorityQueuePolicyTests.cs | TinyBDD coverage for runtime priority queue behavior and validation. |
| test/PatternKit.Generators.Tests/PriorityQueueGeneratorTests.cs | Verifies generator output, diagnostics, escaping, and emit success. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Ensures new generator attributes are included in attribute coverage tests. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates catalog expectations to include “Priority Queue” and adjusts CloudArchitecture count. |
| test/PatternKit.Examples.Tests/PriorityQueueDemo/FulfillmentPriorityQueueDemoTests.cs | Validates fluent vs generated behavior and DI importability. |
| src/PatternKit.Generators/PriorityQueue/PriorityQueueGenerator.cs | New incremental generator and diagnostics for priority queue factory generation. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Documents newly introduced generator diagnostics PKPQ001–PKPQ003. |
| src/PatternKit.Generators.Abstractions/Cloud/PriorityQueueAttributes.cs | Adds [GeneratePriorityQueue] and [PriorityQueuePrioritySelector] attributes. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Adds Priority Queue to the pattern coverage catalog. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds the “Fulfillment Priority Queue” example descriptor. |
| src/PatternKit.Examples/PriorityQueueDemo/FulfillmentPriorityQueueDemo.cs | Adds fluent + generated demo implementation and IServiceCollection extensions. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires the new example into the aggregate example registration. |
| src/PatternKit.Core/Cloud/PriorityQueue/PriorityQueuePolicy.cs | Implements the new priority queue policy and result types. |
| docs/patterns/toc.yml | Adds Priority Queue to the patterns table of contents. |
| docs/patterns/cloud/priority-queue.md | New pattern documentation page for Priority Queue. |
| docs/guides/pattern-coverage.md | Adds Priority Queue to the coverage guide table. |
| docs/generators/toc.yml | Adds Priority Queue generator docs to TOC. |
| docs/generators/priority-queue.md | New generator documentation page and diagnostics list. |
| docs/generators/index.md | Adds Priority Queue to generator index table. |
| docs/examples/toc.yml | Adds Fulfillment Priority Queue to examples TOC. |
| docs/examples/index.md | Adds Fulfillment Priority Queue to examples index summary list. |
| docs/examples/fulfillment-priority-queue.md | New example documentation page for the fulfillment demo. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sb.Append(GetAccessibility(type.DeclaredAccessibility)).Append(' '); | ||
| if (type.IsStatic) | ||
| sb.Append("static "); | ||
| else if (type.IsAbstract && type.TypeKind == TypeKind.Class) | ||
| sb.Append("abstract "); | ||
| else if (type.IsSealed && type.TypeKind == TypeKind.Class) | ||
| sb.Append("sealed "); | ||
| sb.Append("partial ").Append(type.TypeKind == TypeKind.Struct ? "struct" : "class").Append(' ').Append(type.Name).AppendLine(); |
| private readonly object _gate = new(); | ||
| private readonly List<Entry> _items = []; | ||
| private readonly Func<TItem, TPriority> _prioritySelector; | ||
| private readonly IComparer<TPriority> _comparer; | ||
| private readonly bool _dequeueHighestPriorityFirst; | ||
| private long _nextSequence; | ||
|
|
| queue.Enqueue(new FulfillmentPriorityWork("order-100", "enterprise", expedited: false)); | ||
| var next = queue.Dequeue(); |
| var service = provider.GetRequiredService<FulfillmentPriorityQueueService>(); | ||
| var summary = service.Schedule( | ||
| new FulfillmentPriorityWork("order-standard", "standard", expedited: false), | ||
| new FulfillmentPriorityWork("order-enterprise", "enterprise", expedited: false)); | ||
| ``` |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #304 +/- ##
==========================================
+ Coverage 90.33% 96.03% +5.69%
==========================================
Files 424 428 +4
Lines 35733 35980 +247
Branches 5064 5100 +36
==========================================
+ Hits 32279 34552 +2273
+ Misses 1522 1428 -94
+ Partials 1932 0 -1932
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:
|
🔍 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. |
Code Coverage |
Closes #301.\n\nAdds the Priority Queue cloud architecture pattern with fluent runtime support, source generator attributes and factory generation, TinyBDD coverage, production-shaped DI example, and catalog/docs entries.