Class ArvoResumable<TMemory, TSelfContract, TServiceContract>

ArvoResumable complements ArvoOrchestrator by providing imperative handler functions for orchestration logic instead of declarative state machines. While ArvoOrchestrator excels at complex static workflows with deterministic branching, ArvoResumable handles dynamic orchestrations where branching logic depends on runtime context and event data.

Use this for dynamic orchestrations with context-dependent branching or when preferring imperative programming patterns over state machines.

Type Parameters

  • TMemory extends Record<string, any> = Record<string, any>
  • TSelfContract extends ArvoOrchestratorContract = ArvoOrchestratorContract
  • TServiceContract extends Record<string, VersionedArvoContract<any, any>> = Record<string, VersionedArvoContract<any, any>>

Implements

Constructors

Properties

contracts: {
    self: TSelfContract;
    services: TServiceContract;
}

Contract definitions for the resumable's event interface. Defines accepted events, emitted events, and service integrations.

Type declaration

  • self: TSelfContract

    Self contract defining initialization input and completion output structures.

  • services: TServiceContract

    Service contracts defining external service interfaces.

executionunits: number

Computational cost metric for workflow operations

Versioned handler map for processing workflow events.

source: string

Source identifier from the first registered machine

OpenTelemetry span configuration for observability

syncEventResource: SyncEventResource<ArvoResumableState<TMemory>>

Resource manager for state synchronization and memory access

systemErrorDomain?: (null | string)[] = undefined

Optional domains for routing system error events

Accessors

  • get requiresResourceLocking(): boolean
  • Whether this resumable requires resource locking for concurrent safety

    Returns boolean

  • get systemErrorSchema(): {
        domain: undefined | (null | string)[];
        schema: ZodObject<{
            errorMessage: ZodString;
            errorName: ZodString;
            errorStack: ZodNullable<ZodString>;
        }, "strip", ZodTypeAny, {
            errorMessage: string;
            errorName: string;
            errorStack: null | string;
        }, {
            errorMessage: string;
            errorName: string;
            errorStack: null | string;
        }>;
        type: `sys.arvo.orc.${string}.error`;
    }
  • Schema configuration for system error events.

    Defines the structure and routing for error events emitted when unexpected errors occur during event handling. System errors are sent to the workflow initiator to signal terminal failures that cannot be automatically recovered.

    Returns {
        domain: undefined | (null | string)[];
        schema: ZodObject<{
            errorMessage: ZodString;
            errorName: ZodString;
            errorStack: ZodNullable<ZodString>;
        }, "strip", ZodTypeAny, {
            errorMessage: string;
            errorName: string;
            errorStack: null | string;
        }, {
            errorMessage: string;
            errorName: string;
            errorStack: null | string;
        }>;
        type: `sys.arvo.orc.${string}.error`;
    }

    • domain: undefined | (null | string)[]
    • schema: ZodObject<{
          errorMessage: ZodString;
          errorName: ZodString;
          errorStack: ZodNullable<ZodString>;
      }, "strip", ZodTypeAny, {
          errorMessage: string;
          errorName: string;
          errorStack: null | string;
      }, {
          errorMessage: string;
          errorName: string;
          errorStack: null | string;
      }>

      The Zod schema used for validating data associated with this record

    • type: `sys.arvo.orc.${string}.error`

      The type identifier for this record

Methods

  • Executes the workflow handler for an incoming event.

    Processes initialization events or service responses through the versioned handler, manages state persistence, tracks expected events, and generates output events. Workflows in 'done' status ignore subsequent events without processing.

    For violation errors (transaction, config, contract), the error is thrown to enable retry mechanisms. For non-violation errors, system error events are emitted to the workflow initiator, and the workflow enters a terminal failure state.

    Parameters

    • event: ArvoEvent<Record<string, any>, Record<string,
          | null
          | string
          | number
          | boolean>, string>

      The incoming event triggering handler execution

    • Optionalopentelemetry: ArvoEventHandlerOpenTelemetryOptions

      Optional OpenTelemetry configuration for tracing

    Returns Promise<{
        events: ArvoEvent<Record<string, any>, Record<string,
            | null
            | string
            | number
            | boolean>, string>[];
    }>

    Object containing emitted events from the handler or system errors

    When distributed lock acquisition fails

    When handler resolution or contract validation fails

    When event schema validation fails

    When workflow execution encounters critical errors defined by the handler developer

  • Validates incoming event against self or service contracts.

    Resolves the appropriate contract (self for initialization, service for responses), validates schema compatibility, and ensures event data matches contract requirements.

    See validateInputEvent for more infromation

    Parameters

    • event: ArvoEvent<Record<string, any>, Record<string,
          | null
          | string
          | number
          | boolean>, string>
    • Optionalspan: Span

    Returns EventValidationResult