arvo-event-handler
    Preparing search index...

    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

    Index

    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.

    defaultEventEmissionDomains: Required<
        NonNullable<
            ArvoResumableParam<TMemory, TSelfContract, TServiceContract>["defaultEventEmissionDomains"],
        >,
    >

    Optional domains for routing events

    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

    Accessors

    • get requiresResourceLocking(): boolean

      Whether this resumable requires resource locking for concurrent safety

      Returns boolean

    • get systemErrorSchema(): ArvoContractRecord<
          `sys.arvo.orc.${string}.error`,
          ZodObject<
              {
                  errorMessage: ZodString;
                  errorName: ZodString;
                  errorStack: ZodNullable<ZodString>;
              },
              "strip",
              ZodTypeAny,
              { errorMessage: string; errorName: string; errorStack: string
              | null },
              { errorMessage: string; errorName: string; errorStack: string | null },
          >,
      >

      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 ArvoContractRecord<
          `sys.arvo.orc.${string}.error`,
          ZodObject<
              {
                  errorMessage: ZodString;
                  errorName: ZodString;
                  errorStack: ZodNullable<ZodString>;
              },
              "strip",
              ZodTypeAny,
              { errorMessage: string; errorName: string; errorStack: string
              | null },
              { errorMessage: string; errorName: string; errorStack: string | null },
          >,
      >

    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

      Returns Promise<
          {
              events: ArvoEvent<
                  Record<string, any>,
                  Record<string, string | number | boolean | null>,
                  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
      • Optionalspan: Span

      Returns EventValidationResult