@hotmeshio/hotmesh
Version:
Serverless Workflow
23 lines (22 loc) • 945 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.didRun = void 0;
const common_1 = require("./common");
const context_1 = require("./context");
/**
* Determines if a replayed execution result already exists for the given prefix.
* @private
* @param {string} prefix - Identifier prefix (e.g., 'proxy', 'child', 'start', 'wait', etc.)
* @returns {Promise<[boolean, number, any]>} A tuple: [alreadyRan, executionIndex, restoredData]
*/
async function didRun(prefix) {
const { COUNTER, replay, workflowDimension } = (0, context_1.getContext)();
const execIndex = COUNTER.counter = COUNTER.counter + 1;
const sessionId = `-${prefix}${workflowDimension}-${execIndex}-`;
if (sessionId in replay) {
const restored = common_1.SerializerService.fromString(replay[sessionId]);
return [true, execIndex, restored];
}
return [false, execIndex, null];
}
exports.didRun = didRun;
;