@dbos-inc/dbos-sdk 3.0.27-preview → 3.0.29-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/datasource.d.ts +14 -3
- package/dist/src/datasource.d.ts.map +1 -1
- package/dist/src/datasource.js +5 -2
- package/dist/src/datasource.js.map +1 -1
- package/dist/src/dbos-executor.d.ts +28 -64
- package/dist/src/dbos-executor.d.ts.map +1 -1
- package/dist/src/dbos-executor.js +60 -243
- package/dist/src/dbos-executor.js.map +1 -1
- package/dist/src/dbos-runtime/runtime.d.ts.map +1 -1
- package/dist/src/dbos-runtime/runtime.js +0 -9
- package/dist/src/dbos-runtime/runtime.js.map +1 -1
- package/dist/src/dbos.d.ts +6 -22
- package/dist/src/dbos.d.ts.map +1 -1
- package/dist/src/dbos.js +6 -17
- package/dist/src/dbos.js.map +1 -1
- package/dist/src/decorators.d.ts +26 -53
- package/dist/src/decorators.d.ts.map +1 -1
- package/dist/src/decorators.js +150 -162
- package/dist/src/decorators.js.map +1 -1
- package/dist/src/httpServer/handler.js +1 -1
- package/dist/src/httpServer/handler.js.map +1 -1
- package/dist/src/httpServer/server.d.ts.map +1 -1
- package/dist/src/httpServer/server.js +4 -3
- package/dist/src/httpServer/server.js.map +1 -1
- package/dist/src/index.d.ts +2 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/scheduler/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler/scheduler.js +3 -2
- package/dist/src/scheduler/scheduler.js.map +1 -1
- package/dist/src/system_database.d.ts +5 -6
- package/dist/src/system_database.d.ts.map +1 -1
- package/dist/src/system_database.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/eventreceiver.d.ts +0 -152
- package/dist/src/eventreceiver.d.ts.map +0 -1
- package/dist/src/eventreceiver.js +0 -3
- package/dist/src/eventreceiver.js.map +0 -1
@@ -88,27 +88,6 @@ class DBOSExecutor {
|
|
88
88
|
procedurePool;
|
89
89
|
// Temporary workflows are created by calling transaction/send/recv directly from the executor class
|
90
90
|
static tempWorkflowName = 'temp_workflow';
|
91
|
-
workflowInfoMap = new Map([
|
92
|
-
// We initialize the map with an entry for temporary workflows.
|
93
|
-
[
|
94
|
-
DBOSExecutor.tempWorkflowName,
|
95
|
-
{
|
96
|
-
workflow: async () => {
|
97
|
-
this.logger.error('UNREACHABLE: Indirect invoke of temp workflow');
|
98
|
-
return Promise.resolve();
|
99
|
-
},
|
100
|
-
workflowOrigFunction: async () => {
|
101
|
-
this.logger.error('UNREACHABLE: Indirect invoke of temp workflow');
|
102
|
-
return Promise.resolve();
|
103
|
-
},
|
104
|
-
config: {},
|
105
|
-
},
|
106
|
-
],
|
107
|
-
]);
|
108
|
-
transactionInfoMap = new Map();
|
109
|
-
stepInfoMap = new Map();
|
110
|
-
procedureInfoMap = new Map();
|
111
|
-
registeredOperations = [];
|
112
91
|
telemetryCollector;
|
113
92
|
static defaultNotificationTimeoutSec = 60;
|
114
93
|
debugMode;
|
@@ -119,7 +98,6 @@ class DBOSExecutor {
|
|
119
98
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
120
99
|
typeormEntities = [];
|
121
100
|
drizzleEntities = {};
|
122
|
-
eventReceivers = [];
|
123
101
|
scheduler = undefined;
|
124
102
|
wfqEnded = undefined;
|
125
103
|
executorID = utils_1.globalParams.executorID;
|
@@ -233,39 +211,6 @@ class DBOSExecutor {
|
|
233
211
|
this.logger.debug('Loaded Postgres user database');
|
234
212
|
}
|
235
213
|
}
|
236
|
-
#registerClass(clsname) {
|
237
|
-
const registeredClassOperations = (0, decorators_1.getRegisteredOperationsByClassname)(clsname);
|
238
|
-
this.registeredOperations.push(...registeredClassOperations);
|
239
|
-
for (const ro of registeredClassOperations) {
|
240
|
-
if (ro.workflowConfig) {
|
241
|
-
this.#registerWorkflow(ro);
|
242
|
-
}
|
243
|
-
else if (ro.txnConfig) {
|
244
|
-
this.#registerTransaction(ro);
|
245
|
-
}
|
246
|
-
else if (ro.stepConfig) {
|
247
|
-
this.#registerStep(ro);
|
248
|
-
}
|
249
|
-
else if (ro.procConfig) {
|
250
|
-
this.#registerProcedure(ro);
|
251
|
-
}
|
252
|
-
for (const [evtRcvr, _cfg] of ro.eventReceiverInfo) {
|
253
|
-
if (!this.eventReceivers.includes(evtRcvr))
|
254
|
-
this.eventReceivers.push(evtRcvr);
|
255
|
-
}
|
256
|
-
}
|
257
|
-
}
|
258
|
-
getRegistrationsFor(obj) {
|
259
|
-
const res = [];
|
260
|
-
for (const r of this.registeredOperations) {
|
261
|
-
if (!r.eventReceiverInfo.has(obj))
|
262
|
-
continue;
|
263
|
-
const methodConfig = r.eventReceiverInfo.get(obj);
|
264
|
-
const classConfig = r.defaults?.eventReceiverInfo.get(obj) ?? {};
|
265
|
-
res.push({ methodReg: r, methodConfig, classConfig });
|
266
|
-
}
|
267
|
-
return res;
|
268
|
-
}
|
269
214
|
async init(classes) {
|
270
215
|
if (this.initialized) {
|
271
216
|
this.logger.error('Workflow executor already initialized!');
|
@@ -306,9 +251,6 @@ class DBOSExecutor {
|
|
306
251
|
this.logger.error('No user database configured!');
|
307
252
|
throw new error_1.DBOSInitializationError('No user database configured!');
|
308
253
|
}
|
309
|
-
for (const cls of classnames) {
|
310
|
-
this.#registerClass(cls);
|
311
|
-
}
|
312
254
|
// Debug mode doesn't need to initialize the DBs. Everything should appear to be read-only.
|
313
255
|
await this.userDatabase.init(this.debugMode);
|
314
256
|
if (!this.debugMode) {
|
@@ -342,7 +284,7 @@ class DBOSExecutor {
|
|
342
284
|
await cfg.initialize(new _1.InitContext());
|
343
285
|
}
|
344
286
|
}
|
345
|
-
for (const v of
|
287
|
+
for (const v of (0, decorators_1.getAllRegisteredFunctions)()) {
|
346
288
|
const m = v;
|
347
289
|
if (m.init === true) {
|
348
290
|
this.logger.debug('Executing init method: ' + m.name);
|
@@ -402,109 +344,11 @@ class DBOSExecutor {
|
|
402
344
|
throw err;
|
403
345
|
}
|
404
346
|
}
|
405
|
-
|
406
|
-
#
|
407
|
-
const
|
408
|
-
|
409
|
-
throw new error_1.DBOSError(`Unexpected use of reserved workflow name: ${wf.name}`);
|
410
|
-
}
|
411
|
-
const wfn = ro.className + '.' + ro.name;
|
412
|
-
if (this.workflowInfoMap.has(wfn)) {
|
413
|
-
throw new error_1.DBOSError(`Repeated workflow name: ${wfn}`);
|
414
|
-
}
|
415
|
-
const workflowInfo = {
|
416
|
-
workflow: wf,
|
417
|
-
workflowOrigFunction: ro.origFunction,
|
418
|
-
config: { ...ro.workflowConfig },
|
419
|
-
registration: ro,
|
420
|
-
};
|
421
|
-
this.workflowInfoMap.set(wfn, workflowInfo);
|
422
|
-
this.logger.debug(`Registered workflow ${wfn}`);
|
423
|
-
}
|
424
|
-
#registerTransaction(ro) {
|
425
|
-
const txf = ro.registeredFunction;
|
426
|
-
const tfn = ro.className + '.' + ro.name;
|
427
|
-
if (this.transactionInfoMap.has(tfn)) {
|
428
|
-
throw new error_1.DBOSError(`Repeated Transaction name: ${tfn}`);
|
429
|
-
}
|
430
|
-
const txnInfo = {
|
431
|
-
transaction: txf,
|
432
|
-
config: { ...ro.txnConfig },
|
433
|
-
registration: ro,
|
434
|
-
};
|
435
|
-
this.transactionInfoMap.set(tfn, txnInfo);
|
436
|
-
this.logger.debug(`Registered transaction ${tfn}`);
|
437
|
-
}
|
438
|
-
#registerStep(ro) {
|
439
|
-
const comm = ro.registeredFunction;
|
440
|
-
const cfn = ro.className + '.' + ro.name;
|
441
|
-
if (this.stepInfoMap.has(cfn)) {
|
442
|
-
throw new error_1.DBOSError(`Repeated Commmunicator name: ${cfn}`);
|
443
|
-
}
|
444
|
-
const stepInfo = {
|
445
|
-
step: comm,
|
446
|
-
config: { ...ro.stepConfig },
|
447
|
-
registration: ro,
|
448
|
-
};
|
449
|
-
this.stepInfoMap.set(cfn, stepInfo);
|
450
|
-
this.logger.debug(`Registered step ${cfn}`);
|
451
|
-
}
|
452
|
-
#registerProcedure(ro) {
|
453
|
-
const proc = ro.registeredFunction;
|
454
|
-
const cfn = ro.className + '.' + ro.name;
|
455
|
-
if (this.procedureInfoMap.has(cfn)) {
|
456
|
-
throw new error_1.DBOSError(`Repeated Procedure name: ${cfn}`);
|
457
|
-
}
|
458
|
-
const procInfo = {
|
459
|
-
procedure: proc,
|
460
|
-
config: { ...ro.procConfig },
|
461
|
-
registration: ro,
|
462
|
-
};
|
463
|
-
this.procedureInfoMap.set(cfn, procInfo);
|
464
|
-
this.logger.debug(`Registered stored proc ${cfn}`);
|
465
|
-
}
|
466
|
-
getWorkflowInfo(wf) {
|
467
|
-
const wfname = wf.name === DBOSExecutor.tempWorkflowName ? wf.name : (0, decorators_1.getRegisteredMethodClassName)(wf) + '.' + wf.name;
|
468
|
-
return this.workflowInfoMap.get(wfname);
|
469
|
-
}
|
470
|
-
getWorkflowInfoByStatus(wf) {
|
471
|
-
const wfname = wf.workflowClassName + '.' + wf.workflowName;
|
472
|
-
const wfInfo = this.workflowInfoMap.get(wfname);
|
473
|
-
// wfInfo may be undefined here, if this is a temp workflow
|
474
|
-
return { wfInfo, configuredInst: (0, decorators_1.getConfiguredInstance)(wf.workflowClassName, wf.workflowConfigName) };
|
475
|
-
}
|
476
|
-
getTransactionInfo(tf) {
|
477
|
-
const tfname = (0, decorators_1.getRegisteredMethodClassName)(tf) + '.' + tf.name;
|
478
|
-
return this.transactionInfoMap.get(tfname);
|
479
|
-
}
|
480
|
-
getTransactionInfoByNames(className, functionName, cfgName) {
|
481
|
-
const tfname = className + '.' + functionName;
|
482
|
-
const txnInfo = this.transactionInfoMap.get(tfname);
|
483
|
-
if (!txnInfo) {
|
484
|
-
throw new error_1.DBOSNotRegisteredError(tfname, `Transaction function name '${tfname}' is not registered.`);
|
485
|
-
}
|
486
|
-
return { txnInfo, clsInst: (0, decorators_1.getConfiguredInstance)(className, cfgName) };
|
487
|
-
}
|
488
|
-
getStepInfo(cf) {
|
489
|
-
const cfname = (0, decorators_1.getRegisteredMethodClassName)(cf) + '.' + cf.name;
|
490
|
-
return this.stepInfoMap.get(cfname);
|
491
|
-
}
|
492
|
-
getStepInfoByNames(className, functionName, cfgName) {
|
493
|
-
const cfname = className + '.' + functionName;
|
494
|
-
const stepInfo = this.stepInfoMap.get(cfname);
|
495
|
-
if (!stepInfo) {
|
496
|
-
throw new error_1.DBOSNotRegisteredError(cfname, `Step function name '${cfname}' is not registered.`);
|
497
|
-
}
|
498
|
-
return { commInfo: stepInfo, clsInst: (0, decorators_1.getConfiguredInstance)(className, cfgName) };
|
499
|
-
}
|
500
|
-
getProcedureClassName(pf) {
|
501
|
-
return (0, decorators_1.getRegisteredMethodClassName)(pf);
|
502
|
-
}
|
503
|
-
getProcedureInfo(pf) {
|
504
|
-
const pfName = (0, decorators_1.getRegisteredMethodClassName)(pf) + '.' + pf.name;
|
505
|
-
return this.procedureInfoMap.get(pfName);
|
347
|
+
// This could return WF, or the function underlying a temp wf
|
348
|
+
#getFunctionInfoFromWFStatus(wf) {
|
349
|
+
const methReg = (0, decorators_1.getFunctionRegistrationByName)(wf.workflowClassName, wf.workflowName);
|
350
|
+
return { methReg, configuredInst: (0, decorators_1.getConfiguredInstance)(wf.workflowClassName, wf.workflowConfigName) };
|
506
351
|
}
|
507
|
-
// TODO: getProcedureInfoByNames??
|
508
352
|
static reviveResultOrError(r, success) {
|
509
353
|
if (success === true || !r.error) {
|
510
354
|
return utils_1.DBOSJSON.parse(r.output ?? null);
|
@@ -541,18 +385,21 @@ class DBOSExecutor {
|
|
541
385
|
}
|
542
386
|
}
|
543
387
|
const pctx = (0, context_1.getCurrentContextStore)();
|
544
|
-
|
545
|
-
|
546
|
-
|
388
|
+
let wConfig = {};
|
389
|
+
const wInfo = (0, decorators_1.getFunctionRegistration)(wf);
|
390
|
+
if (wf.name !== DBOSExecutor.tempWorkflowName) {
|
391
|
+
if (!wInfo || !wInfo.workflowConfig) {
|
392
|
+
throw new error_1.DBOSNotRegisteredError(wf.name);
|
393
|
+
}
|
394
|
+
wConfig = wInfo.workflowConfig;
|
547
395
|
}
|
548
|
-
const wConfig = wInfo.config;
|
549
396
|
const maxRecoveryAttempts = wConfig.maxRecoveryAttempts ? wConfig.maxRecoveryAttempts : 50;
|
550
397
|
const wfname = wf.name; // TODO: Should be what was registered in wfInfo...
|
551
398
|
const span = this.tracer.startSpan(wfname, {
|
552
399
|
status: workflow_1.StatusString.PENDING,
|
553
400
|
operationUUID: workflowID,
|
554
401
|
operationType: exports.OperationType.WORKFLOW,
|
555
|
-
operationName: wInfo
|
402
|
+
operationName: wInfo?.name ?? wf.name,
|
556
403
|
authenticatedUser: pctx?.authenticatedUser ?? '',
|
557
404
|
authenticatedRoles: pctx?.authenticatedRoles ?? [],
|
558
405
|
assumedRole: pctx?.assumedRole ?? '',
|
@@ -561,8 +408,8 @@ class DBOSExecutor {
|
|
561
408
|
const internalStatus = {
|
562
409
|
workflowUUID: workflowID,
|
563
410
|
status: params.queueName !== undefined ? workflow_1.StatusString.ENQUEUED : workflow_1.StatusString.PENDING,
|
564
|
-
workflowName:
|
565
|
-
workflowClassName: isTempWorkflow ? '' : (0, decorators_1.
|
411
|
+
workflowName: (0, decorators_1.getRegisteredFunctionName)(wf),
|
412
|
+
workflowClassName: isTempWorkflow ? '' : (0, decorators_1.getRegisteredFunctionClassName)(wf),
|
566
413
|
workflowConfigName: params.configuredInstance?.name || '',
|
567
414
|
queueName: params.queueName,
|
568
415
|
output: null,
|
@@ -837,7 +684,7 @@ class DBOSExecutor {
|
|
837
684
|
}
|
838
685
|
return rows;
|
839
686
|
}
|
840
|
-
async
|
687
|
+
async runTransactionTempWF(txn, params, ...args) {
|
841
688
|
return await (await this.startTransactionTempWF(txn, params, undefined, undefined, ...args)).getResult();
|
842
689
|
}
|
843
690
|
async startTransactionTempWF(txn, params, callerWFID, callerFunctionID, ...args) {
|
@@ -848,13 +695,13 @@ class DBOSExecutor {
|
|
848
695
|
return await this.internalWorkflow(temp_workflow, {
|
849
696
|
...params,
|
850
697
|
tempWfType: exports.TempWorkflowType.transaction,
|
851
|
-
tempWfName: (0, decorators_1.
|
852
|
-
tempWfClass: (0, decorators_1.
|
698
|
+
tempWfName: (0, decorators_1.getRegisteredFunctionName)(txn),
|
699
|
+
tempWfClass: (0, decorators_1.getRegisteredFunctionClassName)(txn),
|
853
700
|
}, callerWFID, callerFunctionID, ...args);
|
854
701
|
}
|
855
702
|
async callTransactionFunction(txn, clsinst, ...args) {
|
856
|
-
const
|
857
|
-
if (
|
703
|
+
const txnReg = (0, decorators_1.getFunctionRegistration)(txn);
|
704
|
+
if (!txnReg || !txnReg.txnConfig) {
|
858
705
|
throw new error_1.DBOSNotRegisteredError(txn.name);
|
859
706
|
}
|
860
707
|
const pctx = (0, context_1.getCurrentContextStore)();
|
@@ -871,7 +718,7 @@ class DBOSExecutor {
|
|
871
718
|
authenticatedUser: pctx.authenticatedUser ?? '',
|
872
719
|
assumedRole: pctx.assumedRole ?? '',
|
873
720
|
authenticatedRoles: pctx.authenticatedRoles ?? [],
|
874
|
-
isolationLevel:
|
721
|
+
isolationLevel: txnReg.txnConfig.isolationLevel,
|
875
722
|
}, pctx.span);
|
876
723
|
while (true) {
|
877
724
|
await this.systemDatabase.checkIfCanceled(wfid);
|
@@ -959,7 +806,7 @@ class DBOSExecutor {
|
|
959
806
|
return result;
|
960
807
|
};
|
961
808
|
try {
|
962
|
-
const result = await this.userDatabase.transaction(wrappedTransaction,
|
809
|
+
const result = await this.userDatabase.transaction(wrappedTransaction, txnReg.txnConfig);
|
963
810
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
964
811
|
this.tracer.endSpan(span);
|
965
812
|
return result;
|
@@ -989,7 +836,7 @@ class DBOSExecutor {
|
|
989
836
|
}
|
990
837
|
}
|
991
838
|
}
|
992
|
-
async
|
839
|
+
async runProcedureTempWF(proc, params, ...args) {
|
993
840
|
// Create a workflow and call procedure.
|
994
841
|
const temp_workflow = async (...args) => {
|
995
842
|
return this.callProcedureFunction(proc, ...args);
|
@@ -997,19 +844,20 @@ class DBOSExecutor {
|
|
997
844
|
return await (await this.workflow(temp_workflow, {
|
998
845
|
...params,
|
999
846
|
tempWfType: exports.TempWorkflowType.procedure,
|
1000
|
-
tempWfName: (0, decorators_1.
|
1001
|
-
tempWfClass: (0, decorators_1.
|
847
|
+
tempWfName: (0, decorators_1.getRegisteredFunctionName)(proc),
|
848
|
+
tempWfClass: (0, decorators_1.getRegisteredFunctionClassName)(proc),
|
1002
849
|
}, ...args)).getResult();
|
1003
850
|
}
|
1004
851
|
async callProcedureFunction(proc, ...args) {
|
1005
|
-
const procInfo =
|
1006
|
-
if (procInfo
|
852
|
+
const procInfo = (0, decorators_1.getFunctionRegistration)(proc);
|
853
|
+
if (!procInfo || !procInfo.procConfig) {
|
1007
854
|
throw new error_1.DBOSNotRegisteredError(proc.name);
|
1008
855
|
}
|
856
|
+
const procConfig = procInfo.procConfig;
|
1009
857
|
const pctx = (0, context_1.getCurrentContextStore)();
|
1010
858
|
const wfid = pctx.workflowId;
|
1011
859
|
await this.systemDatabase.checkIfCanceled(wfid);
|
1012
|
-
const executeLocally = this.debugMode || (
|
860
|
+
const executeLocally = this.debugMode || (procConfig.executeLocally ?? false);
|
1013
861
|
const funcId = (0, context_1.functionIDGetIncrement)();
|
1014
862
|
const span = this.tracer.startSpan(proc.name, {
|
1015
863
|
operationUUID: wfid,
|
@@ -1018,13 +866,13 @@ class DBOSExecutor {
|
|
1018
866
|
authenticatedUser: pctx.authenticatedUser ?? '',
|
1019
867
|
assumedRole: pctx.assumedRole ?? '',
|
1020
868
|
authenticatedRoles: pctx.authenticatedRoles ?? [],
|
1021
|
-
isolationLevel: procInfo.
|
869
|
+
isolationLevel: procInfo.procConfig.isolationLevel,
|
1022
870
|
executeLocally,
|
1023
871
|
}, pctx.span);
|
1024
872
|
try {
|
1025
873
|
const result = executeLocally
|
1026
874
|
? await this.#callProcedureFunctionLocal(proc, args, span, procInfo, funcId)
|
1027
|
-
: await this.#callProcedureFunctionRemote(proc, args, span,
|
875
|
+
: await this.#callProcedureFunctionRemote(proc, args, span, procConfig, funcId);
|
1028
876
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
1029
877
|
return result;
|
1030
878
|
}
|
@@ -1120,7 +968,7 @@ class DBOSExecutor {
|
|
1120
968
|
};
|
1121
969
|
try {
|
1122
970
|
const result = await this.invokeStoredProcFunction(wrappedProcedure, {
|
1123
|
-
isolationLevel: procInfo.
|
971
|
+
isolationLevel: procInfo.procConfig.isolationLevel,
|
1124
972
|
});
|
1125
973
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
1126
974
|
return result;
|
@@ -1188,8 +1036,8 @@ class DBOSExecutor {
|
|
1188
1036
|
async #invokeStoredProc(proc, args) {
|
1189
1037
|
const client = await this.procedurePool.connect();
|
1190
1038
|
const log = (msg) => this.#logNotice(msg);
|
1191
|
-
const
|
1192
|
-
const plainProcName = `${
|
1039
|
+
const procname = (0, decorators_1.getRegisteredFunctionFullName)(proc);
|
1040
|
+
const plainProcName = `${procname.className}_${procname.name}_p`;
|
1193
1041
|
const procName = utils_1.globalParams.wasComputed ? plainProcName : `v${utils_1.globalParams.appVersion}_${plainProcName}`;
|
1194
1042
|
const sql = `CALL "${procName}"(${args.map((_v, i) => `$${i + 1}`).join()});`;
|
1195
1043
|
try {
|
@@ -1222,7 +1070,7 @@ class DBOSExecutor {
|
|
1222
1070
|
client.release();
|
1223
1071
|
}
|
1224
1072
|
}
|
1225
|
-
async
|
1073
|
+
async runStepTempWF(stepFn, params, ...args) {
|
1226
1074
|
return await (await this.startStepTempWF(stepFn, params, undefined, undefined, ...args)).getResult();
|
1227
1075
|
}
|
1228
1076
|
async startStepTempWF(stepFn, params, callerWFID, callerFunctionID, ...args) {
|
@@ -1233,8 +1081,8 @@ class DBOSExecutor {
|
|
1233
1081
|
return await this.internalWorkflow(temp_workflow, {
|
1234
1082
|
...params,
|
1235
1083
|
tempWfType: exports.TempWorkflowType.step,
|
1236
|
-
tempWfName: (0, decorators_1.
|
1237
|
-
tempWfClass: (0, decorators_1.
|
1084
|
+
tempWfName: (0, decorators_1.getRegisteredFunctionName)(stepFn),
|
1085
|
+
tempWfClass: (0, decorators_1.getRegisteredFunctionClassName)(stepFn),
|
1238
1086
|
}, callerWFID, callerFunctionID, ...args);
|
1239
1087
|
}
|
1240
1088
|
/**
|
@@ -1245,8 +1093,8 @@ class DBOSExecutor {
|
|
1245
1093
|
async callStepFunction(stepFn, stepFnName, stepConfig, clsInst, ...args) {
|
1246
1094
|
stepFnName = stepFnName ?? stepFn.name ?? '<unnamed>';
|
1247
1095
|
if (!stepConfig) {
|
1248
|
-
const stepReg =
|
1249
|
-
stepConfig = stepReg?.
|
1096
|
+
const stepReg = (0, decorators_1.getFunctionRegistration)(stepFn);
|
1097
|
+
stepConfig = stepReg?.stepConfig;
|
1250
1098
|
}
|
1251
1099
|
if (stepConfig === undefined) {
|
1252
1100
|
throw new error_1.DBOSNotRegisteredError(stepFnName);
|
@@ -1354,7 +1202,7 @@ class DBOSExecutor {
|
|
1354
1202
|
return result;
|
1355
1203
|
}
|
1356
1204
|
}
|
1357
|
-
async
|
1205
|
+
async runSendTempWF(destinationId, message, topic, idempotencyKey) {
|
1358
1206
|
// Create a workflow and call send.
|
1359
1207
|
const temp_workflow = async (destinationId, message, topic) => {
|
1360
1208
|
const ctx = (0, context_1.getCurrentContextStore)();
|
@@ -1434,26 +1282,6 @@ class DBOSExecutor {
|
|
1434
1282
|
return await this.userDatabase.query(sql);
|
1435
1283
|
}
|
1436
1284
|
}
|
1437
|
-
async userDBListen(channels, callback) {
|
1438
|
-
const notificationsClient = await this.procedurePool.connect();
|
1439
|
-
for (const nname of channels) {
|
1440
|
-
await notificationsClient.query(`LISTEN ${nname};`);
|
1441
|
-
}
|
1442
|
-
notificationsClient.on('notification', callback);
|
1443
|
-
return {
|
1444
|
-
close: async () => {
|
1445
|
-
for (const nname of channels) {
|
1446
|
-
try {
|
1447
|
-
await notificationsClient.query(`UNLISTEN ${nname};`);
|
1448
|
-
}
|
1449
|
-
catch (e) {
|
1450
|
-
this.logger.warn(e);
|
1451
|
-
}
|
1452
|
-
notificationsClient.release();
|
1453
|
-
}
|
1454
|
-
},
|
1455
|
-
};
|
1456
|
-
}
|
1457
1285
|
/* INTERNAL HELPERS */
|
1458
1286
|
/**
|
1459
1287
|
* A recovery process that by default runs during executor init time.
|
@@ -1501,9 +1329,6 @@ class DBOSExecutor {
|
|
1501
1329
|
this.scheduler = new scheduler_1.DBOSScheduler(this);
|
1502
1330
|
this.scheduler.initScheduler();
|
1503
1331
|
this.wfqEnded = wfqueue_1.wfQueueRunner.dispatchLoop(this);
|
1504
|
-
for (const evtRcvr of this.eventReceivers) {
|
1505
|
-
await evtRcvr.initialize(this);
|
1506
|
-
}
|
1507
1332
|
for (const lcl of (0, decorators_1.getLifecycleListeners)()) {
|
1508
1333
|
await lcl.initialize?.();
|
1509
1334
|
}
|
@@ -1519,16 +1344,7 @@ class DBOSExecutor {
|
|
1519
1344
|
this.logger.warn(`Error destroying lifecycle listener: ${e.message}`);
|
1520
1345
|
}
|
1521
1346
|
}
|
1522
|
-
this.logger.debug('Deactivating
|
1523
|
-
for (const evtRcvr of this.eventReceivers || []) {
|
1524
|
-
try {
|
1525
|
-
await evtRcvr.destroy();
|
1526
|
-
}
|
1527
|
-
catch (err) {
|
1528
|
-
const e = err;
|
1529
|
-
this.logger.warn(`Error destroying event receiver: ${e.message}`);
|
1530
|
-
}
|
1531
|
-
}
|
1347
|
+
this.logger.debug('Deactivating scheduler');
|
1532
1348
|
try {
|
1533
1349
|
await this.scheduler?.destroyScheduler();
|
1534
1350
|
}
|
@@ -1536,6 +1352,7 @@ class DBOSExecutor {
|
|
1536
1352
|
const e = err;
|
1537
1353
|
this.logger.warn(`Error destroying scheduler: ${e.message}`);
|
1538
1354
|
}
|
1355
|
+
this.logger.debug('Deactivating queue runner');
|
1539
1356
|
if (stopQueueThread) {
|
1540
1357
|
try {
|
1541
1358
|
wfqueue_1.wfQueueRunner.stop();
|
@@ -1559,12 +1376,12 @@ class DBOSExecutor {
|
|
1559
1376
|
}
|
1560
1377
|
const inputs = utils_1.DBOSJSON.parse(wfStatus.input);
|
1561
1378
|
const recoverCtx = this.#getRecoveryContext(workflowID, wfStatus);
|
1562
|
-
const {
|
1379
|
+
const { methReg, configuredInst } = this.#getFunctionInfoFromWFStatus(wfStatus);
|
1563
1380
|
// If starting a new workflow, assign a new UUID. Otherwise, use the workflow's original UUID.
|
1564
1381
|
const workflowStartID = startNewWorkflow ? undefined : workflowID;
|
1565
|
-
if (
|
1382
|
+
if (methReg?.workflowConfig) {
|
1566
1383
|
return await (0, context_1.runWithTopContext)(recoverCtx, async () => {
|
1567
|
-
return await this.workflow(
|
1384
|
+
return await this.workflow(methReg.registeredFunction, {
|
1568
1385
|
workflowUUID: workflowStartID,
|
1569
1386
|
configuredInstance: configuredInst,
|
1570
1387
|
queueName: wfStatus.queueName,
|
@@ -1577,34 +1394,33 @@ class DBOSExecutor {
|
|
1577
1394
|
const wfName = wfStatus.workflowName;
|
1578
1395
|
const nameArr = wfName.split('-');
|
1579
1396
|
if (!nameArr[0].startsWith(DBOSExecutor.tempWorkflowName)) {
|
1580
|
-
|
1581
|
-
throw new error_1.DBOSError(`This should never happen! Cannot find workflow info for a non-temporary workflow! UUID ${workflowID}, name ${wfName}`);
|
1397
|
+
throw new error_1.DBOSError(`Cannot find workflow function for a non-temporary workflow, ID ${workflowID}, class '${wfStatus.workflowClassName}', function '${wfName}'; did you change your code?`);
|
1582
1398
|
}
|
1583
1399
|
if (nameArr[1] === exports.TempWorkflowType.transaction) {
|
1584
|
-
const
|
1585
|
-
if (!
|
1586
|
-
this.logger.error(`Cannot find transaction info for
|
1400
|
+
const txnReg = (0, decorators_1.getFunctionRegistrationByName)(wfStatus.workflowClassName, nameArr[2]);
|
1401
|
+
if (!txnReg?.txnConfig) {
|
1402
|
+
this.logger.error(`Cannot find transaction info for ID ${workflowID}, name ${nameArr[2]}`);
|
1587
1403
|
throw new error_1.DBOSNotRegisteredError(nameArr[2]);
|
1588
1404
|
}
|
1589
1405
|
return await (0, context_1.runWithTopContext)(recoverCtx, async () => {
|
1590
|
-
return await this.startTransactionTempWF(
|
1406
|
+
return await this.startTransactionTempWF(txnReg.registeredFunction, {
|
1591
1407
|
workflowUUID: workflowStartID,
|
1592
|
-
configuredInstance:
|
1408
|
+
configuredInstance: configuredInst,
|
1593
1409
|
queueName: wfStatus.queueName,
|
1594
1410
|
executeWorkflow: true,
|
1595
1411
|
}, undefined, undefined, ...inputs);
|
1596
1412
|
});
|
1597
1413
|
}
|
1598
1414
|
else if (nameArr[1] === exports.TempWorkflowType.step) {
|
1599
|
-
const
|
1600
|
-
if (!
|
1601
|
-
this.logger.error(`Cannot find step info for
|
1415
|
+
const stepReg = (0, decorators_1.getFunctionRegistrationByName)(wfStatus.workflowClassName, nameArr[2]);
|
1416
|
+
if (!stepReg?.stepConfig) {
|
1417
|
+
this.logger.error(`Cannot find step info for ID ${workflowID}, name ${nameArr[2]}`);
|
1602
1418
|
throw new error_1.DBOSNotRegisteredError(nameArr[2]);
|
1603
1419
|
}
|
1604
1420
|
return await (0, context_1.runWithTopContext)(recoverCtx, async () => {
|
1605
|
-
return await this.startStepTempWF(
|
1421
|
+
return await this.startStepTempWF(stepReg.registeredFunction, {
|
1606
1422
|
workflowUUID: workflowStartID,
|
1607
|
-
configuredInstance:
|
1423
|
+
configuredInstance: configuredInst,
|
1608
1424
|
queueName: wfStatus.queueName, // Probably null
|
1609
1425
|
executeWorkflow: true,
|
1610
1426
|
}, undefined, undefined, ...inputs);
|
@@ -1667,7 +1483,7 @@ class DBOSExecutor {
|
|
1667
1483
|
}
|
1668
1484
|
logRegisteredHTTPUrls() {
|
1669
1485
|
this.logger.info('HTTP endpoints supported:');
|
1670
|
-
|
1486
|
+
(0, decorators_1.getAllRegisteredFunctions)().forEach((registeredOperation) => {
|
1671
1487
|
const ro = registeredOperation;
|
1672
1488
|
if (ro.apiURL) {
|
1673
1489
|
this.logger.info(' ' + ro.apiType.padEnd(6) + ' : ' + ro.apiURL);
|
@@ -1695,8 +1511,9 @@ class DBOSExecutor {
|
|
1695
1511
|
*/
|
1696
1512
|
computeAppVersion() {
|
1697
1513
|
const hasher = crypto.createHash('md5');
|
1698
|
-
const sortedWorkflowSource = Array.from(
|
1699
|
-
.
|
1514
|
+
const sortedWorkflowSource = Array.from((0, decorators_1.getAllRegisteredFunctions)())
|
1515
|
+
.filter((e) => e.workflowConfig)
|
1516
|
+
.map((i) => i.origFunction.toString())
|
1700
1517
|
.sort();
|
1701
1518
|
// Different DBOS versions should produce different hashes.
|
1702
1519
|
sortedWorkflowSource.push(utils_1.globalParams.dbosVersion);
|