arvo-event-handler
Version:
A complete set of orthogonal event handler and orchestration primitives for Arvo based applications, featuring declarative state machines (XState), imperative resumables for agentic workflows, contract-based routing, OpenTelemetry observability, and in-me
52 lines (51 loc) • 1.77 kB
TypeScript
import type { IMachineMemory } from './interface';
/**
* A telemetred In-memory implementation of machine state storage for single-instance NodeJS apps.
*
* Best for: Container apps, request-scoped workflows, testing, demos
* Not for: Multi-instance deployments, persistent workflows, distributed systems
*
* @example
* const memory = new TelemetredSimpleMachineMemory();
* const orchestrator = createArvoOrchestrator({
* memory,
* executionunits: 0.1,
* machines: [workflow]
* });
*/
export declare class TelemetredSimpleMachineMemory<T extends Record<string, any> = Record<string, any>> implements IMachineMemory<T> {
private readonly memoryMap;
private readonly lockMap;
/**
* Gets stored state for a machine instance
* @param id Machine instance ID
* @returns State data or null if not found
* @throws {Error} When id is empty or undefined
*/
read(id: string): Promise<T | null>;
/**
* Stores state for a machine instance
* @param id Machine instance ID
* @param data State to store
* @throws {Error} When id is empty/undefined or data is null/undefined
*/
write(id: string, data: T): Promise<void>;
/**
* Attempts to acquire lock for machine instance
* @param id Machine instance ID
* @returns Success status of lock acquisition
* @throws {Error} When id is empty or undefined
*/
lock(id: string): Promise<boolean>;
/**
* Releases lock for machine instance
* @param id Machine instance ID
* @returns True when lock is released
* @throws {Error} When id is empty or undefined
*/
unlock(id: string): Promise<boolean>;
/**
* Clears all stored data and locks
*/
clear(key?: string): void;
}