smart-saga-pattern
Version:
A library implementing the Saga pattern for microservice architecture
29 lines (28 loc) • 1.04 kB
TypeScript
import { Saga } from "../core/Saga";
import { SagaDefinition } from "./SagaDefinition";
import { SagaContext, SagaOptions, StateStore } from "../types";
/**
* Orchestrator for executing Sagas
* @template T Type of the data in the context
* @template R Type of the result data from transactions
*/
export declare class SagaOrchestrator<T = Record<string, any>, R = Record<string, any>> extends Saga<T & R> {
private definition;
private stateStore?;
/**
* Creates a new SagaOrchestrator
* @param definition Saga definition to orchestrate
* @param options Saga options
* @param stateStore Optional state store for persistence
*/
constructor(definition: SagaDefinition<T>, options?: SagaOptions, stateStore?: StateStore<T & R>);
/**
* Executes the Saga
* @param initialData Initial data for the Saga
*/
execute(initialData?: Partial<T>): Promise<SagaContext<T & R>>;
/**
* Compensates the Saga (rolls back)
*/
compensate(): Promise<SagaContext<T & R>>;
}