ReactiveLock.Core 0.0.13

There is a newer version of this package available.
See the version list below for details.
dotnet add package ReactiveLock.Core --version 0.0.13
                    
NuGet\Install-Package ReactiveLock.Core -Version 0.0.13
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ReactiveLock.Core" Version="0.0.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ReactiveLock.Core" Version="0.0.13" />
                    
Directory.Packages.props
<PackageReference Include="ReactiveLock.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ReactiveLock.Core --version 0.0.13
                    
#r "nuget: ReactiveLock.Core, 0.0.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ReactiveLock.Core@0.0.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ReactiveLock.Core&version=0.0.13
                    
Install as a Cake Addin
#tool nuget:?package=ReactiveLock.Core&version=0.0.13
                    
Install as a Cake Tool

ReactiveLock

ReactiveLock is a .NET 9 library for reactive, distributed lock coordination. It lets multiple application instances track “busy”/“idle” state and react to changes via async handlers. Redis is provided out-of-the-box, but you can plug in any backend.


Packages

  • ReactiveLock.Core
    Core abstractions and in‑process state management. You can use it if no distributed strategy is needed.

  • ReactiveLock.Distributed.Redis
    Redis‑backed distributed implementation of ReactiveLock.Core.

  • ReactiveLock.DependencyInjection
    Dependency Injection extensions for controller, state, and factory services with keyed resolution support for ReactiveLock.Distributed.* libs..


Concepts

  • Tracker Controller (IReactiveLockTrackerController)
    Call IncrementAsync() / DecrementAsync() to mark this instance busy or idle.

  • Tracker State (IReactiveLockTrackerState)
    Call IsBlockedAsync() or WaitIfBlockedAsync() to observe or wait for global idle state.

  • Store (IReactiveLockTrackerStore)
    Persists and propagates instance states. Redis store is included; custom stores are supported.


Installation

dotnet add package ReactiveLock.Core
dotnet add package ReactiveLock.DependencyInjection
dotnet add package ReactiveLock.Distributed.Redis

Registration

In Program.cs (or equivalent):

// 1. Register factory and Redis connection
builder.Services.InitializeDistributedRedisReactiveLock("instance-id");

builder.Services.AddSingleton<IConnectionMultiplexer>(
    ConnectionMultiplexer.Connect("localhost:6379"));

// 2. Register one or more locks
builder.Services.AddDistributedRedisReactiveLock(
    lockKey: "my-lock",
    onLockedHandlers:   [ sp => Task.CompletedTask ],
    onUnlockedHandlers: [ sp => Task.CompletedTask ]);

// 3. After Build(), start subscription loop
var app = builder.Build();
await app.UseDistributedRedisReactiveLockAsync();

Usage

var factory    = app.Services.GetRequiredService<IReactiveLockTrackerFactory>();
var controller = factory.GetTrackerController("my-lock");
var state      = factory.GetTrackerState("my-lock");

// Mark busy
await controller.IncrementAsync();
// … work …
await controller.DecrementAsync();

// React to global state
if (await state.IsBlockedAsync())
    /* handle blocked */;

await state.WaitIfBlockedAsync();

Requirements

  • .NET 9

License

MIT © Michel Oliveira

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.22-beta.6 12 8/13/2025
0.0.22-beta.5 15 8/11/2025
0.0.22-beta.4 27 8/10/2025
0.0.22-beta.3 16 8/10/2025
0.0.22-beta.2 50 8/9/2025
0.0.22-beta.1 48 8/9/2025
0.0.21 875 7/30/2025
0.0.20 92 7/30/2025
0.0.19 114 7/29/2025
0.0.17 93 7/29/2025
0.0.16 94 7/29/2025
0.0.15 173 7/26/2025
0.0.14 138 7/26/2025
0.0.13 144 7/26/2025
0.0.12 202 7/26/2025
0.0.11 275 7/25/2025
0.0.7 302 7/25/2025
0.0.6 310 7/25/2025
0.0.5 322 7/25/2025