smart-saga-pattern
Version:
A library implementing the Saga pattern for microservice architecture
27 lines (26 loc) • 712 B
TypeScript
import { SagaDefinition } from "./SagaDefinition";
import { SagaContext } from "../types";
/**
* Executes a Saga definition
* @template T Type of the input data
* @template R Type of the result data
*/
export declare class SagaExecutor<T = any, R = any> {
private definition;
private context;
private currentStepIndex;
/**
* Creates a new SagaExecutor
* @param definition Saga definition to execute
* @param context Initial Saga context
*/
constructor(definition: SagaDefinition<T>, context: SagaContext<T & R>);
/**
* Executes the Saga
*/
execute(): Promise<SagaContext<T & R>>;
/**
* Compensates the Saga
*/
private compensate;
}