Rstmdb.Client
0.1.0
dotnet add package Rstmdb.Client --version 0.1.0
NuGet\Install-Package Rstmdb.Client -Version 0.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="Rstmdb.Client" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rstmdb.Client" Version="0.1.0" />
<PackageReference Include="Rstmdb.Client" />
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 Rstmdb.Client --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Rstmdb.Client, 0.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 Rstmdb.Client@0.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=Rstmdb.Client&version=0.1.0
#tool nuget:?package=Rstmdb.Client&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Rstmdb.Client
Official .NET client for rstmdb — the replicated state machine database.
Installation
dotnet add package Rstmdb.Client
Quick Start
using Rstmdb.Client;
// Connect
await using var client = await RstmdbClient.ConnectAsync("127.0.0.1", 7401);
// Define a state machine
await client.PutMachineAsync(new PutMachineRequest
{
Machine = "order",
Version = 1,
Definition = new MachineDefinition
{
States = new[] { "created", "paid", "shipped" },
Initial = "created",
Transitions = new[]
{
new Transition { From = new[] { "created" }, Event = "PAY", To = "paid" },
new Transition { From = new[] { "paid" }, Event = "SHIP", To = "shipped" },
},
},
});
// Create an instance
var inst = await client.CreateInstanceAsync(new CreateInstanceRequest
{
Machine = "order",
Version = 1,
});
// Transition state
var result = await client.ApplyEventAsync(new ApplyEventRequest
{
InstanceId = inst.InstanceId,
Event = "PAY",
});
Console.WriteLine($"{result.FromState} -> {result.ToState}"); // created -> paid
API Overview
Connection
// Plain TCP
await using var client = await RstmdbClient.ConnectAsync("host", 7401);
// With authentication
await using var client = await RstmdbClient.ConnectAsync("host", 7401,
new RstmdbOptions { Auth = "my-token" });
// With TLS
await using var client = await RstmdbClient.ConnectAsync("host", 7401,
new RstmdbOptions { Tls = RstmdbOptions.InsecureTls() });
Machines
await client.PutMachineAsync(request);
var machine = await client.GetMachineAsync("order", version: 1);
var machines = await client.ListMachinesAsync();
Instances
var created = await client.CreateInstanceAsync(request);
var instance = await client.GetInstanceAsync("instance-id");
var list = await client.ListInstancesAsync(new ListInstancesOptions { Machine = "order", Limit = 10 });
var deleted = await client.DeleteInstanceAsync("instance-id");
Events
var result = await client.ApplyEventAsync(new ApplyEventRequest
{
InstanceId = "instance-id",
Event = "PAY",
Payload = new Dictionary<string, object> { ["amount"] = 99.99 },
});
Batch Operations
var results = await client.BatchAsync(BatchMode.Atomic, new[]
{
BatchOperation.CreateInstance(new CreateInstanceRequest { Machine = "order", Version = 1 }),
BatchOperation.ApplyEvent(new ApplyEventRequest { InstanceId = "id", Event = "PAY" }),
});
Watch (Streaming)
// Watch a specific instance
await using var sub = await client.WatchInstanceAsync(new WatchInstanceRequest
{
InstanceId = "order-123",
IncludeCtx = true,
});
await foreach (var evt in sub.ReadAllAsync(cancellationToken))
{
Console.WriteLine($"{evt.FromState} -> {evt.ToState} via {evt.Event}");
}
// Watch all events
await using var sub = await client.WatchAllAsync(new WatchAllOptions
{
Machines = new[] { "order" },
IncludeCtx = true,
});
WAL Operations
var snapshot = await client.SnapshotInstanceAsync("instance-id");
var walData = await client.WalReadAsync(fromOffset: 0, limit: 100);
var stats = await client.WalStatsAsync();
var compact = await client.CompactAsync(forceSnapshot: true);
Error Handling
try
{
await client.GetInstanceAsync("nonexistent");
}
catch (RstmdbException ex) when (RstmdbException.IsInstanceNotFound(ex))
{
Console.WriteLine("Instance not found");
}
catch (RstmdbException ex) when (ex.IsRetryable)
{
// Safe to retry
}
Configuration
| Option | Default | Description |
|---|---|---|
Auth |
null |
Bearer token for authentication |
Tls |
null |
TLS options (null = plain TCP) |
ConnectTimeout |
10s |
TCP connection timeout |
RequestTimeout |
30s |
Per-request timeout |
ClientName |
null |
Client identifier sent in handshake |
WireMode |
"binary_json" |
Wire protocol mode |
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. 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 was computed. 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 was computed. 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.
-
net7.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.1.0 | 89 | 2/21/2026 |