DynaSharp.Coordination 0.10.0

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

DynaSharp.Coordination

Distributed coordination on DynamoDB for DynaSharp: a lease on a named lock with fencing tokens, and leader election on top of it. The semantics are those of the DynamoDB Lock Client: a relative lease duration, a record version number, and a wait on the monotonic clock of the contender, so the clocks of the machines may be set apart by any offset, as long as they run at about the same rate.

A lease

var locks = new LockTable(client.Table("Shop", "pk", "sk"));

await using var lease = await locks.AcquireAsync("nightly-report", TimeSpan.FromSeconds(30), ct);
await client.TransactWrite().IsHeld(lease).Put(orders, order).SendAsync(ct);

The lock is one item in a table you already have; LockTable.For(client.Table<Order>("Shop")) takes a typed table without restating its keys. A table of locks alone is LockTable.Open(client, "Locks"), whose CreateTable() creates it. AcquireAsync(name, lease, wait) gives up with a TimeoutException after the wait. The lease renews itself every third of its duration, lease.Ended is cancelled once it is no longer held, and disposing it releases the lock. IsHeld(lease) lets a transaction commit only while the lease holds the lock, and lease.FencingToken rises with every acquire, for a system outside DynamoDB that checks it.

Leader election

await locks.RunAsLeaderAsync("order-sweeper", TimeSpan.FromSeconds(30), async (lease, stop) =>
{
    while (true)
    {
        await client.TransactWrite().IsHeld(lease).Put(orders, order).SendAsync(stop);
        await Task.Delay(TimeSpan.FromMinutes(1), stop);
    }
}, ct);

One process at a time runs the work. When its lease is lost, the work is stopped and another process takes over. Code deep in the work fences its writes with IsHeld(), which checks Lease.Current, the lease of the term it runs in, without the lease passed down to it. The processes that wait read the lock item and do not write it while the leader renews, so they cause no failed conditional writes.

The guide is at msallin.github.io/DynaSharp/coordination.html: the item a lock writes, a holder label for operators, expiry of lock items, clocks and takeover, fencing, a BackgroundService that leads for as long as it runs, the spans, metrics and logs, and the helpers of DynaSharp.Coordination.Testing that let a test hold, release or delete a lock as another process would, read its state, and see a contender turned away.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
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.10.0 83 11/10/2026
0.9.0 99 11/8/2026
0.8.0 102 11/7/2026
0.7.0 92 11/7/2026
0.6.0 90 11/7/2026
0.5.0 97 11/6/2026
0.4.0 94 11/6/2026
0.3.0 90 11/5/2026
0.2.0 95 11/5/2026