UNPKG

arvo-xstate

Version:

This package allows you to use xstate Actors and State Machines to act as orchestrators in an Arvo Event Driven System

53 lines (52 loc) 1.83 kB
import type { MachineMemoryRecord } from '../ArvoOrchestrator/types'; 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 SimpleMachineMemory(); * const orchestrator = createArvoOrchestrator({ * memory, * executionunits: 0.1, * machines: [workflow] * }); */ export declare class TelemetredSimpleMachineMemory implements IMachineMemory<MachineMemoryRecord> { 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<MachineMemoryRecord | 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: MachineMemoryRecord): 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; }