UNPKG

@hotmeshio/hotmesh

Version:

Serverless Workflow

25 lines (24 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.interrupt = void 0; const common_1 = require("./common"); const context_1 = require("./context"); const isSideEffectAllowed_1 = require("./isSideEffectAllowed"); /** * Interrupts a running job by sending an interruption request. * * @param {string} jobId - The ID of the job to interrupt. * @param {JobInterruptOptions} options - Additional interruption options. * @returns {Promise<string|void>} Result of the interruption, if any. */ async function interrupt(jobId, options = {}) { const { workflowTopic, connection, namespace } = (0, context_1.getContext)(); const hotMeshClient = await common_1.WorkerService.getHotMesh(workflowTopic, { connection, namespace, }); if (await (0, isSideEffectAllowed_1.isSideEffectAllowed)(hotMeshClient, 'interrupt')) { return await hotMeshClient.interrupt(`${hotMeshClient.appId}.execute`, jobId, options); } } exports.interrupt = interrupt;