smart-saga-pattern
Version:
A library implementing the Saga pattern for microservice architecture
48 lines (47 loc) • 1.48 kB
TypeScript
import { SagaOptions, StateStore, SagaContext } from "../types";
/**
* Options for running a Saga
*/
export interface SagaRunOptions {
/**
* Whether to use structured context
* @default true
*/
useStructuredContext?: boolean;
/**
* Saga options
*/
sagaOptions?: SagaOptions;
/**
* State store for persistence
*/
stateStore?: StateStore<any>;
}
/**
* Runner for executing Sagas built from decorated classes
*/
export declare class SagaRunner {
/**
* Runs a Saga with all registered steps
* @param initialData Initial data for the Saga
* @param options Options for running the Saga
* @template T Type of the context
*/
static runAll<T = any>(initialData: any, options?: SagaRunOptions): Promise<SagaContext<T>>;
/**
* Runs a Saga with specific step classes
* @param stepClasses Step classes to include in the Saga
* @param initialData Initial data for the Saga
* @param options Options for running the Saga
* @template T Type of the context
*/
static run<T = any>(stepClasses: any[], initialData: any, options?: SagaRunOptions): Promise<SagaContext<T>>;
/**
* Creates and executes an orchestrator
* @param definition Saga definition
* @param initialData Initial data for the Saga
* @param options Options for running the Saga
* @template T Type of the context
*/
private static createAndExecuteOrchestrator;
}