Mekik.Redis
0.7.0
dotnet add package Mekik.Redis --version 0.7.0
NuGet\Install-Package Mekik.Redis -Version 0.7.0
<PackageReference Include="Mekik.Redis" Version="0.7.0" />
<PackageVersion Include="Mekik.Redis" Version="0.7.0" />
<PackageReference Include="Mekik.Redis" />
paket add Mekik.Redis --version 0.7.0
#r "nuget: Mekik.Redis, 0.7.0"
#:package Mekik.Redis@0.7.0
#addin nuget:?package=Mekik.Redis&version=0.7.0
#tool nuget:?package=Mekik.Redis&version=0.7.0
Mekik.Redis
Redis horizontal-scale backends for mekik —
the two ports a fleet needs, so a single-node app becomes N nodes behind a load
balancer with no engine changes. The .NET mirror of @mekik/redis; see
docs/SCALING.md
for the model.
RedisTurnLock— aSET NX PXsingle-writer lease per conversation, so only one node runs a turn at a time. The held lease heartbeats its own TTL, so a long streaming run never lets the lock lapse; a crashed owner's lock expires.RedisBackplane— Redis Pub/Sub cross-node fan-out, so every node holding a tab of a conversation re-fans each frame to its own sockets.
using Mekik;
using StackExchange.Redis;
var redis = await ConnectionMultiplexer.ConnectAsync(builder.Configuration["Redis"]!);
var app = new MekikApp(new MekikOptions
{
Graph = graph,
TurnLock = new RedisTurnLock(redis), // single-writer lease across nodes
Backplane = new RedisBackplane(redis), // cross-node fan-out
});
Pass nothing and mekik keeps its process-local defaults (LocalTurnLock,
NoopBackplane) — scaling is entirely opt-in, exactly like History and
Conversations.
Built on StackExchange.Redis:
share one IConnectionMultiplexer across both. The turn lock uses its database; the
backplane uses its subscriber (a multiplexer already manages the subscribe-mode
connection internally, so no second connection to wire up).
RedisTurnLock options
new RedisTurnLock(redis, new RedisTurnLockOptions
{
KeyPrefix = "mekik", // share one Redis across apps. Default "mekik".
Ttl = TimeSpan.FromSeconds(30), // lock TTL; must exceed a turn's worst case.
Heartbeat = TimeSpan.FromSeconds(10), // self-renew interval. Default Ttl / 3.
OnLost = convId => logger.LogWarning("turn lease lost {Conv}", convId),
});
The lease is token-checked: a node can only renew or release a lock it still
holds, so a slow node whose TTL lapsed can never free the new owner's lock. The
key is {KeyPrefix}:lock:{conversationId}. The lease releases on DisposeAsync
(the engine disposes it when the turn ends).
RedisBackplane options
new RedisBackplane(redis, new RedisBackplaneOptions { KeyPrefix = "mekik" });
The channel is {KeyPrefix}:bp:{conversationId}. The returned subscription
unsubscribes on DisposeAsync.
Routing
A fleet needs sticky-by-conversationId ingress so a conversation's connections
land on its owner node (the backplane is a fallback for the re-home window, not the
steady-state path). conversationId travels in the WebSocket query string so an
edge proxy can hash on it without parsing frames. See
docs/SCALING.md.
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 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. |
-
net9.0
- Mekik.Core (>= 0.7.0)
- StackExchange.Redis (>= 2.8.16)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.