SquidStd.Actors 0.28.0

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

<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: TellAsync awaits until capacity frees (back-pressure).
  • DropNewest: TellAsync returns false when full.
  • Isolate: a throwing handler is logged and skipped; the actor stays alive. AskAsync exceptions 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.

License

MIT - part of SquidStd.

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

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
Loading failed