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
| Property | Type | Description |
|---|---|---|
__adapter | PlatformAdapter | The platform adapter that created this bundle. |
transport | OpraSchema.Transport | undefined | The transport protocol ('http', 'socketio', etc.). |
platform | string | The platform name (e.g. 'express'). |
contexts | ExecutionContext[] | All execution contexts created within this bundle, one per sub-request. |
transaction | boolean | undefined | Whether the bundle was requested with transaction semantics. Set by the transport adapter from the incoming request. |
success | boolean | undefined | Set to true after the bundle completes if every context succeeded; false if any context failed. |
finished | boolean | undefined | Set to true once the bundle lifecycle is complete (whether successful or not). |
error | OpraException | undefined | Set 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:
| Event | Payload | Emitted when |
|---|---|---|
'before-execute' | bundle: ExecutionBundle | Before the first sub-request in the bundle begins processing. |
'after-execute' | bundle: ExecutionBundle | After the last sub-request completes successfully. |
'error' | error: OpraException, bundle: ExecutionBundle | A fatal bundle-level error occurred (not per-context errors). |
'finish' | bundle: ExecutionBundle | The 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}`);
});
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.
| Property | Type | Description |
|---|---|---|
__adapter | PlatformAdapter | The platform adapter. |
transport | OpraSchema.Transport | undefined | The transport protocol. |
platform | string | undefined | The platform name. |
Subclasses
| Class | Package | Description |
|---|---|---|
HttpBundle | @opra/http | Bundle for HTTP multipart/mixed batch requests. Adds request/response objects, decoded parameters, and a transaction flag. |