DotnetTemporalPgWorkerV8 1.0.1
dotnet new install DotnetTemporalPgWorkerV8::1.0.1
Temporal Worker Template
A .NET 8 background service template for building Temporal workflow services. Demonstrates a laundry order lifecycle — from order receipt through washing, drying, ironing, packaging, and delivery — using signal-driven workflows backed by PostgreSQL.
Install the template
dotnet new install DotnetTemporalPgWorkerV8
Use the template
dotnet new dotnet-temporal-pg-worker-v8 -n MyWorkerService
cd MyWorkerService
dotnet run
The sourceName Temporal.Worker is replaced throughout — namespaces, project file, and folder names — with whatever name you pass to -n.
Publish a new version
# From repo root
dotnet pack Temporal.Worker.csproj -c Release -o ./nupkg
dotnet nuget push ./nupkg/DotnetTemporalPgWorkerV8.<version>.nupkg \
--api-key <YOUR_NUGET_API_KEY> \
--source https://api.nuget.org/v3/index.json
Test locally before publishing
dotnet pack Temporal.Worker.csproj -c Release -o ./nupkg
dotnet new install ./nupkg/DotnetTemporalPgWorkerV8.<version>.nupkg
dotnet new dotnet-temporal-pg-worker-v8 -n TestWorker
To uninstall the local version:
dotnet new uninstall DotnetTemporalPgWorkerV8
Stack
| Layer | Technology |
|---|---|
| Runtime | .NET 8 Worker Service |
| Workflow engine | Temporalio v1.11.1 via NetTemporal.Client.Core |
| Database | PostgreSQL via EFRadix.Core.Postgres |
| Integration tests | Python + temporalio |
Prerequisites
- .NET 8 SDK
- PostgreSQL (local or Docker)
- Temporal server running at
localhost:7233
Quick start — Temporal server via Docker
docker run -d --name temporal \
-p 7233:7233 \
temporalio/auto-setup:latest
Quick start — PostgreSQL via Docker
docker run -d --name postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
postgres:16
Configuration
Edit Temporal.Worker/appsettings.json:
{
"TemporalConfig": {
"Namespace": "default",
"ServerAddress": "localhost:7233",
"ApiKey": null
},
"ConnectionStrings": {
"DbConnection": "Host=localhost;Port=5432;Database=TemporalWorkerTemplate;Username=postgres;Password=postgres"
}
}
Running the worker
cd Temporal.Worker.Template/Temporal.Worker
dotnet run
Migrations are applied automatically on startup via the EFRadix RunWorkerMigrationsAsync extension.
Workflow overview
Task queue
order-workflow-queue
Lifecycle
[start] ──► WaitFor(OrderReceived)
│
▼
Order Created
│
┌─────────▼──────────┐
│ WaitFor next │◄── AdvanceOrderStatus signals
│ AdvanceOrderStatus │ are enqueued and processed
└─────────┬──────────┘ one at a time
│
Washing → Air Drying → Ironing → Packaging
│
┌────────┴────────┐
Delivered Cancelled
[workflow ends] [workflow ends]
Signals
| Signal | Payload | Description |
|---|---|---|
OrderReceived |
StartOrderWorkflowRequest |
Initialises workflow state and starts the lifecycle |
AdvanceOrderStatus |
AdvanceOrderStatusRequest |
Enqueues a status transition to be processed |
Query
| Query | Returns |
|---|---|
GetState |
OrderWorkflowState (orderRequest, order, statusHistory, message) |
Signal payloads
// OrderReceived
{
"OrderId": "order-123",
"OrderNumber": "ORD-001",
"CustomerId": "cust-abc"
}
// AdvanceOrderStatus
{
"NewStatus": "Washing",
"Notes": null
}
Order statuses
Order Created → Washing → Air Drying → Ironing → Packaging → Delivered / Cancelled
Project structure
Temporal.Worker/
├── Activities/
│ ├── Interfaces/ # IOrderActivities
│ └── Providers/ # OrderActivities (DB writes)
├── Constants/ # OrderStatus, TaskQueueNames, SignalNames, WorkflowNames
├── DTOs/OrderDtos/ # StartOrderWorkflowRequest, AdvanceOrderStatusRequest
├── Entities/ # Order, OrderAnnotation, OrderEvent
├── Workflows/ # OrderWorkflow, OrderWorkflowState
├── _tests/ # Python integration tests
├── Worker.cs # BackgroundService — registers and runs the Temporal worker
├── WorkerDbContext.cs # EFRadix DbContext
└── Program.cs # DI registration
Integration tests (Python)
Tests connect to a live Temporal server and require the .NET worker to be running.
cd Temporal.Worker/_tests
pip install temporalio pytest pytest-asyncio
pytest test_order_workflow.py -v
EF Core migrations
Migrations are auto-applied on startup. To add a new migration:
cd Temporal.Worker.Template/Temporal.Worker
dotnet ef migrations add <MigrationName>
This package has 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.