Type Alias ArvoResumableHandler<TState, TSelfContract, TServiceContract>

ArvoResumableHandler<TState, TSelfContract, TServiceContract>: {
    [V in ArvoSemanticVersion & keyof TSelfContract["versions"]]: Handler<TState, VersionedArvoContract<TSelfContract, V>, TServiceContract>
}

The versioned orchestration handlers in ArvoResumable workflows

It maps each version of an orchestrator contract to its corresponding handler function. Each handler receives workflow context (state, events, contracts) and returns execution results that can update state, complete the workflow, or invoke external services.

The handler is called for each event that matches the orchestrator's contract, whether it's an initialization event or a service response. The handler must be deterministic and idempotent to ensure reliable workflow execution across potential retries.

Type Parameters

  • TState extends ArvoResumableState<Record<string, any>>
  • TSelfContract extends ArvoContract
  • TServiceContract extends Record<string, VersionedArvoContract<any, any>>

Handler execution context

OpenTelemetry span for distributed tracing

Type-safe map of event types to their corresponding typed event arrays, enabling strongly-typed access with full IntelliSense support.

Current workflow state (null for new workflows)

Initialization event data (only present for workflow start events)

Service response event data (only present for service callbacks)

Available contracts for type validation and event creation

The orchestrator's own versioned contract

External service contracts for invocation

Promise resolving to execution result or void

result.context - Updated workflow state to persist

result.complete - Workflow completion event to emit (ends the workflow)

result.services - Array of service invocation events to emit

  • Each version key must match a valid semantic version in the self contract
  • Handlers should be pure functions without side effects beyond the returned actions
  • State updates are atomic - either all changes persist or none do
  • Only one of init or service will be non-null for any given invocation
  • Returning void or an empty object indicates no state changes or events to emit
  • Service events are supposed to queued for execution and may trigger callback events
  • Completion events terminate the workflow and route to the parent orchestrator