HostLoom.Locking.Pipelines 0.17.0

dotnet add package HostLoom.Locking.Pipelines --version 0.17.0
                    
NuGet\Install-Package HostLoom.Locking.Pipelines -Version 0.17.0
                    
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="HostLoom.Locking.Pipelines" Version="0.17.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HostLoom.Locking.Pipelines" Version="0.17.0" />
                    
Directory.Packages.props
<PackageReference Include="HostLoom.Locking.Pipelines" />
                    
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 HostLoom.Locking.Pipelines --version 0.17.0
                    
#r "nuget: HostLoom.Locking.Pipelines, 0.17.0"
                    
#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 HostLoom.Locking.Pipelines@0.17.0
                    
#: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=HostLoom.Locking.Pipelines&version=0.17.0
                    
Install as a Cake Addin
#tool nuget:?package=HostLoom.Locking.Pipelines&version=0.17.0
                    
Install as a Cake Tool

HostLoom.Locking.Pipelines

A distributed-lock filter for HostLoom.Pipelines, built on the HostLoom.Locking kernel. The package references those two and nothing else; HostLoom.Pipelines stays dependency-free.

var pipeline = Pipe.Create<RefreshContext>(pipe =>
{
    pipe.UseDistributedLock(
        distributedLock,
        context => $"refresh:{context.Region}",
        new LockOptions { Lease = TimeSpan.FromSeconds(30), OnLost = LostLeaseBehavior.Cancel });
    pipe.UseExecute(context => RefreshAsync(context));
});

UseDistributedLock runs the rest of the pipe inside IDistributedLock.ExecuteWithLockAsync, so two contexts with the same key never run downstream at once, across every instance sharing the lock's provider. Different keys run concurrently. LockNotAcquiredException and LockProviderUnavailableException propagate unchanged; a retry filter ahead of this one is the place to decide whether to try again.

Before the rest of the pipe runs, a HeldLock payload is put on the context with the key and the cancellation token the lock handed to the run. The context's own token cannot be replaced, so a downstream filter that must stop when the lease is lost watches HeldLock.CancellationToken, which the lock cancels when the options ask for LostLeaseBehavior.Cancel.

The lock is coordination, not correctness, for persisted state: database transactions, row locks, unique constraints, and idempotency records own correctness.

From the container

The filter has a public constructor taking IDistributedLock and DistributedLockFilterOptions<TContext>, so HostLoom.Pipelines.DependencyInjection resolves it per run:

services.AddSingleton(new DistributedLockFilterOptions<RefreshContext>
{
    KeySelector = context => $"refresh:{context.Region}",
    Lock = new LockOptions { Lease = TimeSpan.FromSeconds(30) },
});
services.AddPipeline<RefreshContext>("refresh", pipeline =>
    pipeline.Stage("run", stage =>
        stage.AddFilter<DistributedLockFilter<RefreshContext>>().AddFilter<RefreshFilter>()));

The filter describes itself to PipelineProbe.Inspect as a distributedLock scope with the lease, wait bound, retry policy, and lost-lease behaviour.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

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.17.0 0 10/25/2026
0.16.1 40 10/22/2026
0.16.0 91 10/14/2026
0.15.1 85 10/12/2026
0.15.0 97 10/4/2026
0.14.0 95 10/4/2026
0.13.0 95 9/28/2026
0.12.0 95 9/27/2026
0.11.0 98 9/25/2026
0.10.0 99 9/22/2026
0.9.0 100 9/22/2026
0.8.0 102 9/19/2026
0.7.0 102 9/17/2026
0.6.0 114 9/6/2026
0.5.0 120 9/5/2026
0.4.0 109 9/3/2026