Verbara.Sdk.Cluster.Primitives 2.2.1

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

Verbara.Sdk.Cluster.Primitives

MIT-licensed abstractions for distributed cluster transport, membership, and locking. Part of the Verbara.Sdk open-core family.

What it does

Exposes three orthogonal primitives that production-grade cluster implementations (Pro, custom backends, partner integrations) implement:

Primitive Role
IClusterTransport Publishes/subscribes to ClusterEvent messages across instances (pub/sub).
IDistributedLock Owner-scoped cluster-wide locks with automatic expiry.
IMembershipProvider Tracks node registrations, lifecycle state, and instance heartbeats.

Reference in-memory implementations (InMemoryClusterTransport, InMemoryDistributedLock, InMemoryMembershipProvider) ship in the package for tests and single-instance deployments.

Why it exists

Cluster primitives are infrastructure without domain logic: circuit breakers, retries, and membership protocols are already commoditized across JVM (Resilience4j, Hystrix), Go (failsafe-go, hashicorp/raft), and .NET (Polly, Orleans). Keeping them in the MIT base of the SDK — analogous to Verbara.Sdk.Resilience — allows open-source consumers to build their own cluster implementations against a stable contract, and keeps commercial extensions focused on domain logic (e.g. Asterisk PBX-specific session recovery, AMI/ARI routing, skill-based assignment).

Install

dotnet add package Verbara.Sdk.Cluster.Primitives

Quick start

using Verbara.Sdk.Cluster.Primitives;
using Verbara.Sdk.Cluster.Primitives.InMemory;

// Publish/subscribe
await using var transport = new InMemoryClusterTransport();
_ = Task.Run(async () =>
{
    await foreach (var evt in transport.SubscribeAsync())
    {
        Console.WriteLine($"Got {evt.GetType().Name} from {evt.SourceInstanceId}");
    }
});

await transport.PublishAsync(new NodeJoined("instance-A", DateTimeOffset.UtcNow, "node-1"));

// Locks
var locks = new InMemoryDistributedLock();
if (await locks.TryAcquireAsync("resource-x", owner: "instance-A", expiry: TimeSpan.FromSeconds(30)))
{
    try { /* critical section */ }
    finally { await locks.ReleaseAsync("resource-x", "instance-A"); }
}

// Membership
var members = new InMemoryMembershipProvider();
await members.RegisterNodeAsync(new NodeInfo("node-1", NodeState.Healthy) { OwnerInstanceId = "instance-A" });
await members.HeartbeatAsync("instance-A", TimeSpan.FromSeconds(10));

public sealed record NodeJoined(string SourceInstanceId, DateTimeOffset Timestamp, string NodeId)
    : ClusterEvent(SourceInstanceId, Timestamp);

Tracing

ClusterEvent carries an optional TraceContext property (W3C traceparent) for cross-node distributed tracing. Publishers inject the ambient Activity.Current traceparent; subscribers extract it to continue the trace. Null when no trace listener is active — zero wire overhead.

AOT

All types are trimming/AOT-safe. No reflection, no dynamic code generation, no runtime codegen. Pair with [JsonSerializable] source generation for event payload serialization across production transports (Redis, Postgres, NATS).

License

MIT. See repository root.

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 (1)

Showing the top 1 NuGet packages that depend on Verbara.Sdk.Cluster.Primitives:

Package Downloads
Verbara.Sdk.Cluster.Postgres

Verbara.Sdk.Cluster.Postgres - Postgres-backed IDistributedLock implementation for cluster-wide mutual exclusion. AOT-safe (raw Npgsql via Verbara.Sdk.Data.Npgsql facade, no reflection). Ships idempotent migration for the cluster_distributed_lock table.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.1 207 5/23/2026
2.2.0 116 5/20/2026
2.1.2 106 5/8/2026
2.1.1 93 5/7/2026
2.1.0 87 5/7/2026
2.0.0 91 5/6/2026