SquidStd.Workers
0.25.0
dotnet add package SquidStd.Workers --version 0.25.0
NuGet\Install-Package SquidStd.Workers -Version 0.25.0
<PackageReference Include="SquidStd.Workers" Version="0.25.0" />
<PackageVersion Include="SquidStd.Workers" Version="0.25.0" />
<PackageReference Include="SquidStd.Workers" />
paket add SquidStd.Workers --version 0.25.0
#r "nuget: SquidStd.Workers, 0.25.0"
#:package SquidStd.Workers@0.25.0
#addin nuget:?package=SquidStd.Workers&version=0.25.0
#tool nuget:?package=SquidStd.Workers&version=0.25.0
<h1 align="center">SquidStd.Workers</h1>
The SquidStd worker runtime. WorkerConsumerService consumes JobRequests from the jobs queue and
dispatches each to the IJobHandler registered for its job name (up to MaxConcurrency in parallel),
while WorkerHeartbeatService publishes a WorkerHeartbeat on the heartbeat topic every few seconds so
a manager can track the fleet. Use it to build worker microservices that pull jobs off a shared queue;
pair it with SquidStd.Workers.Manager on the producing side to enqueue jobs and watch heartbeats.
The runtime rides on SquidStd messaging, so a transport must be registered alongside it - in-memory for a single process, RabbitMQ for real multi-process deployments.
Install
dotnet add package SquidStd.Workers
Usage
Register a messaging transport, the worker runtime, and your handlers on the bootstrap container:
using SquidStd.Generators.Workers;
using SquidStd.Messaging.Extensions;
using SquidStd.Services.Core.Extensions;
using SquidStd.Services.Core.Services.Bootstrap;
using SquidStd.Workers.Extensions;
var bootstrap = SquidStdBootstrap.Create(o => o.ConfigName = "myworker");
bootstrap.ConfigureServices(c => c
.RegisterCoreServices()
.AddInMemoryMessaging() // or AddRabbitMqMessaging(...)
.AddWorkers()
.RegisterGeneratedJobHandlers()); // source-generated [RegisterJobHandler] registrations
await bootstrap.StartAsync();
A handler implements IJobHandler: it names the job it processes and does the work in HandleAsync,
reading string parameters off the JobRequest. [RegisterJobHandler] opts it into generated
registration (or register manually with AddJobHandler<T>()):
using SquidStd.Workers.Abstractions.Data;
using SquidStd.Workers.Attributes;
using SquidStd.Workers.Interfaces;
[RegisterJobHandler]
public sealed class ResizeImageHandler : IJobHandler
{
public string JobName => "resize-image";
public Task HandleAsync(JobRequest job, CancellationToken cancellationToken)
{
var width = job.Parameters["width"];
// ... do the work ...
return Task.CompletedTask;
}
}
On the producing side, SquidStd.Workers.Manager's IJobScheduler (registered with
AddWorkerManager()) publishes the JobRequest onto the same queue:
var scheduler = bootstrap.Resolve<IJobScheduler>();
await scheduler.EnqueueAsync("resize-image", new Dictionary<string, string> { ["width"] = "640" });
An unmatched job name raises JobHandlerNotFoundException in the dispatcher.
Configuration
AddWorkers() binds the workers section of the YAML config to WorkersConfig:
workers:
WorkerId: worker-1
HeartbeatIntervalSeconds: 10
MaxConcurrency: 4
JobQueue: squidstd.workers.jobs
HeartbeatTopic: squidstd.workers.heartbeat
| Property | Default | Notes |
|---|---|---|
WorkerId |
empty | Stable identity; blank falls back to the machine/container name. |
HeartbeatIntervalSeconds |
10 |
Seconds between heartbeats; non-positive falls back to 10. |
MaxConcurrency |
0 |
Parallel jobs; non-positive falls back to the processor count. |
JobQueue |
squidstd.workers.jobs |
Queue consumed for jobs (WorkerChannels.JobQueue). |
HeartbeatTopic |
squidstd.workers.heartbeat |
Topic heartbeats are published to (WorkerChannels.HeartbeatTopic). |
The channel defaults come from WorkerChannels in SquidStd.Workers.Abstractions, shared with the
manager so both sides agree out of the box.
Key types
| Type | Purpose |
|---|---|
IJobHandler |
Handles jobs of one named kind: JobName + HandleAsync(JobRequest, ct). |
IJobDispatcher |
Routes a JobRequest to the handler registered for its job name. |
RegisterJobHandlerAttribute |
Marks handlers for source-generated registration. |
WorkerConsumerService |
Lifecycle service that consumes the jobs queue and dispatches. |
WorkerHeartbeatService |
Lifecycle service that publishes periodic WorkerHeartbeats. |
WorkersConfig |
The workers config section (identity, heartbeat, concurrency, channels). |
WorkersRegistrationExtensions |
AddWorkers() and AddJobHandler<T>(). |
Related
- Tutorial: Build a worker system
- Article: SquidStd.Workers.Manager
- Article: SquidStd.Workers.Abstractions
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
- SquidStd.Messaging.Abstractions (>= 0.25.0)
- SquidStd.Workers.Abstractions (>= 0.25.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.25.0 | 0 | 7/6/2026 |
| 0.24.1 | 0 | 7/6/2026 |
| 0.24.0 | 0 | 7/6/2026 |
| 0.23.0 | 42 | 7/4/2026 |
| 0.22.0 | 44 | 7/4/2026 |
| 0.21.0 | 45 | 7/3/2026 |
| 0.20.0 | 41 | 7/3/2026 |
| 0.19.0 | 50 | 7/3/2026 |
| 0.18.0 | 42 | 7/3/2026 |
| 0.17.0 | 51 | 7/3/2026 |
| 0.16.0 | 50 | 7/3/2026 |
| 0.15.0 | 68 | 7/2/2026 |
| 0.14.1 | 75 | 7/2/2026 |
| 0.14.0 | 76 | 7/2/2026 |
| 0.13.0 | 73 | 7/2/2026 |
| 0.12.0 | 73 | 7/2/2026 |
| 0.11.0 | 75 | 7/2/2026 |
| 0.10.0 | 87 | 6/30/2026 |
| 0.9.0 | 108 | 6/29/2026 |
| 0.8.0 | 96 | 6/28/2026 |