SquidStd.Actors
0.28.0
dotnet add package SquidStd.Actors --version 0.28.0
NuGet\Install-Package SquidStd.Actors -Version 0.28.0
<PackageReference Include="SquidStd.Actors" Version="0.28.0" />
<PackageVersion Include="SquidStd.Actors" Version="0.28.0" />
<PackageReference Include="SquidStd.Actors" />
paket add SquidStd.Actors --version 0.28.0
#r "nuget: SquidStd.Actors, 0.28.0"
#:package SquidStd.Actors@0.28.0
#addin nuget:?package=SquidStd.Actors&version=0.28.0
#tool nuget:?package=SquidStd.Actors&version=0.28.0
<h1 align="center">SquidStd.Actors</h1>
Ordered, single-threaded, lock-free per-entity message processing for SquidStd, built on TPL Dataflow
ActionBlock<T>. Each actor owns a mailbox processed by one consumer, so handler state is mutated
without locks. Complements the EventBus (stateless broadcast) and CommandDispatcher (stateless fan-out)
with ordered, stateful, per-instance processing.
Install
dotnet add package SquidStd.Actors
Usage
using SquidStd.Actors;
public interface ISessionMessage { }
public sealed record LineReceived(string Raw) : ISessionMessage;
public sealed record SendText(string Text) : ISessionMessage;
public sealed record GetNick : ActorRequest<string?>, ISessionMessage; // request/response
public sealed class SessionActor : Actor<ISessionMessage>
{
private readonly INetworkConnection _conn;
private string? _nick;
public SessionActor(INetworkConnection conn) { _conn = conn; }
protected override async ValueTask ReceiveAsync(ISessionMessage message, CancellationToken ct)
{
switch (message)
{
case LineReceived(var raw): if (raw.StartsWith("NICK ")) _nick = raw[5..]; break;
case SendText(var text): await _conn.WriteAsync(text, ct); break;
case GetNick q: q.Reply(_nick); break;
}
}
}
await using var session = new SessionActor(conn);
await session.TellAsync(new LineReceived("NICK alice")); // fire-and-forget
string? nick = await session.AskAsync<GetNick, string?>(new GetNick()); // request/response
Use the event bus as an ordered source:
using SquidStd.Actors.Extensions;
using var sub = session.SubscribeToEventBus(eventBus, (UserJoinedEvent e) => new SendText($":{e.Nick} JOIN"));
Key types
| Type | Purpose |
|---|---|
Actor<TMessage> |
Mailbox base class (TellAsync / AskAsync). |
ActorRequest<TReply> |
Base record for request/response messages. |
IActorRequest<TReply> |
Request contract (implement directly if not using the base). |
ActorOptions |
Capacity / overflow / error configuration. |
Options
ActorOptions controls the mailbox:
| Property | Values | Default |
|---|---|---|
Capacity |
bounded mailbox size | 1024 |
OverflowPolicy |
Wait / DropNewest / Unbounded |
Wait |
ErrorPolicy |
Isolate / StopOnError |
Isolate |
ShutdownDrainTimeout |
any TimeSpan |
5s |
- Wait:
TellAsyncawaits until capacity frees (back-pressure). - DropNewest:
TellAsyncreturnsfalsewhen full. - Isolate: a throwing handler is logged and skipped; the actor stays alive.
AskAsyncexceptions always propagate to the caller regardless of policy.
DisposeAsync completes the mailbox and drains queued messages - every Tell runs and every Ask
replies - within ShutdownDrainTimeout. If a handler is still running when that budget elapses, the
actor cancels its handlers and faults any requests that never completed with ObjectDisposedException.
Related
- Tutorial: Actors
- Concept: Messaging models
License
MIT - part of SquidStd.
| Product | Versions 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. |
-
net10.0
- Serilog (>= 4.3.1)
- SquidStd.Core (>= 0.28.0)
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.28.0 | 46 | 7/8/2026 |
| 0.27.0 | 69 | 7/7/2026 |
| 0.26.0 | 70 | 7/7/2026 |
| 0.25.0 | 92 | 7/6/2026 |
| 0.24.1 | 92 | 7/6/2026 |
| 0.24.0 | 89 | 7/6/2026 |
| 0.23.0 | 90 | 7/4/2026 |
| 0.22.0 | 88 | 7/4/2026 |
| 0.21.0 | 92 | 7/3/2026 |
| 0.20.0 | 87 | 7/3/2026 |
| 0.19.0 | 92 | 7/3/2026 |
| 0.18.0 | 90 | 7/3/2026 |
| 0.17.0 | 96 | 7/3/2026 |
| 0.16.0 | 97 | 7/3/2026 |
| 0.15.0 | 93 | 7/2/2026 |
| 0.14.1 | 108 | 7/2/2026 |
| 0.14.0 | 89 | 7/2/2026 |
| 0.13.0 | 95 | 7/2/2026 |
| 0.12.0 | 91 | 7/2/2026 |
| 0.11.0 | 92 | 7/2/2026 |