RaftCs.Transport.NanoMsg 1.1.0

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

๐Ÿงญ raft-cs

CI NuGet GitHub Packages

A pure-managed, NativeAOT-ready implementation of the Raft consensus algorithm for modern .NET. No native dependency.

Raft is a customizable core consensus module โ€” modeled on tikv/raft-rs โ€” with bring-your-own log, state machine, and transport. The deterministic state machine (RaftCore) is wrapped by an asynchronous RaftNode that owns timers, transport, and storage, so you get a working replica out of the box and can swap any piece.

โœจ Why Raft

  • Complete consensus: leader election with pre-vote, log replication and commit, snapshots with log compaction, joint-consensus membership changes with learners, and leadership transfer.
  • Low-latency replication: optimistic pipelining, per-peer flow control (message- and byte-windowed), batched network sends, and asynchronous storage writes that let the leader replicate to followers in parallel with persisting to its own disk.
  • Robust under failure: optional check-quorum step-down when a leader loses contact with a majority, an uncommitted-log byte cap that protects against unbounded log growth when quorum is lost, and internal proposal forwarding from followers to the leader.
  • Observable: push streams for leadership/role changes and committed membership (plus poll properties), so applications react to elections and reconcile configuration against committed state without polling.
  • Replaceable everything: the IRaftStorage and IRaftTransport abstractions ship with an in-memory + file (WAL) store and an in-memory + NanoMsg (NNG/nanomsg) transport.
  • Fast: readonly struct/readonly ref struct building blocks, Span<byte>/BinaryPrimitives/stackalloc codecs, ArrayPool framing, an Inflights ring buffer, and no LINQ on hot paths.
  • NativeAOT & trimming clean on .NET 8/9/10 โ€” the library is annotated IsAotCompatible, and the test suite itself runs as a NativeAOT binary.
  • Broad reach: targets netstandard2.0, netstandard2.1, net8.0, net9.0, net10.0 (polyfilled on older runtimes).
  • Verified against raft-rs: a behavioral-parity harness drives both implementations through identical scenarios and compares the committed logs.

๐Ÿ“ฆ Install

dotnet add package RaftCs

Replaceable transport and storage ship as separate opt-in packages:

dotnet add package RaftCs.Transport            # IRaftTransport + in-memory transport
dotnet add package RaftCs.Transport.NanoMsg    # NNG/nanomsg (BUS) transport
dotnet add package RaftCs.Storage.File         # crash-safe file (WAL) IRaftStorage

All packages are strong-named โ€” every assembly is signed with one shared key, public-key token dfdc46ace5e226f1 โ€” so they can be referenced from strong-named (signed) assemblies. Strong naming here is an identity mechanism only, not a security guarantee.

๐Ÿš€ Quick start

using Raft;
using Raft.Configuration;
using Raft.Storage;
using Raft.Transport;

ulong[] cluster = { 1, 2, 3 };
await using var network = new InMemoryNetwork();

var node = new RaftNode(
    new RaftConfig { Id = 1, ElectionTick = 10, HeartbeatTick = 1, PreVote = true },
    new MemoryStorage(new ConfState(cluster)),
    network.CreateNode(1));

await node.StartAsync();
await node.ProposeAsync(System.Text.Encoding.UTF8.GetBytes("set x = 1"));

await foreach (var command in node.Committed.ReadAllAsync())
{
    Console.WriteLine(System.Text.Encoding.UTF8.GetString(command.Span));
}

See samples/Raft.Samples for a runnable three-node demo.

๐Ÿ› ๏ธ Build & test

dotnet build Raft.slnx -c Release
dotnet test Raft.slnx -c Release

๐Ÿ“š Documentation

๐Ÿงช Samples & Interop

  • In-memory cluster โ€” three nodes elect a leader and replicate commands over the in-memory transport; runs anywhere.
  • raft-rs behavioral parity โ€” a Rust harness wrapping tikv/raft-rs produces golden traces that the .NET implementation must reproduce.

๐Ÿ“„ License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.1.0 47 6/30/2026
1.0.0 47 6/30/2026