Class AbstractArvoEventHandlerAbstract

Abstract base class for Arvo event handlers.

This class defines the basic structure for all Arvo event handlers. It provides an abstract method for executing events, which must be implemented by any concrete subclass.


Hierarchy (view full)

Constructors

Properties

Accessors

Methods

Constructors

Properties

source: string

Unique identifier for the event handler source system

Accessors

  • get systemErrorSchema(): ArvoContractRecord
  • Provides the schema for system error events.

    Returns ArvoContractRecord

    An object containing the error event type and schema.

    This getter should define the structure for system error events that may be emitted when an unexpected error occurs during event handling.

    • The returned ArvoContractRecord typically includes:
      • type: A string representing the error event type.
      • schema: The schema definition for the error event.
    • Implementations should ensure that the error schema is consistent with the overall system's error handling strategy.
    • The error event type often follows a pattern like 'sys.[eventType].error'.
    public get systemErrorSchema(): ArvoContractRecord {
    return {
    type: 'sys.myEvent.error',
    schema: MyCustomErrorSchema
    };
    }

Methods

  • Executes the event handling logic for a given Arvo event.

    Parameters

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

      The Arvo event to be processed. This event should conform to the expected schema for the specific handler implementation.

    • opentelemetry: ArvoEventHandlerOpenTelemetryOptions

      Configuration for OpenTelemetry integration

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

    A promise that resolves to an array of resulting Arvo events. These events represent the outcome of processing the input event.

    This method defines the core event processing logic that each concrete handler must implement. It should handle the complete lifecycle of an event, including:

    • Validation of the input event
    • Processing of the event according to business rules
    • Generation of any resulting events
    • Error handling and reporting
    • OpenTelemetry integration for observability
    • When the input event fails validation
    • When processing encounters an unrecoverable error
    • When the handler is unable to properly execute the event

    Implementation considerations:

    • Ensure proper error handling and event validation
    • Implement appropriate retry logic for transient failures
    • Use the provided OpenTelemetry configuration for tracing
    • Consider performance implications for long-running operations
    • Maintain idempotency where appropriate
    • Document any specific requirements for event schemas

    The method should handle observability concerns by:

    • Creating appropriate spans for tracing
    • Recording relevant attributes and events
    • Properly handling span lifecycle (creation and completion)
    • Propagating context appropriately