@dbos-inc/dbos-sdk 0.7.25-preview → 0.8.12-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/cloud-cli/applications/configure.d.ts.map +1 -1
- package/dist/src/cloud-cli/applications/configure.js +12 -2
- package/dist/src/cloud-cli/applications/configure.js.map +1 -1
- package/dist/src/cloud-cli/applications/delete-app.js +1 -1
- package/dist/src/cloud-cli/applications/delete-app.js.map +1 -1
- package/dist/src/cloud-cli/applications/deploy-app-code.d.ts.map +1 -1
- package/dist/src/cloud-cli/applications/deploy-app-code.js +10 -2
- package/dist/src/cloud-cli/applications/deploy-app-code.js.map +1 -1
- package/dist/src/cloud-cli/applications/get-app-logs.js +1 -1
- package/dist/src/cloud-cli/applications/get-app-logs.js.map +1 -1
- package/dist/src/cloud-cli/applications/list-apps.js +1 -1
- package/dist/src/cloud-cli/applications/list-apps.js.map +1 -1
- package/dist/src/cloud-cli/applications/register-app.js +1 -1
- package/dist/src/cloud-cli/applications/register-app.js.map +1 -1
- package/dist/src/cloud-cli/applications/update-app.d.ts.map +1 -1
- package/dist/src/cloud-cli/applications/update-app.js +3 -2
- package/dist/src/cloud-cli/applications/update-app.js.map +1 -1
- package/dist/src/cloud-cli/cli.js +19 -7
- package/dist/src/cloud-cli/cli.js.map +1 -1
- package/dist/src/cloud-cli/login.d.ts.map +1 -1
- package/dist/src/cloud-cli/login.js +3 -2
- package/dist/src/cloud-cli/login.js.map +1 -1
- package/dist/src/cloud-cli/register.js +1 -1
- package/dist/src/cloud-cli/register.js.map +1 -1
- package/dist/src/cloud-cli/userdb.d.ts +2 -0
- package/dist/src/cloud-cli/userdb.d.ts.map +1 -1
- package/dist/src/cloud-cli/userdb.js +102 -8
- package/dist/src/cloud-cli/userdb.js.map +1 -1
- package/dist/src/communicator.d.ts +3 -2
- package/dist/src/communicator.d.ts.map +1 -1
- package/dist/src/communicator.js.map +1 -1
- package/dist/src/context.d.ts +3 -3
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +8 -8
- package/dist/src/context.js.map +1 -1
- package/dist/src/dbos-executor.d.ts +19 -7
- package/dist/src/dbos-executor.d.ts.map +1 -1
- package/dist/src/dbos-executor.js +186 -67
- package/dist/src/dbos-executor.js.map +1 -1
- package/dist/src/dbos-runtime/cli.d.ts +0 -1
- package/dist/src/dbos-runtime/cli.d.ts.map +1 -1
- package/dist/src/dbos-runtime/cli.js +14 -2
- package/dist/src/dbos-runtime/cli.js.map +1 -1
- package/dist/src/dbos-runtime/config.d.ts +3 -0
- package/dist/src/dbos-runtime/config.d.ts.map +1 -1
- package/dist/src/dbos-runtime/config.js +0 -1
- package/dist/src/dbos-runtime/config.js.map +1 -1
- package/dist/src/dbos-runtime/debug.d.ts +4 -0
- package/dist/src/dbos-runtime/debug.d.ts.map +1 -0
- package/dist/src/dbos-runtime/debug.js +23 -0
- package/dist/src/dbos-runtime/debug.js.map +1 -0
- package/dist/src/dbos-runtime/runtime.d.ts +2 -2
- package/dist/src/dbos-runtime/runtime.d.ts.map +1 -1
- package/dist/src/dbos-runtime/runtime.js +20 -21
- package/dist/src/dbos-runtime/runtime.js.map +1 -1
- package/dist/src/debugger/debug_workflow.d.ts +8 -8
- package/dist/src/debugger/debug_workflow.d.ts.map +1 -1
- package/dist/src/debugger/debug_workflow.js +107 -36
- package/dist/src/debugger/debug_workflow.js.map +1 -1
- package/dist/src/httpServer/handler.d.ts +1 -1
- package/dist/src/httpServer/handler.d.ts.map +1 -1
- package/dist/src/httpServer/handler.js +14 -14
- package/dist/src/httpServer/handler.js.map +1 -1
- package/dist/src/httpServer/server.d.ts +4 -4
- package/dist/src/httpServer/server.d.ts.map +1 -1
- package/dist/src/httpServer/server.js +17 -17
- package/dist/src/httpServer/server.js.map +1 -1
- package/dist/src/{dbos-runtime → staticAnalysis}/TypeParser.d.ts +4 -0
- package/dist/src/staticAnalysis/TypeParser.d.ts.map +1 -0
- package/dist/src/{dbos-runtime → staticAnalysis}/TypeParser.js +34 -1
- package/dist/src/staticAnalysis/TypeParser.js.map +1 -0
- package/dist/src/{dbos-runtime → staticAnalysis}/openApi.d.ts.map +1 -1
- package/dist/src/{dbos-runtime → staticAnalysis}/openApi.js +1 -31
- package/dist/src/staticAnalysis/openApi.js.map +1 -0
- package/dist/src/staticAnalysis/tsDiagUtil.d.ts.map +1 -0
- package/dist/src/staticAnalysis/tsDiagUtil.js.map +1 -0
- package/dist/src/system_database.d.ts +22 -9
- package/dist/src/system_database.d.ts.map +1 -1
- package/dist/src/system_database.js +44 -42
- package/dist/src/system_database.js.map +1 -1
- package/dist/src/telemetry/collector.d.ts +5 -5
- package/dist/src/telemetry/collector.d.ts.map +1 -1
- package/dist/src/telemetry/collector.js +5 -17
- package/dist/src/telemetry/collector.js.map +1 -1
- package/dist/src/telemetry/exporters.d.ts +11 -24
- package/dist/src/telemetry/exporters.d.ts.map +1 -1
- package/dist/src/telemetry/exporters.js +42 -129
- package/dist/src/telemetry/exporters.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +6 -2
- package/dist/src/telemetry/index.d.ts.map +1 -1
- package/dist/src/telemetry/index.js +16 -0
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/logs.d.ts +35 -11
- package/dist/src/telemetry/logs.d.ts.map +1 -1
- package/dist/src/telemetry/logs.js +158 -53
- package/dist/src/telemetry/logs.js.map +1 -1
- package/dist/src/telemetry/traces.d.ts +1 -6
- package/dist/src/telemetry/traces.d.ts.map +1 -1
- package/dist/src/telemetry/traces.js +2 -34
- package/dist/src/telemetry/traces.js.map +1 -1
- package/dist/src/testing/testing_runtime.d.ts +1 -1
- package/dist/src/testing/testing_runtime.d.ts.map +1 -1
- package/dist/src/testing/testing_runtime.js +8 -2
- package/dist/src/testing/testing_runtime.js.map +1 -1
- package/dist/src/transaction.d.ts +1 -1
- package/dist/src/transaction.d.ts.map +1 -1
- package/dist/src/workflow.d.ts +16 -1
- package/dist/src/workflow.d.ts.map +1 -1
- package/dist/src/workflow.js +103 -61
- package/dist/src/workflow.js.map +1 -1
- package/examples/hello/README.md +1 -1
- package/examples/hello/dbos-config.yaml +3 -0
- package/package.json +3 -2
- package/dist/src/dbos-runtime/TypeParser.d.ts.map +0 -1
- package/dist/src/dbos-runtime/TypeParser.js.map +0 -1
- package/dist/src/dbos-runtime/openApi.js.map +0 -1
- package/dist/src/dbos-runtime/tsDiagUtil.d.ts.map +0 -1
- package/dist/src/dbos-runtime/tsDiagUtil.js.map +0 -1
- package/dist/src/telemetry/signals.d.ts +0 -20
- package/dist/src/telemetry/signals.d.ts.map +0 -1
- package/dist/src/telemetry/signals.js +0 -11
- package/dist/src/telemetry/signals.js.map +0 -1
- /package/dist/src/{dbos-runtime → staticAnalysis}/openApi.d.ts +0 -0
- /package/dist/src/{dbos-runtime → staticAnalysis}/tsDiagUtil.d.ts +0 -0
- /package/dist/src/{dbos-runtime → staticAnalysis}/tsDiagUtil.js +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"communicator.d.ts","sourceRoot":"","sources":["../../src/communicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"communicator.d.ts","sourceRoot":"","sources":["../../src/communicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAErG,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IAEtD,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,uBAAwB,SAAQ,eAAgB,YAAW,mBAAmB;IACzF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAGjB,eAAe,EAAE,mBAAmB,GAAG,oBAAoB,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM;CAYtK"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"communicator.js","sourceRoot":"","sources":["../../src/communicator.ts"],"names":[],"mappings":";;;AAGA,uCAAyD;
|
1
|
+
{"version":3,"file":"communicator.js","sourceRoot":"","sources":["../../src/communicator.ts"],"names":[],"mappings":";;;AAGA,uCAAyD;AAmBzD,MAAa,uBAAwB,SAAQ,yBAAe;IACjD,UAAU,CAAS;IACnB,cAAc,CAAU;IACxB,eAAe,CAAS;IACxB,WAAW,CAAS;IACpB,WAAW,CAAS;IAE7B,iCAAiC;IACjC,YAAY,eAA2D,EAAE,UAAkB,EAAE,IAAU,EAAE,MAAc,EAAE,MAA0B,EAAE,QAAgB;QACnK,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;QACpD,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;QAC3C,IAAI,eAAe,CAAC,iBAAiB,EAAE;YACrC,mEAAmE;YACnE,IAAI,CAAC,iBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC;SAC5D;IACH,CAAC;CACF;AApBD,0DAoBC"}
|
package/dist/src/context.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
/// <reference types="node" />
|
3
3
|
import { Span } from "@opentelemetry/sdk-trace-base";
|
4
|
-
import {
|
4
|
+
import { GlobalLogger as Logger, Logger as DBOSLogger } from "./telemetry/logs";
|
5
5
|
import { IncomingHttpHeaders } from "http";
|
6
6
|
import { ParsedUrlQuery } from "querystring";
|
7
7
|
import { DBOSExecutor } from "./dbos-executor";
|
@@ -47,11 +47,11 @@ export declare class DBOSContextImpl implements DBOSContext {
|
|
47
47
|
* TODO : move logger and application, getConfig to a BaseContext which is at the root of all contexts
|
48
48
|
*/
|
49
49
|
export declare class InitContext {
|
50
|
-
readonly
|
50
|
+
readonly dbosExec: DBOSExecutor;
|
51
51
|
readonly logger: Logger;
|
52
52
|
private userDatabase;
|
53
53
|
private application;
|
54
|
-
constructor(
|
54
|
+
constructor(dbosExec: DBOSExecutor);
|
55
55
|
createUserSchema(): Promise<void>;
|
56
56
|
dropUserSchema(): Promise<void>;
|
57
57
|
queryUserDB<R>(sql: string, ...params: unknown[]): Promise<R[]>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,Q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AAI,CAAC;IAIjC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAK/D,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IACxC,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC;CAmB9C"}
|
package/dist/src/context.js
CHANGED
@@ -16,7 +16,6 @@ class DBOSContextImpl {
|
|
16
16
|
constructor(operationName, span, logger, parentCtx) {
|
17
17
|
this.operationName = operationName;
|
18
18
|
this.span = span;
|
19
|
-
this.logger = new logs_1.Logger(logger, this);
|
20
19
|
if (parentCtx) {
|
21
20
|
this.request = parentCtx.request;
|
22
21
|
this.authenticatedUser = parentCtx.authenticatedUser;
|
@@ -24,6 +23,7 @@ class DBOSContextImpl {
|
|
24
23
|
this.assumedRole = parentCtx.assumedRole;
|
25
24
|
this.workflowUUID = parentCtx.workflowUUID;
|
26
25
|
}
|
26
|
+
this.logger = new logs_1.Logger(logger, this);
|
27
27
|
}
|
28
28
|
/*** Application configuration ***/
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -50,18 +50,18 @@ exports.DBOSContextImpl = DBOSContextImpl;
|
|
50
50
|
* TODO : move logger and application, getConfig to a BaseContext which is at the root of all contexts
|
51
51
|
*/
|
52
52
|
class InitContext {
|
53
|
-
|
53
|
+
dbosExec;
|
54
54
|
logger;
|
55
55
|
// All private Not exposed
|
56
56
|
userDatabase;
|
57
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
58
58
|
application;
|
59
|
-
constructor(
|
60
|
-
this.
|
61
|
-
this.logger =
|
62
|
-
this.userDatabase =
|
59
|
+
constructor(dbosExec) {
|
60
|
+
this.dbosExec = dbosExec;
|
61
|
+
this.logger = dbosExec.logger;
|
62
|
+
this.userDatabase = dbosExec.userDatabase;
|
63
63
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
64
|
-
this.application =
|
64
|
+
this.application = dbosExec.config.application;
|
65
65
|
}
|
66
66
|
createUserSchema() {
|
67
67
|
return this.userDatabase.createSchema();
|
@@ -83,7 +83,7 @@ class InitContext {
|
|
83
83
|
}
|
84
84
|
// If the key is found and the default value is provided, check whether the value is of the same type.
|
85
85
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
86
|
-
const value = (0, lodash_1.get)(this.
|
86
|
+
const value = (0, lodash_1.get)(this.dbosExec.config.application, key);
|
87
87
|
if (defaultValue && typeof value !== typeof defaultValue) {
|
88
88
|
throw new error_1.DBOSConfigKeyTypeError(key, typeof defaultValue, typeof value);
|
89
89
|
}
|
package/dist/src/context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;;AACA,2CAAgF;AAChF,mCAAkC;AAKlC,mCAAiD;AA8BjD,MAAa,eAAe;IAQL;IAAgC;IAPrD,OAAO,GAAgB,EAAE,CAAC,CAAU,6BAA6B;IACjE,iBAAiB,GAAW,EAAE,CAAC,CAAK,uCAAuC;IAC3E,kBAAkB,GAAa,EAAE,CAAC,CAAE,qDAAqD;IACzF,WAAW,GAAW,EAAE,CAAC,CAAW,6EAA6E;IACjH,YAAY,GAAW,EAAE,CAAC,CAAU,4CAA4C;IACvE,MAAM,CAAa,CAAM,qDAAqD;IAEvF,YAAqB,aAAqB,EAAW,IAAU,EAAE,MAAc,EAAE,SAA2B;QAAvF,kBAAa,GAAb,aAAa,CAAQ;QAAW,SAAI,GAAJ,IAAI,CAAM;QAC7D,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,OAAO,GAAG,S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,QAAQ,CAAC,YAAY,CAAC;QAC1C,mEAAmE;QACnE,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;IACjD,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;IAC1C,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,WAAW,CAAI,GAAW,EAAE,GAAG,MAAiB;QAC9C,iEAAiE;QACjE,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC;IACjD,CAAC;IAID,SAAS,CAAI,GAAW,EAAE,YAAgB;QACxC,0GAA0G;QAC1G,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAA,YAAG,EAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE;YACpD,IAAI,YAAY,EAAE;gBAChB,OAAO,YAAY,CAAC;aACrB;YACD,OAAO,SAAS,CAAC;SAClB;QAED,sGAAsG;QACtG,mEAAmE;QACnE,MAAM,KAAK,GAAG,IAAA,YAAG,EAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QACzD,IAAI,YAAY,IAAI,OAAO,KAAK,KAAK,OAAO,YAAY,EAAE;YACxD,MAAM,IAAI,8BAAsB,CAAC,GAAG,EAAE,OAAO,YAAY,EAAE,OAAO,KAAK,CAAC,CAAC;SAC1E;QAED,OAAO,KAAU,CAAC;IACpB,CAAC;CACF;AAjDD,kCAiDC"}
|
@@ -4,7 +4,7 @@ import { Transaction, TransactionConfig } from './transaction';
|
|
4
4
|
import { CommunicatorConfig, Communicator } from './communicator';
|
5
5
|
import { TelemetryCollector } from './telemetry/collector';
|
6
6
|
import { Tracer } from './telemetry/traces';
|
7
|
-
import {
|
7
|
+
import { GlobalLogger as Logger } from './telemetry/logs';
|
8
8
|
import { TelemetryConfig } from './telemetry';
|
9
9
|
import { PoolConfig } from 'pg';
|
10
10
|
import { SystemDatabase } from './system_database';
|
@@ -13,6 +13,7 @@ import { MethodRegistrationBase } from './decorators';
|
|
13
13
|
export interface DBOSNull {
|
14
14
|
}
|
15
15
|
export declare const dbosNull: DBOSNull;
|
16
|
+
export declare const DBOSExecutorIDHeader = "dbos-executor-id";
|
16
17
|
export interface DBOSConfig {
|
17
18
|
readonly poolConfig: PoolConfig;
|
18
19
|
readonly userDbclient?: UserDatabaseName;
|
@@ -23,27 +24,37 @@ export interface DBOSConfig {
|
|
23
24
|
readonly dbClientMetadata?: any;
|
24
25
|
readonly debugProxy?: string;
|
25
26
|
}
|
26
|
-
interface WorkflowInfo
|
27
|
-
workflow: Workflow<
|
27
|
+
interface WorkflowInfo {
|
28
|
+
workflow: Workflow<any, any>;
|
28
29
|
config: WorkflowConfig;
|
29
30
|
}
|
31
|
+
interface TransactionInfo {
|
32
|
+
transaction: Transaction<any, any>;
|
33
|
+
config: TransactionConfig;
|
34
|
+
}
|
35
|
+
interface CommunicatorInfo {
|
36
|
+
communicator: Communicator<any, any>;
|
37
|
+
config: CommunicatorConfig;
|
38
|
+
}
|
30
39
|
export declare class DBOSExecutor {
|
31
40
|
#private;
|
32
41
|
readonly config: DBOSConfig;
|
33
42
|
initialized: boolean;
|
34
43
|
userDatabase: UserDatabase;
|
35
44
|
readonly systemDatabase: SystemDatabase;
|
36
|
-
readonly tempWorkflowName = "temp_workflow";
|
37
|
-
readonly workflowInfoMap: Map<string, WorkflowInfo
|
38
|
-
readonly
|
39
|
-
readonly
|
45
|
+
static readonly tempWorkflowName = "temp_workflow";
|
46
|
+
readonly workflowInfoMap: Map<string, WorkflowInfo>;
|
47
|
+
readonly transactionInfoMap: Map<string, TransactionInfo>;
|
48
|
+
readonly communicatorInfoMap: Map<string, CommunicatorInfo>;
|
40
49
|
readonly registeredOperations: Array<MethodRegistrationBase>;
|
41
50
|
readonly pendingWorkflowMap: Map<string, Promise<unknown>>;
|
51
|
+
readonly pendingAsyncWrites: Map<string, Promise<unknown>>;
|
42
52
|
readonly telemetryCollector: TelemetryCollector;
|
43
53
|
readonly flushBufferIntervalMs: number;
|
44
54
|
readonly flushBufferID: NodeJS.Timeout;
|
45
55
|
static readonly defaultNotificationTimeoutSec = 60;
|
46
56
|
readonly debugMode: boolean;
|
57
|
+
static systemDBSchemaName: string;
|
47
58
|
readonly logger: Logger;
|
48
59
|
readonly tracer: Tracer;
|
49
60
|
entities: Function[];
|
@@ -73,6 +84,7 @@ export declare class DBOSExecutor {
|
|
73
84
|
* It runs to completion all pending workflows that were executing when the previous executor failed.
|
74
85
|
*/
|
75
86
|
recoverPendingWorkflows(executorIDs?: string[]): Promise<WorkflowHandle<any>[]>;
|
87
|
+
executeWorkflowUUID(workflowUUID: string): Promise<WorkflowHandle<unknown>>;
|
76
88
|
/**
|
77
89
|
* Periodically flush the workflow output buffer to the system database.
|
78
90
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dbos-executor.d.ts","sourceRoot":"","sources":["../../src/dbos-executor.ts"],"names":[],"mappings":";AAQA,OAAO,EAEL,QAAQ,EACR,cAAc,EAEd,cAAc,EACd,cAAc,
|
1
|
+
{"version":3,"file":"dbos-executor.d.ts","sourceRoot":"","sources":["../../src/dbos-executor.ts"],"names":[],"mappings":";AAQA,OAAO,EAEL,QAAQ,EACR,cAAc,EAEd,cAAc,EACd,cAAc,EAKf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAkB,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,kBAAkB,CA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AO,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnI;;OAEG;IACG,QAAQ,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,GAAE,MAAmD,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAIrK;;OAEG;IACH,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC;IAS5D;;;OAGG;IACG,uBAAuB,CAAC,WAAW,GAAE,MAAM,EAAc,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;IAmB1F,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAuEjF;;OAEG;IACG,yBAAyB;IAM/B,qBAAqB;CAatB"}
|
@@ -3,14 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.DBOSExecutor = exports.dbosNull = void 0;
|
6
|
+
exports.DBOSExecutor = exports.DBOSExecutorIDHeader = exports.dbosNull = void 0;
|
7
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
8
8
|
const error_1 = require("./error");
|
9
9
|
const workflow_1 = require("./workflow");
|
10
|
-
const
|
10
|
+
const transaction_1 = require("./transaction");
|
11
11
|
const collector_1 = require("./telemetry/collector");
|
12
12
|
const traces_1 = require("./telemetry/traces");
|
13
13
|
const logs_1 = require("./telemetry/logs");
|
14
|
+
const exporters_1 = require("./telemetry/exporters");
|
14
15
|
const system_database_1 = require("./system_database");
|
15
16
|
const uuid_1 = require("uuid");
|
16
17
|
const user_database_1 = require("./user_database");
|
@@ -19,7 +20,14 @@ const api_1 = require("@opentelemetry/api");
|
|
19
20
|
const knex_1 = __importDefault(require("knex"));
|
20
21
|
const context_1 = require("./context");
|
21
22
|
const debug_workflow_1 = require("./debugger/debug_workflow");
|
23
|
+
const serialize_error_1 = require("serialize-error");
|
22
24
|
exports.dbosNull = {};
|
25
|
+
exports.DBOSExecutorIDHeader = "dbos-executor-id";
|
26
|
+
const TempWorkflowType = {
|
27
|
+
transaction: "transaction",
|
28
|
+
external: "external",
|
29
|
+
send: "send",
|
30
|
+
};
|
23
31
|
class DBOSExecutor {
|
24
32
|
config;
|
25
33
|
initialized;
|
@@ -28,11 +36,11 @@ class DBOSExecutor {
|
|
28
36
|
// System Database
|
29
37
|
systemDatabase;
|
30
38
|
// Temporary workflows are created by calling transaction/send/recv directly from the executor class
|
31
|
-
tempWorkflowName = "temp_workflow";
|
39
|
+
static tempWorkflowName = "temp_workflow";
|
32
40
|
workflowInfoMap = new Map([
|
33
41
|
// We initialize the map with an entry for temporary workflows.
|
34
42
|
[
|
35
|
-
|
43
|
+
DBOSExecutor.tempWorkflowName,
|
36
44
|
{
|
37
45
|
// eslint-disable-next-line @typescript-eslint/require-await
|
38
46
|
workflow: async () => this.logger.error("UNREACHABLE: Indirect invoke of temp workflow"),
|
@@ -40,15 +48,17 @@ class DBOSExecutor {
|
|
40
48
|
},
|
41
49
|
],
|
42
50
|
]);
|
43
|
-
|
44
|
-
|
51
|
+
transactionInfoMap = new Map();
|
52
|
+
communicatorInfoMap = new Map();
|
45
53
|
registeredOperations = [];
|
46
|
-
pendingWorkflowMap = new Map(); // Map from workflowUUID to workflow promise
|
54
|
+
pendingWorkflowMap = new Map(); // Map from workflowUUID to workflow promise
|
55
|
+
pendingAsyncWrites = new Map(); // Map from workflowUUID to asynchronous write promise
|
47
56
|
telemetryCollector;
|
48
57
|
flushBufferIntervalMs = 1000;
|
49
58
|
flushBufferID;
|
50
59
|
static defaultNotificationTimeoutSec = 60;
|
51
60
|
debugMode;
|
61
|
+
static systemDBSchemaName = "public";
|
52
62
|
logger;
|
53
63
|
tracer;
|
54
64
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
@@ -57,9 +67,28 @@ class DBOSExecutor {
|
|
57
67
|
constructor(config, systemDatabase) {
|
58
68
|
this.config = config;
|
59
69
|
this.debugMode = config.debugProxy ? true : false;
|
60
|
-
|
70
|
+
if (config.telemetry?.OTLPExporter) {
|
71
|
+
const OTLPExporter = new exporters_1.TelemetryExporter(config.telemetry.OTLPExporter);
|
72
|
+
this.telemetryCollector = new collector_1.TelemetryCollector(OTLPExporter);
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
// We always an collector to drain the signals queue, even if we don't have an exporter.
|
76
|
+
this.telemetryCollector = new collector_1.TelemetryCollector();
|
77
|
+
}
|
78
|
+
this.logger = new logs_1.GlobalLogger(this.telemetryCollector, this.config.telemetry?.logs);
|
79
|
+
this.tracer = new traces_1.Tracer(this.telemetryCollector);
|
61
80
|
if (this.debugMode) {
|
62
81
|
this.logger.info("Running in debug mode!");
|
82
|
+
try {
|
83
|
+
const url = new URL(this.config.debugProxy);
|
84
|
+
this.config.poolConfig.host = url.hostname;
|
85
|
+
this.config.poolConfig.port = parseInt(url.port, 10);
|
86
|
+
this.logger.info(`Debugging mode proxy: ${this.config.poolConfig.host}:${this.config.poolConfig.port}`);
|
87
|
+
}
|
88
|
+
catch (err) {
|
89
|
+
this.logger.error(err);
|
90
|
+
throw err;
|
91
|
+
}
|
63
92
|
}
|
64
93
|
if (systemDatabase) {
|
65
94
|
this.logger.debug("Using provided system database"); // XXX print the name or something
|
@@ -75,31 +104,11 @@ class DBOSExecutor {
|
|
75
104
|
}
|
76
105
|
}, this.flushBufferIntervalMs);
|
77
106
|
this.logger.debug("Started workflow status buffer worker");
|
78
|
-
// Add Jaeger exporter if tracing is enabled
|
79
|
-
const telemetryExporters = [];
|
80
|
-
if (this.config.telemetry?.traces?.enabled && !this.debugMode) {
|
81
|
-
telemetryExporters.push(new exporters_1.JaegerExporter(this.config.telemetry?.traces?.endpoint));
|
82
|
-
this.logger.debug("Loaded Jaeger Telemetry Exporter");
|
83
|
-
}
|
84
|
-
this.telemetryCollector = new collector_1.TelemetryCollector(telemetryExporters);
|
85
|
-
this.tracer = new traces_1.Tracer(this.telemetryCollector);
|
86
107
|
this.initialized = false;
|
87
108
|
}
|
88
109
|
configureDbClient() {
|
89
110
|
const userDbClient = this.config.userDbclient;
|
90
|
-
const userDBConfig =
|
91
|
-
if (this.debugMode) {
|
92
|
-
try {
|
93
|
-
const url = new URL(this.config.debugProxy);
|
94
|
-
userDBConfig.host = url.hostname;
|
95
|
-
userDBConfig.port = parseInt(url.port, 10);
|
96
|
-
this.logger.info(`Debugging mode proxy: ${userDBConfig.host}:${userDBConfig.port}`);
|
97
|
-
}
|
98
|
-
catch (err) {
|
99
|
-
this.logger.error(err);
|
100
|
-
return;
|
101
|
-
}
|
102
|
-
}
|
111
|
+
const userDBConfig = this.config.poolConfig;
|
103
112
|
if (userDbClient === user_database_1.UserDatabaseName.PRISMA) {
|
104
113
|
// TODO: make Prisma work with debugger proxy.
|
105
114
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
@@ -112,8 +121,9 @@ class DBOSExecutor {
|
|
112
121
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
113
122
|
const DataSourceExports = require("typeorm");
|
114
123
|
try {
|
124
|
+
this.userDatabase = new user_database_1.TypeORMDatabase(
|
115
125
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
116
|
-
|
126
|
+
new DataSourceExports.DataSource({
|
117
127
|
type: "postgres",
|
118
128
|
host: userDBConfig.host,
|
119
129
|
port: userDBConfig.port,
|
@@ -121,11 +131,12 @@ class DBOSExecutor {
|
|
121
131
|
password: userDBConfig.password,
|
122
132
|
database: userDBConfig.database,
|
123
133
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
124
|
-
entities: this.entities
|
134
|
+
entities: this.entities,
|
125
135
|
}));
|
126
136
|
}
|
127
137
|
catch (s) {
|
128
|
-
|
138
|
+
s.message = `Error loading TypeORM user database: ${s.message}`;
|
139
|
+
this.logger.error(s);
|
129
140
|
}
|
130
141
|
this.logger.debug("Loaded TypeORM user database");
|
131
142
|
}
|
@@ -139,7 +150,7 @@ class DBOSExecutor {
|
|
139
150
|
password: userDBConfig.password,
|
140
151
|
database: userDBConfig.database,
|
141
152
|
ssl: userDBConfig.ssl,
|
142
|
-
}
|
153
|
+
},
|
143
154
|
};
|
144
155
|
this.userDatabase = new user_database_1.KnexUserDatabase((0, knex_1.default)(knexConfig));
|
145
156
|
this.logger.debug("Loaded Knex user database");
|
@@ -194,16 +205,14 @@ class DBOSExecutor {
|
|
194
205
|
// Debug mode doesn't need to initialize the DBs. Everything should appear to be read-only.
|
195
206
|
if (!this.debugMode) {
|
196
207
|
await this.systemDatabase.init();
|
197
|
-
await this.telemetryCollector.init(this.registeredOperations);
|
198
208
|
await this.userDatabase.init(); // Skip user DB init because we're using the proxy.
|
199
209
|
await this.recoverPendingWorkflows();
|
200
210
|
}
|
201
211
|
}
|
202
212
|
catch (err) {
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
}
|
213
|
+
err.message = `failed to initialize workflow executor: ${err.message}`;
|
214
|
+
this.logger.error(err);
|
215
|
+
throw new error_1.DBOSInitializationError(`failed to initialize workflow executor: ${err.message}`);
|
207
216
|
}
|
208
217
|
this.initialized = true;
|
209
218
|
// Only execute init code if under non-debug mode
|
@@ -223,6 +232,10 @@ class DBOSExecutor {
|
|
223
232
|
this.logger.info("Waiting for pending workflows to finish.");
|
224
233
|
await Promise.allSettled(this.pendingWorkflowMap.values());
|
225
234
|
}
|
235
|
+
if (this.pendingAsyncWrites.size > 0) {
|
236
|
+
this.logger.info("Waiting for pending buffer flushes to finish");
|
237
|
+
await Promise.allSettled(this.pendingAsyncWrites.values());
|
238
|
+
}
|
226
239
|
clearInterval(this.flushBufferID);
|
227
240
|
await this.flushWorkflowStatusBuffer();
|
228
241
|
await this.systemDatabase.destroy();
|
@@ -231,7 +244,7 @@ class DBOSExecutor {
|
|
231
244
|
}
|
232
245
|
/* WORKFLOW OPERATIONS */
|
233
246
|
#registerWorkflow(wf, config = {}) {
|
234
|
-
if (wf.name ===
|
247
|
+
if (wf.name === DBOSExecutor.tempWorkflowName || this.workflowInfoMap.has(wf.name)) {
|
235
248
|
throw new error_1.DBOSError(`Repeated workflow name: ${wf.name}`);
|
236
249
|
}
|
237
250
|
const workflowInfo = {
|
@@ -241,16 +254,24 @@ class DBOSExecutor {
|
|
241
254
|
this.workflowInfoMap.set(wf.name, workflowInfo);
|
242
255
|
}
|
243
256
|
#registerTransaction(txn, params = {}) {
|
244
|
-
if (this.
|
257
|
+
if (this.transactionInfoMap.has(txn.name)) {
|
245
258
|
throw new error_1.DBOSError(`Repeated Transaction name: ${txn.name}`);
|
246
259
|
}
|
247
|
-
|
260
|
+
const txnInfo = {
|
261
|
+
transaction: txn,
|
262
|
+
config: params,
|
263
|
+
};
|
264
|
+
this.transactionInfoMap.set(txn.name, txnInfo);
|
248
265
|
}
|
249
266
|
#registerCommunicator(comm, params = {}) {
|
250
|
-
if (this.
|
267
|
+
if (this.communicatorInfoMap.has(comm.name)) {
|
251
268
|
throw new error_1.DBOSError(`Repeated Commmunicator name: ${comm.name}`);
|
252
269
|
}
|
253
|
-
|
270
|
+
const commInfo = {
|
271
|
+
communicator: comm,
|
272
|
+
config: params,
|
273
|
+
};
|
274
|
+
this.communicatorInfoMap.set(comm.name, commInfo);
|
254
275
|
}
|
255
276
|
async workflow(wf, params, ...args) {
|
256
277
|
if (this.debugMode) {
|
@@ -261,31 +282,58 @@ class DBOSExecutor {
|
|
261
282
|
// If callerUUID and functionID are set, it means the workflow is invoked from within a workflow.
|
262
283
|
async internalWorkflow(wf, params, callerUUID, callerFunctionID, ...args) {
|
263
284
|
const workflowUUID = params.workflowUUID ? params.workflowUUID : this.#generateUUID();
|
285
|
+
const presetUUID = params.workflowUUID ? true : false;
|
264
286
|
const wInfo = this.workflowInfoMap.get(wf.name);
|
265
287
|
if (wInfo === undefined) {
|
266
288
|
throw new error_1.DBOSNotRegisteredError(wf.name);
|
267
289
|
}
|
268
290
|
const wConfig = wInfo.config;
|
269
|
-
const wCtxt = new workflow_1.WorkflowContextImpl(this, params.parentCtx, workflowUUID, wConfig, wf.name);
|
291
|
+
const wCtxt = new workflow_1.WorkflowContextImpl(this, params.parentCtx, workflowUUID, wConfig, wf.name, presetUUID);
|
270
292
|
wCtxt.span.setAttributes({ args: JSON.stringify(args) }); // TODO enforce skipLogging & request for hashing
|
271
|
-
|
293
|
+
let executorID = "local";
|
294
|
+
if (wCtxt.request.headers && wCtxt.request.headers[exports.DBOSExecutorIDHeader]) {
|
295
|
+
executorID = wCtxt.request.headers[exports.DBOSExecutorIDHeader];
|
296
|
+
}
|
297
|
+
const internalStatus = {
|
298
|
+
workflowUUID: workflowUUID,
|
299
|
+
status: workflow_1.StatusString.PENDING,
|
300
|
+
name: wf.name,
|
301
|
+
authenticatedUser: wCtxt.authenticatedUser,
|
302
|
+
output: undefined,
|
303
|
+
error: "",
|
304
|
+
assumedRole: wCtxt.assumedRole,
|
305
|
+
authenticatedRoles: wCtxt.authenticatedRoles,
|
306
|
+
request: wCtxt.request,
|
307
|
+
executorID: executorID,
|
308
|
+
};
|
309
|
+
// Synchronously set the workflow's status to PENDING and record workflow inputs.
|
272
310
|
if (!wCtxt.isTempWorkflow) {
|
273
|
-
args = await this.systemDatabase.initWorkflowStatus(
|
311
|
+
args = await this.systemDatabase.initWorkflowStatus(internalStatus, args);
|
312
|
+
}
|
313
|
+
else {
|
314
|
+
// For temporary workflows, instead asynchronously record inputs.
|
315
|
+
const setWorkflowInputs = this.systemDatabase
|
316
|
+
.setWorkflowInputs(workflowUUID, args)
|
317
|
+
.catch((error) => {
|
318
|
+
error.message = `Error asynchronously setting workflow inputs: ${error.message}`;
|
319
|
+
this.logger.error(error);
|
320
|
+
})
|
321
|
+
.finally(() => {
|
322
|
+
this.pendingAsyncWrites.delete(workflowUUID);
|
323
|
+
});
|
324
|
+
this.pendingAsyncWrites.set(workflowUUID, setWorkflowInputs);
|
274
325
|
}
|
275
326
|
const runWorkflow = async () => {
|
276
|
-
// Check if the workflow previously ran.
|
277
|
-
const previousOutput = await this.systemDatabase.checkWorkflowOutput(workflowUUID);
|
278
|
-
if (previousOutput !== exports.dbosNull) {
|
279
|
-
wCtxt.span.setAttribute("cached", true);
|
280
|
-
wCtxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
|
281
|
-
this.tracer.endSpan(wCtxt.span);
|
282
|
-
return previousOutput;
|
283
|
-
}
|
284
327
|
let result;
|
285
328
|
// Execute the workflow.
|
286
329
|
try {
|
287
330
|
result = await wf(wCtxt, ...args);
|
288
|
-
|
331
|
+
if (wCtxt.isTempWorkflow) {
|
332
|
+
internalStatus.name = `${DBOSExecutor.tempWorkflowName}-${wCtxt.tempWfOperationType}-${wCtxt.tempWfOperationName}`;
|
333
|
+
}
|
334
|
+
internalStatus.output = result;
|
335
|
+
internalStatus.status = workflow_1.StatusString.SUCCESS;
|
336
|
+
this.systemDatabase.bufferWorkflowOutput(workflowUUID, internalStatus);
|
289
337
|
wCtxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
|
290
338
|
}
|
291
339
|
catch (err) {
|
@@ -300,7 +348,12 @@ class DBOSExecutor {
|
|
300
348
|
// Record the error.
|
301
349
|
const e = err;
|
302
350
|
this.logger.error(e);
|
303
|
-
|
351
|
+
if (wCtxt.isTempWorkflow) {
|
352
|
+
internalStatus.name = `${DBOSExecutor.tempWorkflowName}-${wCtxt.tempWfOperationType}-${wCtxt.tempWfOperationName}`;
|
353
|
+
}
|
354
|
+
internalStatus.error = JSON.stringify((0, serialize_error_1.serializeError)(e));
|
355
|
+
internalStatus.status = workflow_1.StatusString.ERROR;
|
356
|
+
await this.systemDatabase.recordWorkflowError(workflowUUID, internalStatus);
|
304
357
|
// TODO: Log errors, but not in the tests when they're expected.
|
305
358
|
wCtxt.span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e.message });
|
306
359
|
throw err;
|
@@ -309,6 +362,21 @@ class DBOSExecutor {
|
|
309
362
|
finally {
|
310
363
|
this.tracer.endSpan(wCtxt.span);
|
311
364
|
}
|
365
|
+
// Asynchronously flush the result buffer.
|
366
|
+
const resultBufferFlush = this.userDatabase
|
367
|
+
.transaction(async (client) => {
|
368
|
+
if (wCtxt.resultBuffer.size > 0) {
|
369
|
+
await wCtxt.flushResultBuffer(client);
|
370
|
+
}
|
371
|
+
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted })
|
372
|
+
.catch((error) => {
|
373
|
+
error.message = `Error asynchronously flushing result buffer: ${error.message}`;
|
374
|
+
this.logger.error(error);
|
375
|
+
})
|
376
|
+
.finally(() => {
|
377
|
+
this.pendingAsyncWrites.delete(workflowUUID);
|
378
|
+
});
|
379
|
+
this.pendingAsyncWrites.set(workflowUUID, resultBufferFlush);
|
312
380
|
return result;
|
313
381
|
};
|
314
382
|
const workflowPromise = runWorkflow();
|
@@ -358,6 +426,8 @@ class DBOSExecutor {
|
|
358
426
|
// Create a workflow and call transaction.
|
359
427
|
const temp_workflow = async (ctxt, ...args) => {
|
360
428
|
const ctxtImpl = ctxt;
|
429
|
+
ctxtImpl.tempWfOperationType = TempWorkflowType.transaction;
|
430
|
+
ctxtImpl.tempWfOperationName = txn.name;
|
361
431
|
return await ctxtImpl.transaction(txn, ...args);
|
362
432
|
};
|
363
433
|
return (await this.workflow(temp_workflow, params, ...args)).getResult();
|
@@ -366,6 +436,8 @@ class DBOSExecutor {
|
|
366
436
|
// Create a workflow and call external.
|
367
437
|
const temp_workflow = async (ctxt, ...args) => {
|
368
438
|
const ctxtImpl = ctxt;
|
439
|
+
ctxtImpl.tempWfOperationType = TempWorkflowType.external;
|
440
|
+
ctxtImpl.tempWfOperationName = commFn.name;
|
369
441
|
return await ctxtImpl.external(commFn, ...args);
|
370
442
|
};
|
371
443
|
return (await this.workflow(temp_workflow, params, ...args)).getResult();
|
@@ -373,6 +445,8 @@ class DBOSExecutor {
|
|
373
445
|
async send(destinationUUID, message, topic, idempotencyKey) {
|
374
446
|
// Create a workflow and call send.
|
375
447
|
const temp_workflow = async (ctxt, destinationUUID, message, topic) => {
|
448
|
+
const ctxtImpl = ctxt;
|
449
|
+
ctxtImpl.tempWfOperationType = TempWorkflowType.send;
|
376
450
|
return await ctxt.send(destinationUUID, message, topic);
|
377
451
|
};
|
378
452
|
const workflowUUID = idempotencyKey ? destinationUUID + idempotencyKey : undefined;
|
@@ -408,23 +482,68 @@ class DBOSExecutor {
|
|
408
482
|
const handlerArray = [];
|
409
483
|
for (const workflowUUID of pendingWorkflows) {
|
410
484
|
try {
|
411
|
-
|
412
|
-
const inputs = await this.systemDatabase.getWorkflowInputs(workflowUUID);
|
413
|
-
if (!inputs || !wfStatus) {
|
414
|
-
this.logger.error(`Failed to find inputs during recover, workflow UUID: ${workflowUUID}`);
|
415
|
-
continue;
|
416
|
-
}
|
417
|
-
const wfInfo = this.workflowInfoMap.get(wfStatus.workflowName);
|
418
|
-
const parentCtx = this.#getRecoveryContext(workflowUUID, wfStatus);
|
419
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
420
|
-
handlerArray.push(await this.workflow(wfInfo.workflow, { workflowUUID: workflowUUID, parentCtx: parentCtx ?? undefined }, ...inputs));
|
485
|
+
handlerArray.push(await this.executeWorkflowUUID(workflowUUID));
|
421
486
|
}
|
422
487
|
catch (e) {
|
423
|
-
this.logger.warn(`Recovery of workflow ${workflowUUID} failed
|
488
|
+
this.logger.warn(`Recovery of workflow ${workflowUUID} failed: ${e.message}`);
|
424
489
|
}
|
425
490
|
}
|
426
491
|
return handlerArray;
|
427
492
|
}
|
493
|
+
async executeWorkflowUUID(workflowUUID) {
|
494
|
+
const wfStatus = await this.systemDatabase.getWorkflowStatus(workflowUUID);
|
495
|
+
const inputs = await this.systemDatabase.getWorkflowInputs(workflowUUID);
|
496
|
+
if (!inputs || !wfStatus) {
|
497
|
+
this.logger.error(`Failed to find inputs for workflowUUID: ${workflowUUID}`);
|
498
|
+
throw new error_1.DBOSError(`Failed to find inputs for workflow UUID: ${workflowUUID}`);
|
499
|
+
}
|
500
|
+
const parentCtx = this.#getRecoveryContext(workflowUUID, wfStatus);
|
501
|
+
const wfInfo = this.workflowInfoMap.get(wfStatus.workflowName);
|
502
|
+
if (wfInfo) {
|
503
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
504
|
+
return this.workflow(wfInfo.workflow, { workflowUUID: workflowUUID, parentCtx: parentCtx ?? undefined }, ...inputs);
|
505
|
+
}
|
506
|
+
// Should be temporary workflows. Parse the name of the workflow.
|
507
|
+
const wfName = wfStatus.workflowName;
|
508
|
+
const nameArr = wfName.split("-");
|
509
|
+
if (!nameArr[0].startsWith(DBOSExecutor.tempWorkflowName)) {
|
510
|
+
throw new error_1.DBOSError(`This should never happen! Cannot find workflow info for a non-temporary workflow! UUID ${workflowUUID}, name ${wfName}`);
|
511
|
+
}
|
512
|
+
let temp_workflow;
|
513
|
+
if (nameArr[1] === TempWorkflowType.transaction) {
|
514
|
+
const txnInfo = this.transactionInfoMap.get(nameArr[2]);
|
515
|
+
if (!txnInfo) {
|
516
|
+
throw new error_1.DBOSError(`Cannot find transaction info for UUID ${workflowUUID}, name ${wfName}`);
|
517
|
+
}
|
518
|
+
temp_workflow = async (ctxt, ...args) => {
|
519
|
+
const ctxtImpl = ctxt;
|
520
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument
|
521
|
+
return await ctxtImpl.transaction(txnInfo.transaction, ...args);
|
522
|
+
};
|
523
|
+
}
|
524
|
+
else if (nameArr[1] === TempWorkflowType.external) {
|
525
|
+
const commInfo = this.communicatorInfoMap.get(nameArr[2]);
|
526
|
+
if (!commInfo) {
|
527
|
+
throw new error_1.DBOSError(`Cannot find transaction info for UUID ${workflowUUID}, name ${wfName}`);
|
528
|
+
}
|
529
|
+
temp_workflow = async (ctxt, ...args) => {
|
530
|
+
const ctxtImpl = ctxt;
|
531
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument
|
532
|
+
return await ctxtImpl.external(commInfo.communicator, ...args);
|
533
|
+
};
|
534
|
+
}
|
535
|
+
else if (nameArr[1] === TempWorkflowType.send) {
|
536
|
+
temp_workflow = async (ctxt, ...args) => {
|
537
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
538
|
+
return await ctxt.send(args[0], args[1], args[2]);
|
539
|
+
};
|
540
|
+
}
|
541
|
+
else {
|
542
|
+
throw new error_1.DBOSError(`Unrecognized temporary workflow! UUID ${workflowUUID}, name ${wfName}`);
|
543
|
+
}
|
544
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
545
|
+
return this.workflow(temp_workflow, { workflowUUID: workflowUUID, parentCtx: parentCtx ?? undefined }, ...inputs);
|
546
|
+
}
|
428
547
|
#getRecoveryContext(workflowUUID, status) {
|
429
548
|
const span = this.tracer.startSpan(status.workflowName);
|
430
549
|
span.setAttributes({
|