arvo-event-handler
Version:
A complete set of orthogonal event handler and orchestration primitives for Arvo based applications, featuring declarative state machines (XState), imperative resumables for agentic workflows, contract-based routing, OpenTelemetry observability, and in-me
54 lines (53 loc) • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createArvoResumable = void 0;
var _1 = require(".");
var servicesValidation_1 = require("../ArvoOrchestrationUtils/servicesValidation");
/**
* Creates a new {@link ArvoResumable} orchestrator instance.
*
* Factory function that constructs a resumable workflow handler with automatic
* resource locking determination and contract validation. Validates that service
* contracts have unique URIs and no circular dependencies exist.
*
* @param param - Configuration parameters for the resumable
* @returns Configured ArvoResumable instance ready for event handling
*
* @throws {ConfigViolation} When service contracts have duplicate URIs
* @throws {ConfigViolation} When circular dependency detected (self contract registered as service)
*
* @example
* ```typescript
* const resumable = createArvoResumable({
* contracts: {
* self: myOrchestratorContract,
* services: {
* userService: userContract.version('1.0.0'),
* paymentService: paymentContract.version('1.0.0') }
* },
* memory: new SimpleMachineMemory(),
* handler: {
* '1.0.0': async ({ input, service, context }) => {
* // Handler implementation
* }
* },
* });
* ```
*
* @see {@link ArvoResumable} For the orchestrator class documentation
* @see {@link ArvoResumableHandler} For handler interface details
*/
var createArvoResumable = function (param) {
var _a, _b;
(0, servicesValidation_1.servicesValidation)(param.contracts, 'resumable');
return new _1.ArvoResumable({
contracts: param.contracts,
memory: param.memory,
handler: param.handler,
executionunits: (_a = param.executionunits) !== null && _a !== void 0 ? _a : 0,
requiresResourceLocking: (_b = param.requiresResourceLocking) !== null && _b !== void 0 ? _b : Object.keys(param.contracts.services).length > 1,
defaultEventEmissionDomains: param.defaultEventEmissionDomains,
spanOptions: param.spanOptions,
});
};
exports.createArvoResumable = createArvoResumable;