fix(di): cache registry factory execution - #52
Conversation
Resolve each registration through one execution-and-publication Lazy so concurrent paths share the same shield or cached construction failure.
|
Warning Review limit reached
Next review available in: 4 minutes Limit details: You’ve used all 10 included reviews currently available. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Comment |
Greptile SummaryThis PR makes named shield factory initialization concurrency-safe and caches both successful values and construction failures. It also validates unknown backoff enum values and adds DI/configuration contract coverage.
Confidence Score: 5/5The PR appears safe to merge, with no actionable defects identified in the changed behavior. The singleton registry and keyed-service paths share the same Lazy cache, ensuring one factory execution and a consistent cached value or exception, while the stricter backoff validation matches the stated contract.
|
| Filename | Overview |
|---|---|
| src/Kevlar.Extensions.DependencyInjection/IKevlarRegistry.cs | Documents case-sensitive naming and the shared value-or-exception caching contract. |
| src/Kevlar.Extensions.DependencyInjection/KevlarRegistry.cs | Uses Lazy execution-and-publication semantics to ensure concurrent callers execute each factory once and share its outcome. |
| src/Kevlar.Extensions.DependencyInjection/ShieldDefinition.cs | Explicitly rejects undefined BackoffKind values rather than interpreting them as exponential. |
| tests/Kevlar.Tests/DependencyInjectionContractTests.cs | Adds broad contract coverage for concurrent DI resolution, cached failures, keyed paths, registration semantics, names, and configuration behavior. |
Sequence Diagram
sequenceDiagram
participant C1 as Concurrent caller 1
participant C2 as Concurrent caller 2
participant R as KevlarRegistry
participant L as Cached Lazy
participant F as Shield factory
C1->>R: GetShield(name)
C2->>R: GetShield(name)
R->>L: GetOrAdd(key)
R->>L: GetOrAdd(key)
L->>F: Execute once
F-->>L: Shield or exception
L-->>R: Cached outcome
R-->>C1: Same outcome
R-->>C2: Same outcome
Reviews (1): Last reviewed commit: "fix(di): cache registry factory executio..." | Re-trigger Greptile
Summary
TryGet, and keyed DI pathsBackoffKindvalues instead of silently treating them as exponentialCloses #25
Validation
dotnet build Kevlar.slnx -c Release --no-incrementaldotnet run --project tests/Kevlar.Tests -c Release --no-build -- --timeout 5m(352 passed)dotnet run --project tests/Kevlar.NetStandard.Tests -c Release --no-build -- --timeout 5m(1 passed)dotnet run --project tests/Kevlar.IntegrationTests -c Release --no-build -- --timeout 5m(16 passed)dotnet run --project tests/Kevlar.Analyzers.Tests -c Release --no-build -- --timeout 5m(19 passed)