Class ArvoEventHandler<TContract>

The foundational component for building stateless, contract-bound services in the Arvo system.

Type Parameters

  • TContract extends ArvoContract

Implements

Constructors

Properties

contract: TContract

Contract instance that defines the event schema and validation rules

executionunits: number

Computational cost metric associated with event handling operations

Version-specific event handler implementation map

OpenTelemetry configuration for event handling spans

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

Optional domains for routing system error events

Accessors

  • 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.${string}.error`;
    }
  • Provides access to the system error event schema configuration.

    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.${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.${string}.error`

      The type identifier for this record

Methods

  • Processes an incoming event according to the handler's contract specifications. This method handles the complete lifecycle of event processing including validation, execution, error handling, and multi-domain event broadcasting, while maintaining detailed telemetry through OpenTelemetry.

    Parameters

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

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

    when input or output event data violates the contract schema, or when event emission fails due to invalid data

    when event type doesn't match contract type, when the contract version expected by the event does not exist in handler configuration, or when contract URI mismatch occurs

    for explicitly handled runtime errors that should bubble up