smart-saga-pattern
Version:
A library implementing the Saga pattern for microservice architecture
47 lines (46 loc) • 1.51 kB
TypeScript
import { SagaContext, StateStore } from "../types";
/**
* In-memory implementation of StateStore
* @template T Type of the data in the context
*/
export declare class InMemoryStateStore<T = Record<string, any>> implements StateStore<T> {
private store;
/**
* Saves a Saga context
* @param sagaId ID of the Saga
* @param context Saga context to save
*/
save(sagaId: string, context: SagaContext<T>): Promise<void>;
/**
* Loads a Saga context
* @param sagaId ID of the Saga
*/
load(sagaId: string): Promise<SagaContext<T> | null>;
/**
* Updates a Saga context
* @param sagaId ID of the Saga
* @param context Partial Saga context to update
*/
update(sagaId: string, context: Partial<SagaContext<T>>): Promise<void>;
/**
* Deletes a Saga context
* @param sagaId ID of the Saga
*/
delete(sagaId: string): Promise<void>;
}
/**
* Factory for creating StateStore instances
*/
export declare class StateStoreFactory {
/**
* Creates an in-memory StateStore
* @template T Type of the data in the context
*/
static createInMemoryStore<T = Record<string, any>>(): StateStore<T>;
/**
* Creates a file system StateStore
* @param options Options for the file system store
* @template T Type of the data in the context
*/
static createFileSystemStore<T = Record<string, any>>(options: import("./FileSystemStateStore").FileSystemStateStoreOptions): StateStore<T>;
}