EricksonLopez.DistributedLock
dotnet-distributedlock · Reliability & Concurrency
On this page (20 sections)
1. Identity, Tier & Maturity Profile#
2. Value Proposition & Problem Solved#
High-performance distributed locking & mutual exclusion ecosystem for .NET 8/9/10. Zero-exception Result pattern, Native AOT compliant, OpenTelemetry metrics, and native providers for PostgreSQL, SQL Server, MySQL, MariaDB, Oracle, SQLite, and Redis.
Uncoordinated worker replicas execute scheduled jobs or reconciliations simultaneously, and legacy lock tools often mandate extra ZooKeeper or Consul clusters.
3. Quick Install#
Primary package: EricksonLopez.DistributedLock.Abstractions
dotnet add package EricksonLopez.DistributedLock.Abstractions --version 1.0.0<PackageReference Include="EricksonLopez.DistributedLock.Abstractions" Version="1.0.0" /><PackageVersion Include="EricksonLopez.DistributedLock.Abstractions" Version="1.0.0" />4. Verified Ecosystem Metrics#
Snapshot retrieved UTC: 2026-12-01
5. When to Use & When Not to Use#
When to use
- You want Result-based IDistributedLockProvider mutual exclusion backed by your existing database (PostgreSQL, SQL Server, MySQL, MariaDB, Oracle, SQLite) or Redis.
When NOT to use
- You need multi-step optimistic version conflict detection on entities—use EricksonLopez.Concurrency.
6. Core Capabilities & Design Invariants#
Decoupled Core Abstractions
Core contract lives in EricksonLopez.DistributedLock.Abstractions with zero concrete driver dependencies.
7 Provider Backends & Keepalive
Supports TryAcquireAsync, jittered polling AcquireAsync, session locks, and transaction-scoped advisory locks.
7. Included NuGet Packages & Adapters#
| Package ID | Status | NuGet / Local | TFMs | AOT Status | Downloads | Description |
|---|---|---|---|---|---|---|
| EricksonLopez.DistributedLock.AbstractionsPrimary | Published | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 244 | Tier 0 distributed locking contracts, provider abstractions, and Result-based failure models for the EricksonLopez platform. |
| EricksonLopez.DistributedLock.PostgreSql | Published | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 134 | High-performance PostgreSQL advisory lock provider implementing IDistributedLockProvider for the EricksonLopez platform. Features Native AOT compatibility, zero-allocation error handling, keepalive heartbeats, and OpenTelemetry instrumentation. |
| EricksonLopez.DistributedLock.Redis | Published | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 132 | Redis distributed lock provider implementing IDistributedLockProvider for the EricksonLopez platform using StackExchange.Redis with Lua scripts for atomic release and lease renewals. Features zero-allocation error handling and OpenTelemetry instrumentation. Native AOT compatibility is subject to StackExchange.Redis AOT support for the specific version in use. |
| EricksonLopez.DistributedLock.Oracle | Published | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 131 | Oracle Database lock provider implementing IDistributedLockProvider for the EricksonLopez platform using DBMS_LOCK via Oracle.ManagedDataAccess.Core. Features Native AOT compatibility, zero-allocation error handling, and OpenTelemetry instrumentation. |
| EricksonLopez.DistributedLock.MariaDb | Published | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 130 | MariaDB user-level lock provider implementing IDistributedLockProvider for the EricksonLopez platform using GET_LOCK / RELEASE_LOCK via MySqlConnector. Features Native AOT compatibility, zero-allocation error handling, and OpenTelemetry instrumentation. |
| EricksonLopez.DistributedLock.Sqlite | Published | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 127 | SQLite lock provider implementing IDistributedLockProvider for the EricksonLopez platform using database-enforced concurrency locks via Microsoft.Data.Sqlite. Features Native AOT compatibility, zero-allocation error handling, and OpenTelemetry instrumentation. |
| EricksonLopez.DistributedLock.MySql | Published | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 126 | MySQL user-level lock provider implementing IDistributedLockProvider for the EricksonLopez platform using GET_LOCK / RELEASE_LOCK via MySqlConnector. Features Native AOT compatibility, zero-allocation error handling, and OpenTelemetry instrumentation. |
| EricksonLopez.DistributedLock.SqlServer | Published | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 122 | Microsoft SQL Server application lock provider implementing IDistributedLockProvider for the EricksonLopez platform using sp_getapplock / sp_releaseapplock. Features Native AOT compatibility, zero-allocation error handling, keepalive heartbeats, and OpenTelemetry instrumentation. |
8. Quick Start Code Example#
Grounded in verified public APIs from EricksonLopez.DistributedLock. Compile with `<ImplicitUsings>disable</ImplicitUsings>` and explicit imports.
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Npgsql;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPostgresDistributedLock(
sp => new NpgsqlConnection(builder.Configuration.GetConnectionString("Database")),
options =>
{
options.KeepaliveCadence = TimeSpan.FromSeconds(30);
options.InitialPollingInterval = TimeSpan.FromMilliseconds(25);
options.MaxPollingInterval = TimeSpan.FromMilliseconds(500);
options.JitterRatio = 0.25;
});9. Architecture & Dependency Flow#
Rendering diagram…
flowchart LR lib_distributedlock["EricksonLopez.DistributedLock (L2)"] lib_result["EricksonLopez.Result (L0)"] lib_distributedlock --> lib_result
View accessible text summary and structure
1 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.
| Direction | Library | Tier | Relationship Kinds |
|---|---|---|---|
| Upstream | EricksonLopez.Result | L0 | Compile-Time, NuGet Package |
flowchart LR
lib_distributedlock["EricksonLopez.DistributedLock (L2)"]
lib_result["EricksonLopez.Result (L0)"]
lib_distributedlock --> lib_result10. Target Frameworks & Native AOT / Trimming Matrix#
MSBuild `.csproj` inspection across 8 packages: 8 Full, 0 Partial, 0 Incompatible, 0 NotApplicable (analyzers/generators).
| Package ID | IsAotCompatible | EnableTrimAnalyzer | Verified AOT Status | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.DistributedLock.Abstractions | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DistributedLock.PostgreSql | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DistributedLock.Redis | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DistributedLock.Oracle | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DistributedLock.MariaDb | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DistributedLock.Sqlite | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DistributedLock.MySql | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DistributedLock.SqlServer | true | true | Full | net8.0, net9.0, net10.0 |
11. Upstream Dependencies & Downstream Dependents#
Upstream Dependencies (1)
Downstream Dependents (0)
No other EricksonLopez.* libraries currently depend on this family.
12. Optional Adapters & Third-Party Integrations#
Internal Adapter Edges & Integration Packages
No optional cross-family adapter edges or integration packages are recorded for this library.
Verified External NuGet Dependencies (8)
13. Configuration & DI Registration Summary#
Verified DI & Configuration Entry Points
MariaDbDistributedLockExtensions.AddMariaDbDistributedLockRegisters the MariaDB distributed lock provider with a connection factory delegate.
MySqlDistributedLockExtensions.AddMySqlDistributedLockRegisters the MySQL distributed lock provider with a connection factory delegate.
OracleDistributedLockExtensions.AddOracleDistributedLockRegisters the Oracle distributed lock provider with a connection factory delegate.
PostgresDistributedLockExtensions.AddPostgresDistributedLockRegisters the PostgreSQL distributed lock provider with a `DbConnection` factory delegate.
RedisDistributedLockExtensions.AddRedisDistributedLockRegisters Redis distributed lock services resolving the required `IConnectionMultiplexer` from the service provider.
SqlServerDistributedLockExtensions.AddSqlServerDistributedLockRegisters SQL Server distributed lock services using the specified connection factory delegate.
SqliteDistributedLockExtensions.AddSqliteDistributedLockRegisters SQLite distributed lock services using the specified connection factory delegate.
Key Public Types & Contracts
EricksonLopez.DistributedLock.Abstractions.CompositeDistributedLockHandle (class)Represents a composite distributed lock handle holding multiple underlying resource locks acquired in canonical order.
EricksonLopez.DistributedLock.Abstractions.DistributedLockAttribute (class)Specifies declarative distributed mutual exclusion for target classes or methods.
EricksonLopez.DistributedLock.Abstractions.DistributedLockErrors (class)Provides predefined standard domain errors for distributed locking failures.
EricksonLopez.DistributedLock.Abstractions.DistributedLockExtensions (class)Provides extension methods for `IDistributedLockProvider` to execute operations within a distributed lock scope.
EricksonLopez.DistributedLock.Abstractions.DistributedLockMetrics (class)Provides OpenTelemetry instrumentation and metrics for distributed lock operations.
EricksonLopez.DistributedLock.Abstractions.IDistributedLockHandle (interface)Defines a contract for a distributed lock handle whose disposal releases the acquired lock.
EricksonLopez.DistributedLock.Abstractions.IDistributedLockProvider (interface)Defines a contract for coordinating distributed mutual exclusion across process boundaries.
EricksonLopez.DistributedLock.MariaDb.MariaDbDistributedLockHandle (class)Represents an active MariaDB user-level lock handle that releases the lock upon disposal.
EricksonLopez.DistributedLock.MariaDb.MariaDbDistributedLockProvider (class)Provides distributed locks backed by MariaDB user-level locking functions.
EricksonLopez.DistributedLock.MariaDb.MariaDbLockOptions (class)Specifies configuration options for the MariaDB distributed lock provider.
EricksonLopez.DistributedLock.MariaDb.MariaDbTransactionLockExtensions (class)Provides extension methods for acquiring MariaDB locks within active database transactions.
EricksonLopez.DistributedLock.MySql.MySqlDistributedLockHandle (class)Represents an active MySQL user-level lock handle that releases the lock upon disposal.
14. Verified Performance Benchmarks#
All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).
No non-MEGA-AUDIT `BenchmarkDotNet.Artifacts` files were verified for this library in the snapshot (`hasBenchmarks: false`).
15. Release History & NuGet vs Repo Status#
Version lag detected: NuGet.org latest published version is v1.0.0, while local repository HEAD is at v2.1.0.
| Version | Source | Published Date | Summary |
|---|---|---|---|
| v1.0.0 ↗ | github | 2026-09-22 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.DistributedLock.Abstractions` | `1.0.0` | | `EricksonLopez.DistributedLock.PostgreSql` | `1.0.0` | | `EricksonLopez.DistributedLock.SqlServer` | `1.0.0` | | `EricksonLopez.DistributedLock.MySql` | `1.0.0` | | `EricksonLopez.DistributedLock.MariaDb` | `1.0.0` | | `EricksonLopez.DistributedLock.Oracle`... |
| v1.0.0 ↗ | nuget | 2026-09-22 | Published EricksonLopez.DistributedLock.Abstractions 1.0.0 to NuGet.org. |
16. Complementary & Related Libraries#
Libraries in the same tier, architectural layer, or directly paired via dependency edges.
17. Documentation, API Reference & Portal Links#
Conceptual Documentation (Starlight) →
Extracted XML API Reference →
9 namespaces · 43 types · 225 members
Ecosystem Dependency Map →
Learning Center & Handbook →
Per-library conceptual Starlight pages expand in M4; API Reference pages expand in M3.2.
18. Source Repository, License & Contributing#
Released under the MIT License. All assemblies follow EricksonLopez.* build invariants: explicit imports, strong-name signing (`EricksonLopez.snk`), and ASCII author metadata (`Erickson Lopez`).
19. Troubleshooting, Pitfalls & Migration Guidance#
- Install EricksonLopez.DistributedLock.Abstractions for domain/application interfaces and one concrete provider package in Infrastructure.
- Version lag detected: NuGet.org latest published version is v1.0.0, while local repository HEAD is at v2.1.0.
20. Quality & Verification Evidence#
- Strong-Name Signing (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- XML Documentation Extraction
- Verified (9 namespaces, 43 types, 225 members)
- MSBuild AOT / Trim Attributes
- 8 Full / 0 Partial / 0 Incompatible / 0 N/A
- BenchmarkDotNet Artifacts
- 0 total (0 measured, 0 na_error)
Explicit Verification Boundaries & Limitations
- All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).