ghts.Saga.Compensator 1.0.6

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

SagaCompensator


What is SagaCompensator?

SagaCompensator is a lightweight .NET library that provides an in-memory orchestrator for managing compensating transactions in distributed workflows based on the Saga pattern.

When a saga step fails, all previously completed steps must be undone in reverse order. SagaCompensator handles this automatically using a LIFO (last-in, first-out) stack internally, ensuring that compensations are always executed in the correct order without any manual coordination.

It integrates natively with the .NET dependency injection system and supports structured logging through Microsoft.Extensions.Logging.


Key Concepts

Saga Pattern

A saga is a sequence of local transactions, each belonging to a different service or bounded context. If any step fails, the saga triggers compensating transactions for all previously succeeded steps to restore consistency.

Compensation

A compensation is the business-level "undo" operation for a completed step. It is not a technical database rollback — it is a new forward action that reverses the observable effect of a previous one (for example, cancelling a reservation that was already confirmed, or issuing a refund for a charge already processed).

Orchestrator

In an orchestrated saga, a central coordinator controls the flow: it calls each step in sequence and decides what to do on success or failure. SagaCompensator integrates into this coordinator layer, providing it with the tooling needed to register, track, and execute compensations cleanly.


How It Works

  1. Before executing the saga, you obtain an ISagaOrchestrator instance (via dependency injection or directly).
  2. As each step completes successfully, you register its corresponding compensation action using AddCompensation or automatically via ExecuteStepAsync.
  3. If any step fails, you call RollbackAsync() and the library executes all registered compensations in reverse order.
  4. If a compensation itself throws an error, it is logged and execution continues with the remaining compensations — ensuring the rollback process is always completed.
  5. RollbackAsync() is idempotent: calling it multiple times has no additional effect.

Installation

SagaCompensator is distributed as a NuGet package targeting .NET 10.0.

.NET CLI

dotnet add package SagaCompensator

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
1.0.6 112 4/27/2026