Initializes a new ArvoEventHandler instance with the specified contract and configuration. Validates handler implementations against contract versions during initialization.
The constructor ensures that handler implementations exist for all supported contract versions and configures OpenTelemetry span attributes for monitoring event handling.
Handler configuration including contract, execution units, and handler implementations
Readonly
contractContract instance that defines the event schema and validation rules
Readonly
executionunitsComputational cost metric associated with event handling operations
Readonly
handlerVersion-specific event handler implementation map
Readonly
spanOpenTelemetry configuration for event handling spans
Optional
Readonly
systemThe contract-defined domain for this handler, used as the default domain for emitted events. Can be overridden by individual handler implementations for cross-domain workflows. Returns null if no domain is specified, indicating standard processing context.
Provides access to the system error event schema configuration.
The schema defines the structure of error events emitted during execution failures. These events are automatically generated when runtime errors occur and follow a standardized format for consistent error handling across the system.
Error events follow the naming convention: sys.<contract-type>.error
The error event schema containing type and validation rules
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.
The incoming event to process
Configuration for OpenTelemetry context inheritance, defaults to inheriting from the event
Promise resolving to a structured result containing an array of output events
ArvoEventHandler
is the foundational component for building stateless, contract-bound services in the Arvo system.It enforces strict contract validation, version-aware handler resolution, and safe, observable event emission — all while maintaining type safety, traceability, and support for multi-domain workflows.
What It Does
type
anddataschema
dataschema
domain[]
on the emitted eventssys.*.error
) on failureError Boundaries
ArvoEventHandler enforces a clear separation between:
Violations — structural, schema, or config errors that break the contract. These are thrown and must be handled explicitly by the caller.
System Errors — runtime exceptions during execution that are caught and emitted as standardized
sys.<contract>.error
events.Domain Broadcasting
The handler supports multi-domain event distribution. When the handler returns an event with a
domain
array, it is broadcast to one or more routing contexts.System Error Domain Control
By default, system error events are broadcast into the source event’s domain, the handler’s contract domain, and the
null
domain. This fallback ensures errors are visible across all relevant contexts. Developers can override this behavior using the optionalsystemErrorDomain
field to specify an explicit set of domain values, including symbolic constants from ArvoDomain.Supported Domain Values:
'audit.orders'
or'human.review'
null
to emit with no domain (standard internal flow)Domain Resolution Rules:
domain
array is resolved via resolveEventDomaindomain
is omitted entirely, Arvo defaults to[null]
Example:
This would emit at most 3 copies of the event, domained to:
'analytics'
Domain Usage Guidance
Contract-level domains enforce implicit routing for every emitted event in that handler, making the behavior harder to override and debug.
Prefer:
domain
values in handler outputnull
or symbolic constants to control domain cleanlyWhen to Use Domains
Use domains when handling for specialized contexts:
'human.review'
→ for human-in-the-loop steps'analytics.workflow'
→ to pipe events into observability systems'external.partner.sync'
→ to route to external services