AxisSaga 2.2.0
dotnet add package AxisSaga --version 2.2.0
NuGet\Install-Package AxisSaga -Version 2.2.0
<PackageReference Include="AxisSaga" Version="2.2.0" />
<PackageVersion Include="AxisSaga" Version="2.2.0" />
<PackageReference Include="AxisSaga" />
paket add AxisSaga --version 2.2.0
#r "nuget: AxisSaga, 2.2.0"
#:package AxisSaga@2.2.0
#addin nuget:?package=AxisSaga&version=2.2.0
#tool nuget:?package=AxisSaga&version=2.2.0
AxisSaga — Documentation
Orchestration of long-running, multi-step processes with compensations — declarative saga definitions (forward stages, error stages, success routing, route-to compensation), per-stage handlers returning AxisResult<TPayload>, a bundled storage adapter (Postgres, MySQL, …) over a shared core that persists every instance, every stage log and the definition catalogue, and a built-in poll-based resumer that recovers stuck sagas after a process restart.
public static class OrderSagaDefinition
{
public static void Configure(IAxisSagaConfigurator<OrderPayload> saga)
{
saga.AddStage("ReserveStock")
.NextStageOnSuccess("ChargeCard")
.RouteToOnError("CompensateOrder");
saga.AddStage("ChargeCard")
.FinishOnSuccess()
.RouteToOnError("RefundStock", "CompensateOrder");
saga.AddErrorStage("RefundStock") /* … */;
saga.AddErrorStage("CompensateOrder") /* … */;
}
}
Use this page as a map: read the trunk below (~5 min) and jump straight to the detail of the group you need — without reading hundreds of lines.
The trunk (read first)
What a saga is
A saga is a long-running process composed of stages that run in order. Each stage runs an IAxisSagaStageHandler<TPayload> that returns AxisResult<TPayload> — success advances to the next stage; failure routes to one or more error stages (the classic compensation pattern). If a stage needs to notify the rest of the system, its own handler publishes the event on the IAxisBus, on the same unit of work that persists the stage's state change — the saga runtime itself does not publish anything.
The five participating types
| Type | What it is |
|---|---|
IAxisSagaStageHandler<TPayload> |
a per-stage handler that runs one step and returns AxisResult<TPayload> |
IAxisSagaConfigurator<TPayload> |
the fluent builder that declares the stages and routes |
AxisSagaDefinition |
the immutable, validated definition that the registry exposes at runtime |
IAxisSagaMediator |
start a saga, fetch its state, or ask for it to resume |
IAxisSagaResumer |
a poll-based recovery worker that looks for stuck sagas and re-fires the engine |
→ Concepts · stages and routes · IAxisSagaConfigurator<TPayload> — the fluent builder · Writing a stage handler · Driving a saga — IAxisSagaMediator · Resuming · IAxisSagaResumer
Storage adapters — Postgres, MySQL, …
The schema is declared once, dialect-agnostically, in the core (AxisSagaSchema) and rendered per dialect: a single schema (AXIS_SAGA) with four tables — saga_definitions, saga_instances, saga_stage_logs and saga_settings — plus a MIGRATIONS control table created by the framework migration runner. The core supplies the SagaEngine that drives one instance forward (load → resolve stage → invoke handler → write log → route), the SagaMediator that inserts a new instance and fires the engine in the background, and the built-in resumer. The bundled storage adapters share that core — currently AxisSaga.Postgres (AddAxisSagaPostgres), AxisSaga.MySql (AddAxisSagaMySql), and more can follow — each supplying only its data source, store implementations and migration runner.
→ Postgres adapter · MySQL adapter · Database schema
Installation
dotnet add package AxisSaga # contracts + configurator
dotnet add package AxisSaga.Postgres # the Postgres storage adapter (or AxisSaga.MySql)
AxisSaga depends on AxisResult, AxisLogger, AxisMediator.Contracts. AxisSaga.Postgres adds Npgsql.
→ Full guide: Getting started
The map (jump to what you need)
| Group | You want to… | Detail |
|---|---|---|
| Concepts · stages and routes | understand the moving parts | concepts.md |
Configurator · IAxisSagaConfigurator<TPayload> ⭐ |
declare a saga end-to-end | configuration.md |
| Stage handlers | write a handler that runs one stage | stage-handlers.md |
Mediator · IAxisSagaMediator |
start a saga, read its state, resume it | mediator.md |
Resumer · IAxisSagaResumer |
recover stuck instances after a restart | resumer.md |
| Postgres adapter | the storage + engine | postgres-adapter.md |
| MySQL adapter | the storage + engine | mysql-adapter.md |
| Database schema | what the adapter creates | database-schema.md |
| Why? | the case for the abstraction | why-axissaga.md |
| Reference | every member at a glance | api-reference.md |
Start here: Getting started · Concepts · Why AxisSaga?
Fundamentals: Configurator · Stage handlers · Mediator · Resumer
Reference & extras: Postgres adapter · MySQL adapter · Database schema · API reference
Design principles
- Sagas are declarative. Stages, next-on-success and route-to-on-error are data (
AxisSagaDefinition), not handler-level conditionals. - Compensation is first-class. A failed forward stage routes to a sequence of error stages — there is no "throw an exception and hope for the best".
- Every step is logged. Each stage's start / completion / failure is a row in
axis_saga.saga_stage_logs. Forensics are a SQL query. - The engine resumes itself. The core ships a built-in resumer (an auto-hosted worker) that finds stuck instances and re-triggers the engine — process restart is not a saga restart.
- One storage per process.
AddAxisSagaPostgresrefuses a second registration on purpose: every saga across every BC shares theAXIS_SAGAschema.
License
Apache 2.0
| 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
- AxisLogger (>= 2.2.0)
- AxisMediator.Contracts (>= 2.2.0)
- AxisRepository (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.10)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on AxisSaga:
| Package | Downloads |
|---|---|
|
AxisSaga.MySql
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
|
|
AxisSaga.Postgres
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.