EricksonLopez.DistributedLock
dotnet-distributedlock · Fiabilidad y Concurrencia
En esta página (20 secciones)
1. Identidad, Nivel y Perfil de Madurez#
2. Propuesta de Valor y Problema que Resuelve#
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.
Réplicas sin coordinación ejecutan tareas programadas simultáneamente, y muchas soluciones heredadas exigen clústeres adicionales de ZooKeeper o Consul.
3. Instalación Rápida#
Paquete principal: 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. Métricas Verificadas del Ecosistema#
Instantánea recuperada UTC: 2026-12-01
5. Cuándo Usar y Cuándo NO Usar#
Cuándo usar
- Buscas exclusión mutua IDistributedLockProvider basada en Result sobre tu base de datos existente (PostgreSQL, SQL Server, MySQL, MariaDB, Oracle, SQLite) o Redis.
Cuándo NO usar
- Necesitas detección optimista de conflictos por versión sobre entidades; usa EricksonLopez.Concurrency.
6. Capacidades Principales e Invariantes de Diseño#
Abstracciones Desacopladas
El contrato núcleo reside en EricksonLopez.DistributedLock.Abstractions sin dependencias concretas de drivers.
7 Proveedores y Keepalive
Soporta TryAcquireAsync, AcquireAsync con backoff y jitter, bloqueos de sesión y bloqueos transaccionales.
7. Paquetes NuGet y Adaptadores Incluidos#
| ID del Paquete | Estado | NuGet / Local | TFMs | Estado AOT | Descargas | Descripción |
|---|---|---|---|---|---|---|
| EricksonLopez.DistributedLock.AbstractionsPrincipal | Publicado | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Completo | 244 | Tier 0 distributed locking contracts, provider abstractions, and Result-based failure models for the EricksonLopez platform. |
| EricksonLopez.DistributedLock.PostgreSql | Publicado | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Completo | 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 | Publicado | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Completo | 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 | Publicado | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Completo | 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 | Publicado | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Completo | 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 | Publicado | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Completo | 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 | Publicado | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Completo | 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 | Publicado | v1.0.0 / v2.1.0 | net8.0, net9.0, net10.0 | AOT: Completo | 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. Ejemplo Quick Start#
Basado en APIs públicas verificadas de EricksonLopez.DistributedLock. Compila con `<ImplicitUsings>disable</ImplicitUsings>` e importaciones explícitas.
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. Arquitectura y Flujo de Dependencias#
Renderizando diagrama…
flowchart LR lib_distributedlock["EricksonLopez.DistributedLock (L2)"] lib_result["EricksonLopez.Result (L0)"] lib_distributedlock --> lib_result
Ver descripción textual y tabla accesible
1 dependencias hacia librerías aguas arriba y 0 librerías dependientes aguas abajo verificadas en dependencies.json.
| Dirección | Librería | Nivel | Tipos de Relación |
|---|---|---|---|
| Aguas arriba | EricksonLopez.Result | L0 | Tiempo de compilación, Paquete NuGet |
flowchart LR
lib_distributedlock["EricksonLopez.DistributedLock (L2)"]
lib_result["EricksonLopez.Result (L0)"]
lib_distributedlock --> lib_result10. Target Frameworks y Matriz Native AOT / Trimming#
Inspección MSBuild `.csproj` sobre 8 paquetes: 8 Full, 0 Partial, 0 Incompatible, 0 NotApplicable (analizadores/generadores).
| ID del Paquete | IsAotCompatible | EnableTrimAnalyzer | Estado AOT Verificado | 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. Dependencias Aguas Arriba y Dependientes Aguas Abajo#
Dependencias Aguas Arriba (1)
Dependientes Aguas Abajo (0)
Ninguna otra librería EricksonLopez.* depende actualmente de esta familia.
12. Adaptadores Opcionales e Integraciones Externas#
Aristas de Adaptadores Internos y Paquetes de Integración
No se registran aristas de adaptadores opcionales ni paquetes de integración para esta librería.
Dependencias NuGet Externas Verificadas (8)
13. Resumen de Configuración y Registro en DI#
Puntos de Entrada DI y Configuración Verificados
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.
Tipos Públicos y Contratos Clave
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. Benchmarks de Rendimiento Verificados#
Todas las mediciones verificadas provienen estrictamente de `BenchmarkDotNet.Artifacts` ejecutados sobre .NET RyuJIT (existen 0 ejecuciones NativeAOT en esta instantánea).
No se verificaron archivos `BenchmarkDotNet.Artifacts` no-MEGA-AUDIT para esta librería en la instantánea (`hasBenchmarks: false`).
15. Historial de Versiones y Estado NuGet vs Repositorio#
Desfase de versiones detectado: la última versión publicada en NuGet.org es v1.0.0, mientras el HEAD del repositorio local está en v2.1.0.
| Versión | Origen | Fecha de Publicación | Resumen |
|---|---|---|---|
| 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. Librerías Complementarias y Relacionadas#
Librerías en el mismo nivel, capa arquitectónica o vinculadas directamente mediante aristas de dependencia.
17. Documentación, API Reference y Enlaces del Portal#
Documentación Conceptual (Starlight) →
Referencia de API XML Extraída →
9 namespaces · 43 tipos · 225 miembros
Mapa de Dependencias del Ecosistema →
Centro de Aprendizaje y Manual →
Las páginas conceptuales por librería en Starlight se completan en M4; las páginas de API Reference en M3.2.
18. Repositorio Fuente, Licencia y Contribución#
Publicado bajo Licencia MIT. Todos los ensamblados cumplen los invariantes de compilación EricksonLopez.*: importaciones explícitas, firma fuerte (`EricksonLopez.snk`) y metadatos de autor en ASCII (`Erickson Lopez`).
19. Resolución de Problemas, Riesgos y Migración#
- Instala EricksonLopez.DistributedLock.Abstractions para contratos y un paquete proveedor concreto en Infrastructure.
- Desfase de versiones detectado: la última versión publicada en NuGet.org es v1.0.0, mientras el HEAD del repositorio local está en v2.1.0.
20. Evidencia de Calidad y Verificación#
- Firma Fuerte (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- Extracción de Documentación XML
- Verificado (9 namespaces, 43 tipos, 225 miembros)
- Atributos MSBuild AOT / Trimming
- 8 Full / 0 Partial / 0 Incompatible / 0 N/A
- Artefactos BenchmarkDotNet
- 0 total (0 measured, 0 na_error)
Límites Explícitos de Verificación y Alcance
- Todas las mediciones verificadas provienen estrictamente de `BenchmarkDotNet.Artifacts` ejecutados sobre .NET RyuJIT (existen 0 ejecuciones NativeAOT en esta instantánea).