feat: add distributed lock lease pattern#498
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
This PR introduces a new Distributed Lock / Lease pattern across the PatternKit stack (runtime + generator + example), and wires it into the production-readiness catalogs, documentation, and benchmark coverage infrastructure.
Changes:
- Adds an in-memory lease-based
DistributedLock<TKey>runtime with acquire/renew/release, expiry, snapshots, and builder configuration. - Adds
[GenerateDistributedLock]+ an incremental generator that emits configuredDistributedLock<TKey>factory methods, with diagnostics and test coverage. - Adds a DI-importable “Order Allocation” example plus docs, catalog entries, and BenchmarkDotNet scenario coverage/matrix updates.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Cloud/DistributedLocks/DistributedLockTests.cs | New TinyBDD coverage for the runtime lock/lease behavior (acquire/contend/renew/release/validation). |
| test/PatternKit.Generators.Tests/DistributedLockGeneratorTests.cs | Generator tests for valid output, invalid declarations diagnostics, nested hosts, and malformed key types. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Adds [GenerateDistributedLock] to attribute coverage + validates defaults. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates production catalog expectations for the new pattern count/name. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs | Updates expected totals and adds humanization mapping for the new benchmark class name. |
| test/PatternKit.Examples.Tests/DistributedLockDemo/OrderAllocationDistributedLockDemoTests.cs | Verifies fluent vs generated example behavior and DI importability. |
| src/PatternKit.Generators/DistributedLocks/DistributedLockGenerator.cs | New incremental generator for distributed lock factories + diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new diagnostic IDs PKDLOCK001/PKDLOCK002. |
| src/PatternKit.Generators.Abstractions/DistributedLocks/DistributedLockAttributes.cs | Adds GenerateDistributedLockAttribute abstraction API. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Adds the new pattern entry with source/test/docs paths. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds the new example descriptor entry for production-readiness validation. |
| src/PatternKit.Examples/DistributedLockDemo/OrderAllocationDistributedLockDemo.cs | New DI-ready example demonstrating fluent + generated paths. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Integrates the new example into the aggregate AddPatternKitExamples() registrations. |
| src/PatternKit.Core/Cloud/DistributedLocks/DistributedLock.cs | New runtime implementation and related record/result/state types. |
| README.md | Updates pattern counts/tables and adds benchmark rows (Pending values). |
| docs/patterns/toc.yml | Adds the new pattern page to the patterns TOC. |
| docs/patterns/cloud/distributed-lock-lease.md | New pattern documentation page. |
| docs/index.md | Updates pattern counts/tables to include the new pattern. |
| docs/guides/benchmark-results.md | Updates matrix totals and adds rows/coverage entries for the new benchmarks and generator. |
| docs/generators/toc.yml | Adds generator doc link to the generators TOC. |
| docs/generators/index.md | Adds distributed lock generator to the generator index table. |
| docs/generators/distributed-lock.md | New distributed lock generator documentation page. |
| docs/examples/toc.yml | Adds the new example page to the examples TOC. |
| docs/examples/order-allocation-distributed-lock.md | New example documentation page. |
| docs/examples/index.md | Adds the new example to the examples index list. |
| benchmarks/PatternKit.Benchmarks/Cloud/DistributedLockBenchmarks.cs | Adds benchmark scenarios for fluent vs generated construction/execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test Results 12 files 12 suites 11m 33s ⏱️ Results for commit 4c8cb9f. ♻️ 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. |
f2e83c0 to
0140674
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #498 +/- ##
==========================================
+ Coverage 97.41% 97.42% +0.01%
==========================================
Files 603 607 +4
Lines 49238 49540 +302
Branches 3184 34 -3150
==========================================
+ Hits 47963 48263 +300
- Misses 1275 1277 +2
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:
|
0140674 to
f544e3f
Compare
f544e3f to
4c8cb9f
Compare
Code Coverage |
Closes #483.
Summary
Validation