Skip to main content

ExecutionBundle

ExecutionBundle is the base class for grouping multiple operation executions that share a single transport-level connection or batch request. The HTTP adapter creates an HttpBundle (which extends ExecutionBundle) when it receives a multipart/mixed batch request; each sub-request in the batch becomes an ExecutionContext inside the bundle.

Package: @opra/core
Extends: AsyncEventEmitter

import { ExecutionBundle } from '@opra/core';

Properties

PropertyTypeDescription
__adapterPlatformAdapterThe platform adapter that created this bundle.
transportOpraSchema.Transport | undefinedThe transport protocol ('http', 'socketio', etc.).
platformstringThe platform name (e.g. 'express').
contextsExecutionContext[]All execution contexts created within this bundle, one per sub-request.
transactionboolean | undefinedWhether the bundle was requested with transaction semantics. Set by the transport adapter from the incoming request.
successboolean | undefinedSet to true after the bundle completes if every context succeeded; false if any context failed.
finishedboolean | undefinedSet to true once the bundle lifecycle is complete (whether successful or not).
errorOpraException | undefinedSet to the first fatal error if bundle-level processing fails (not set for individual context errors).

Events

ExecutionBundle extends AsyncEventEmitter and emits the following events:

EventPayloadEmitted when
'before-execute'bundle: ExecutionBundleBefore the first sub-request in the bundle begins processing.
'after-execute'bundle: ExecutionBundleAfter the last sub-request completes successfully.
'error'error: OpraException, bundle: ExecutionBundleA fatal bundle-level error occurred (not per-context errors).
'finish'bundle: ExecutionBundleThe bundle lifecycle is complete regardless of success or failure. Always fires.
adapter.on('bundle-before-execute', bundle => {
console.log(`Bundle starting: ${bundle.contexts.length} requests`);
});

adapter.on('bundle-finish', bundle => {
console.log(`Bundle done. Success: ${bundle.success}`);
});
note

Bundle lifecycle events are also emitted on the adapter with a bundle- prefix — bundle-before-execute, bundle-after-execute, bundle-finish — making it possible to observe bundle lifecycles without attaching listeners to individual bundle instances. See HttpAdapter.Events.


ExecutionBundle.Initiator

Parameters passed to the ExecutionBundle constructor.

PropertyTypeDescription
__adapterPlatformAdapterThe platform adapter.
transportOpraSchema.Transport | undefinedThe transport protocol.
platformstring | undefinedThe platform name.

Subclasses

ClassPackageDescription
HttpBundle@opra/httpBundle for HTTP multipart/mixed batch requests. Adds request/response objects, decoded parameters, and a transaction flag.