@dbos-inc/dbos-sdk 0.8.45-preview → 0.8.46-preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/dist/packages/dbos-cloud/applications/delete-app.d.ts.map +1 -1
  2. package/dist/packages/dbos-cloud/applications/delete-app.js +1 -2
  3. package/dist/packages/dbos-cloud/applications/delete-app.js.map +1 -1
  4. package/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts.map +1 -1
  5. package/dist/packages/dbos-cloud/applications/deploy-app-code.js +5 -7
  6. package/dist/packages/dbos-cloud/applications/deploy-app-code.js.map +1 -1
  7. package/dist/packages/dbos-cloud/applications/get-app-logs.d.ts.map +1 -1
  8. package/dist/packages/dbos-cloud/applications/get-app-logs.js +1 -2
  9. package/dist/packages/dbos-cloud/applications/get-app-logs.js.map +1 -1
  10. package/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +1 -1
  11. package/dist/packages/dbos-cloud/applications/list-apps.js +1 -2
  12. package/dist/packages/dbos-cloud/applications/list-apps.js.map +1 -1
  13. package/dist/packages/dbos-cloud/applications/register-app.d.ts.map +1 -1
  14. package/dist/packages/dbos-cloud/applications/register-app.js +1 -2
  15. package/dist/packages/dbos-cloud/applications/register-app.js.map +1 -1
  16. package/dist/packages/dbos-cloud/applications/update-app.d.ts.map +1 -1
  17. package/dist/packages/dbos-cloud/applications/update-app.js +1 -2
  18. package/dist/packages/dbos-cloud/applications/update-app.js.map +1 -1
  19. package/dist/packages/dbos-cloud/cloudutils.d.ts +7 -0
  20. package/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
  21. package/dist/packages/dbos-cloud/cloudutils.js +44 -3
  22. package/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
  23. package/dist/packages/dbos-cloud/login.d.ts.map +1 -1
  24. package/dist/packages/dbos-cloud/login.js +3 -4
  25. package/dist/packages/dbos-cloud/login.js.map +1 -1
  26. package/dist/packages/dbos-cloud/register.d.ts.map +1 -1
  27. package/dist/packages/dbos-cloud/register.js +1 -2
  28. package/dist/packages/dbos-cloud/register.js.map +1 -1
  29. package/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
  30. package/dist/packages/dbos-cloud/userdb.js +3 -4
  31. package/dist/packages/dbos-cloud/userdb.js.map +1 -1
  32. package/dist/src/context.d.ts +1 -0
  33. package/dist/src/context.d.ts.map +1 -1
  34. package/dist/src/httpServer/server.d.ts +2 -1
  35. package/dist/src/httpServer/server.d.ts.map +1 -1
  36. package/dist/src/testing/testing_runtime.d.ts +2 -1
  37. package/dist/src/testing/testing_runtime.d.ts.map +1 -1
  38. package/dist/src/utils.d.ts +0 -1
  39. package/dist/src/utils.d.ts.map +1 -1
  40. package/dist/src/utils.js +3 -12
  41. package/dist/src/utils.js.map +1 -1
  42. package/dist/tsconfig.build.tsbuildinfo +1 -1
  43. package/package.json +1 -1
  44. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.d.ts.map +1 -1
  45. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.js +1 -2
  46. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.js.map +1 -1
  47. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts.map +1 -1
  48. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.js +5 -7
  49. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.js.map +1 -1
  50. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.d.ts.map +1 -1
  51. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.js +1 -2
  52. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.js.map +1 -1
  53. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +1 -1
  54. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.js +1 -2
  55. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.js.map +1 -1
  56. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.d.ts.map +1 -1
  57. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.js +1 -2
  58. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.js.map +1 -1
  59. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.d.ts.map +1 -1
  60. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.js +1 -2
  61. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.js.map +1 -1
  62. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.d.ts +7 -0
  63. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
  64. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.js +44 -3
  65. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
  66. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.d.ts.map +1 -1
  67. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.js +3 -4
  68. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.js.map +1 -1
  69. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.d.ts.map +1 -1
  70. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.js +1 -2
  71. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.js.map +1 -1
  72. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
  73. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.js +3 -4
  74. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.js.map +1 -1
  75. package/packages/dbos-cloud/dist/src/utils.d.ts +0 -1
  76. package/packages/dbos-cloud/dist/src/utils.d.ts.map +1 -1
  77. package/packages/dbos-cloud/dist/src/utils.js +3 -12
  78. package/packages/dbos-cloud/dist/src/utils.js.map +1 -1
  79. package/packages/dbos-cloud/package.json +1 -1
  80. package/packages/dbos-openapi/package.json +1 -1
  81. package/packages/dbos-cloud/dist/schemas/system_db_schema.d.ts +0 -34
  82. package/packages/dbos-cloud/dist/schemas/system_db_schema.d.ts.map +0 -1
  83. package/packages/dbos-cloud/dist/schemas/system_db_schema.js +0 -77
  84. package/packages/dbos-cloud/dist/schemas/system_db_schema.js.map +0 -1
  85. package/packages/dbos-cloud/dist/schemas/user_db_schema.d.ts +0 -11
  86. package/packages/dbos-cloud/dist/schemas/user_db_schema.d.ts.map +0 -1
  87. package/packages/dbos-cloud/dist/schemas/user_db_schema.js +0 -16
  88. package/packages/dbos-cloud/dist/schemas/user_db_schema.js.map +0 -1
  89. package/packages/dbos-cloud/dist/src/communicator.d.ts +0 -25
  90. package/packages/dbos-cloud/dist/src/communicator.d.ts.map +0 -1
  91. package/packages/dbos-cloud/dist/src/communicator.js +0 -26
  92. package/packages/dbos-cloud/dist/src/communicator.js.map +0 -1
  93. package/packages/dbos-cloud/dist/src/context.d.ts +0 -64
  94. package/packages/dbos-cloud/dist/src/context.d.ts.map +0 -1
  95. package/packages/dbos-cloud/dist/src/context.js +0 -96
  96. package/packages/dbos-cloud/dist/src/context.js.map +0 -1
  97. package/packages/dbos-cloud/dist/src/data_validation.d.ts +0 -3
  98. package/packages/dbos-cloud/dist/src/data_validation.d.ts.map +0 -1
  99. package/packages/dbos-cloud/dist/src/data_validation.js +0 -168
  100. package/packages/dbos-cloud/dist/src/data_validation.js.map +0 -1
  101. package/packages/dbos-cloud/dist/src/dbos-executor.d.ts +0 -102
  102. package/packages/dbos-cloud/dist/src/dbos-executor.d.ts.map +0 -1
  103. package/packages/dbos-cloud/dist/src/dbos-executor.js +0 -631
  104. package/packages/dbos-cloud/dist/src/dbos-executor.js.map +0 -1
  105. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.d.ts +0 -3
  106. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.d.ts.map +0 -1
  107. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.js +0 -13
  108. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.js.map +0 -1
  109. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.d.ts +0 -8
  110. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.d.ts.map +0 -1
  111. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.js +0 -61
  112. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.js.map +0 -1
  113. package/packages/dbos-cloud/dist/src/dbos-runtime/config.d.ts +0 -29
  114. package/packages/dbos-cloud/dist/src/dbos-runtime/config.d.ts.map +0 -1
  115. package/packages/dbos-cloud/dist/src/dbos-runtime/config.js +0 -111
  116. package/packages/dbos-cloud/dist/src/dbos-runtime/config.js.map +0 -1
  117. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.d.ts +0 -4
  118. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.d.ts.map +0 -1
  119. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.js +0 -21
  120. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.js.map +0 -1
  121. package/packages/dbos-cloud/dist/src/dbos-runtime/init.d.ts +0 -7
  122. package/packages/dbos-cloud/dist/src/dbos-runtime/init.d.ts.map +0 -1
  123. package/packages/dbos-cloud/dist/src/dbos-runtime/init.js +0 -51
  124. package/packages/dbos-cloud/dist/src/dbos-runtime/init.js.map +0 -1
  125. package/packages/dbos-cloud/dist/src/dbos-runtime/migrate.d.ts +0 -3
  126. package/packages/dbos-cloud/dist/src/dbos-runtime/migrate.d.ts.map +0 -1
  127. package/packages/dbos-cloud/dist/src/dbos-runtime/migrate.js +0 -175
  128. package/packages/dbos-cloud/dist/src/dbos-runtime/migrate.js.map +0 -1
  129. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.d.ts +0 -28
  130. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.d.ts.map +0 -1
  131. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.js +0 -95
  132. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.js.map +0 -1
  133. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.d.ts +0 -38
  134. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.d.ts.map +0 -1
  135. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.js +0 -211
  136. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.js.map +0 -1
  137. package/packages/dbos-cloud/dist/src/decorators.d.ts +0 -118
  138. package/packages/dbos-cloud/dist/src/decorators.d.ts.map +0 -1
  139. package/packages/dbos-cloud/dist/src/decorators.js +0 -467
  140. package/packages/dbos-cloud/dist/src/decorators.js.map +0 -1
  141. package/packages/dbos-cloud/dist/src/error.d.ts +0 -47
  142. package/packages/dbos-cloud/dist/src/error.d.ts.map +0 -1
  143. package/packages/dbos-cloud/dist/src/error.js +0 -171
  144. package/packages/dbos-cloud/dist/src/error.js.map +0 -1
  145. package/packages/dbos-cloud/dist/src/httpServer/handler.d.ts +0 -54
  146. package/packages/dbos-cloud/dist/src/httpServer/handler.d.ts.map +0 -1
  147. package/packages/dbos-cloud/dist/src/httpServer/handler.js +0 -175
  148. package/packages/dbos-cloud/dist/src/httpServer/handler.js.map +0 -1
  149. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.d.ts +0 -11
  150. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.d.ts.map +0 -1
  151. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.js +0 -19
  152. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.js.map +0 -1
  153. package/packages/dbos-cloud/dist/src/httpServer/middleware.d.ts +0 -56
  154. package/packages/dbos-cloud/dist/src/httpServer/middleware.d.ts.map +0 -1
  155. package/packages/dbos-cloud/dist/src/httpServer/middleware.js +0 -57
  156. package/packages/dbos-cloud/dist/src/httpServer/middleware.js.map +0 -1
  157. package/packages/dbos-cloud/dist/src/httpServer/server.d.ts +0 -45
  158. package/packages/dbos-cloud/dist/src/httpServer/server.d.ts.map +0 -1
  159. package/packages/dbos-cloud/dist/src/httpServer/server.js +0 -253
  160. package/packages/dbos-cloud/dist/src/httpServer/server.js.map +0 -1
  161. package/packages/dbos-cloud/dist/src/system_database.d.ts +0 -91
  162. package/packages/dbos-cloud/dist/src/system_database.d.ts.map +0 -1
  163. package/packages/dbos-cloud/dist/src/system_database.js +0 -462
  164. package/packages/dbos-cloud/dist/src/system_database.js.map +0 -1
  165. package/packages/dbos-cloud/dist/src/telemetry/collector.d.ts +0 -16
  166. package/packages/dbos-cloud/dist/src/telemetry/collector.d.ts.map +0 -1
  167. package/packages/dbos-cloud/dist/src/telemetry/collector.js +0 -65
  168. package/packages/dbos-cloud/dist/src/telemetry/collector.js.map +0 -1
  169. package/packages/dbos-cloud/dist/src/telemetry/exporters.d.ts +0 -15
  170. package/packages/dbos-cloud/dist/src/telemetry/exporters.d.ts.map +0 -1
  171. package/packages/dbos-cloud/dist/src/telemetry/exporters.js +0 -59
  172. package/packages/dbos-cloud/dist/src/telemetry/exporters.js.map +0 -1
  173. package/packages/dbos-cloud/dist/src/telemetry/index.d.ts +0 -11
  174. package/packages/dbos-cloud/dist/src/telemetry/index.d.ts.map +0 -1
  175. package/packages/dbos-cloud/dist/src/telemetry/index.js +0 -19
  176. package/packages/dbos-cloud/dist/src/telemetry/index.js.map +0 -1
  177. package/packages/dbos-cloud/dist/src/telemetry/logs.d.ts +0 -47
  178. package/packages/dbos-cloud/dist/src/telemetry/logs.d.ts.map +0 -1
  179. package/packages/dbos-cloud/dist/src/telemetry/logs.js +0 -195
  180. package/packages/dbos-cloud/dist/src/telemetry/logs.js.map +0 -1
  181. package/packages/dbos-cloud/dist/src/telemetry/traces.d.ts +0 -14
  182. package/packages/dbos-cloud/dist/src/telemetry/traces.d.ts.map +0 -1
  183. package/packages/dbos-cloud/dist/src/telemetry/traces.js +0 -52
  184. package/packages/dbos-cloud/dist/src/telemetry/traces.js.map +0 -1
  185. package/packages/dbos-cloud/dist/src/transaction.d.ts +0 -29
  186. package/packages/dbos-cloud/dist/src/transaction.d.ts.map +0 -1
  187. package/packages/dbos-cloud/dist/src/transaction.js +0 -27
  188. package/packages/dbos-cloud/dist/src/transaction.js.map +0 -1
  189. package/packages/dbos-cloud/dist/src/user_database.d.ts +0 -132
  190. package/packages/dbos-cloud/dist/src/user_database.d.ts.map +0 -1
  191. package/packages/dbos-cloud/dist/src/user_database.js +0 -332
  192. package/packages/dbos-cloud/dist/src/user_database.js.map +0 -1
  193. package/packages/dbos-cloud/dist/src/workflow.d.ts +0 -195
  194. package/packages/dbos-cloud/dist/src/workflow.d.ts.map +0 -1
  195. package/packages/dbos-cloud/dist/src/workflow.js +0 -498
  196. package/packages/dbos-cloud/dist/src/workflow.js.map +0 -1
@@ -1 +0,0 @@
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,EAKd,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/D,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,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,cAAc,EAAkD,MAAM,mBAAmB,CAAC;AAEnG,OAAO,EAGL,YAAY,EAEZ,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAA6E,MAAM,cAAc,CAAC;AAQjI,MAAM,WAAW,QAAQ;CAAI;AAC7B,eAAO,MAAM,QAAQ,EAAE,QAAa,CAAC;AACr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EG;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;IAgFjF;;OAEG;IACG,oBAAoB;IAQpB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgDhD,qBAAqB;CAatB"}
@@ -1,631 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DBOSExecutor = exports.OperationType = exports.DBOSExecutorIDHeader = exports.dbosNull = void 0;
7
- /* eslint-disable @typescript-eslint/no-explicit-any */
8
- const error_1 = require("./error");
9
- const workflow_1 = require("./workflow");
10
- const collector_1 = require("./telemetry/collector");
11
- const traces_1 = require("./telemetry/traces");
12
- const logs_1 = require("./telemetry/logs");
13
- const exporters_1 = require("./telemetry/exporters");
14
- const system_database_1 = require("./system_database");
15
- const uuid_1 = require("uuid");
16
- const user_database_1 = require("./user_database");
17
- const decorators_1 = require("./decorators");
18
- const api_1 = require("@opentelemetry/api");
19
- const knex_1 = __importDefault(require("knex"));
20
- const context_1 = require("./context");
21
- const debug_workflow_1 = require("./debugger/debug_workflow");
22
- const serialize_error_1 = require("serialize-error");
23
- exports.dbosNull = {};
24
- exports.DBOSExecutorIDHeader = "dbos-executor-id";
25
- exports.OperationType = {
26
- HANDLER: "handler",
27
- WORKFLOW: "workflow",
28
- TRANSACTION: "transaction",
29
- COMMUNICATOR: "communicator",
30
- };
31
- const TempWorkflowType = {
32
- transaction: "transaction",
33
- external: "external",
34
- send: "send",
35
- };
36
- class DBOSExecutor {
37
- config;
38
- initialized;
39
- // User Database
40
- userDatabase = null;
41
- // System Database
42
- systemDatabase;
43
- // Temporary workflows are created by calling transaction/send/recv directly from the executor class
44
- static tempWorkflowName = "temp_workflow";
45
- workflowInfoMap = new Map([
46
- // We initialize the map with an entry for temporary workflows.
47
- [
48
- DBOSExecutor.tempWorkflowName,
49
- {
50
- // eslint-disable-next-line @typescript-eslint/require-await
51
- workflow: async () => this.logger.error("UNREACHABLE: Indirect invoke of temp workflow"),
52
- config: {},
53
- },
54
- ],
55
- ]);
56
- transactionInfoMap = new Map();
57
- communicatorInfoMap = new Map();
58
- registeredOperations = [];
59
- pendingWorkflowMap = new Map(); // Map from workflowUUID to workflow promise
60
- workflowResultBuffer = new Map(); // Map from workflowUUID to its remaining result buffer.
61
- telemetryCollector;
62
- flushBufferIntervalMs = 1000;
63
- flushBufferID;
64
- static defaultNotificationTimeoutSec = 60;
65
- debugMode;
66
- static systemDBSchemaName = "dbos";
67
- logger;
68
- tracer;
69
- // eslint-disable-next-line @typescript-eslint/ban-types
70
- entities = [];
71
- /* WORKFLOW EXECUTOR LIFE CYCLE MANAGEMENT */
72
- constructor(config, systemDatabase) {
73
- this.config = config;
74
- this.debugMode = config.debugProxy ? true : false;
75
- if (config.telemetry?.OTLPExporter) {
76
- const OTLPExporter = new exporters_1.TelemetryExporter(config.telemetry.OTLPExporter);
77
- this.telemetryCollector = new collector_1.TelemetryCollector(OTLPExporter);
78
- }
79
- else {
80
- // We always an collector to drain the signals queue, even if we don't have an exporter.
81
- this.telemetryCollector = new collector_1.TelemetryCollector();
82
- }
83
- this.logger = new logs_1.GlobalLogger(this.telemetryCollector, this.config.telemetry?.logs);
84
- this.tracer = new traces_1.Tracer(this.telemetryCollector);
85
- if (this.debugMode) {
86
- this.logger.info("Running in debug mode!");
87
- try {
88
- const url = new URL(this.config.debugProxy);
89
- this.config.poolConfig.host = url.hostname;
90
- this.config.poolConfig.port = parseInt(url.port, 10);
91
- this.logger.info(`Debugging mode proxy: ${this.config.poolConfig.host}:${this.config.poolConfig.port}`);
92
- }
93
- catch (err) {
94
- this.logger.error(err);
95
- throw err;
96
- }
97
- }
98
- if (systemDatabase) {
99
- this.logger.debug("Using provided system database"); // XXX print the name or something
100
- this.systemDatabase = systemDatabase;
101
- }
102
- else {
103
- this.logger.debug("Using Postgres system database");
104
- this.systemDatabase = new system_database_1.PostgresSystemDatabase(this.config.poolConfig, this.config.system_database, this.logger);
105
- }
106
- this.flushBufferID = setInterval(() => {
107
- if (!this.debugMode) {
108
- void this.flushWorkflowBuffers();
109
- }
110
- }, this.flushBufferIntervalMs);
111
- this.logger.debug("Started workflow status buffer worker");
112
- this.initialized = false;
113
- }
114
- configureDbClient() {
115
- const userDbClient = this.config.userDbclient;
116
- const userDBConfig = this.config.poolConfig;
117
- if (userDbClient === user_database_1.UserDatabaseName.PRISMA) {
118
- // TODO: make Prisma work with debugger proxy.
119
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
120
- const { PrismaClient } = require("@prisma/client");
121
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
122
- this.userDatabase = new user_database_1.PrismaUserDatabase(new PrismaClient());
123
- this.logger.debug("Loaded Prisma user database");
124
- }
125
- else if (userDbClient === user_database_1.UserDatabaseName.TYPEORM) {
126
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
127
- const DataSourceExports = require("typeorm");
128
- try {
129
- this.userDatabase = new user_database_1.TypeORMDatabase(
130
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
131
- new DataSourceExports.DataSource({
132
- type: "postgres", // perhaps should move to config file
133
- host: userDBConfig.host,
134
- port: userDBConfig.port,
135
- username: userDBConfig.user,
136
- password: userDBConfig.password,
137
- database: userDBConfig.database,
138
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
139
- entities: this.entities,
140
- }));
141
- }
142
- catch (s) {
143
- s.message = `Error loading TypeORM user database: ${s.message}`;
144
- this.logger.error(s);
145
- }
146
- this.logger.debug("Loaded TypeORM user database");
147
- }
148
- else if (userDbClient === user_database_1.UserDatabaseName.KNEX) {
149
- const knexConfig = {
150
- client: "postgres",
151
- connection: {
152
- host: userDBConfig.host,
153
- port: userDBConfig.port,
154
- user: userDBConfig.user,
155
- password: userDBConfig.password,
156
- database: userDBConfig.database,
157
- ssl: userDBConfig.ssl,
158
- },
159
- };
160
- this.userDatabase = new user_database_1.KnexUserDatabase((0, knex_1.default)(knexConfig));
161
- this.logger.debug("Loaded Knex user database");
162
- }
163
- else {
164
- this.userDatabase = new user_database_1.PGNodeUserDatabase(userDBConfig);
165
- this.logger.debug("Loaded Postgres user database");
166
- }
167
- }
168
- #registerClass(cls) {
169
- const registeredClassOperations = (0, decorators_1.getRegisteredOperations)(cls);
170
- this.registeredOperations.push(...registeredClassOperations);
171
- for (const ro of registeredClassOperations) {
172
- if (ro.workflowConfig) {
173
- const wf = ro.registeredFunction;
174
- this.#registerWorkflow(wf, ro.workflowConfig);
175
- this.logger.debug(`Registered workflow ${ro.name}`);
176
- }
177
- else if (ro.txnConfig) {
178
- const tx = ro.registeredFunction;
179
- this.#registerTransaction(tx, ro.txnConfig);
180
- this.logger.debug(`Registered transaction ${ro.name}`);
181
- }
182
- else if (ro.commConfig) {
183
- const comm = ro.registeredFunction;
184
- this.#registerCommunicator(comm, ro.commConfig);
185
- this.logger.debug(`Registered communicator ${ro.name}`);
186
- }
187
- }
188
- }
189
- async init(...classes) {
190
- if (this.initialized) {
191
- this.logger.error("Workflow executor already initialized!");
192
- return;
193
- }
194
- try {
195
- for (const cls of classes) {
196
- const reg = (0, decorators_1.getOrCreateClassRegistration)(cls);
197
- if (reg.ormEntities.length > 0) {
198
- this.entities = this.entities.concat(reg.ormEntities);
199
- this.logger.debug(`Loaded ${reg.ormEntities.length} ORM entities`);
200
- }
201
- }
202
- this.configureDbClient();
203
- if (!this.userDatabase) {
204
- this.logger.error("No user database configured!");
205
- throw new error_1.DBOSInitializationError("No user database configured!");
206
- }
207
- for (const cls of classes) {
208
- this.#registerClass(cls);
209
- }
210
- // Debug mode doesn't need to initialize the DBs. Everything should appear to be read-only.
211
- await this.userDatabase.init(this.debugMode);
212
- if (!this.debugMode) {
213
- await this.systemDatabase.init();
214
- await this.recoverPendingWorkflows();
215
- }
216
- }
217
- catch (err) {
218
- err.message = `failed to initialize workflow executor: ${err.message}`;
219
- this.logger.error(err);
220
- throw new error_1.DBOSInitializationError(`${err.message}`);
221
- }
222
- this.initialized = true;
223
- // Only execute init code if under non-debug mode
224
- if (!this.debugMode) {
225
- for (const v of this.registeredOperations) {
226
- const m = v;
227
- if (m.init === true) {
228
- this.logger.debug("Executing init method: " + m.name);
229
- await m.origFunction(new context_1.InitContext(this));
230
- }
231
- }
232
- }
233
- this.logger.info("Workflow executor initialized");
234
- }
235
- async destroy() {
236
- if (this.pendingWorkflowMap.size > 0) {
237
- this.logger.info("Waiting for pending workflows to finish.");
238
- await Promise.allSettled(this.pendingWorkflowMap.values());
239
- }
240
- clearInterval(this.flushBufferID);
241
- await this.flushWorkflowBuffers();
242
- await this.systemDatabase.destroy();
243
- await this.userDatabase.destroy();
244
- await this.telemetryCollector.destroy();
245
- }
246
- /* WORKFLOW OPERATIONS */
247
- #registerWorkflow(wf, config = {}) {
248
- if (wf.name === DBOSExecutor.tempWorkflowName || this.workflowInfoMap.has(wf.name)) {
249
- throw new error_1.DBOSError(`Repeated workflow name: ${wf.name}`);
250
- }
251
- const workflowInfo = {
252
- workflow: wf,
253
- config: config,
254
- };
255
- this.workflowInfoMap.set(wf.name, workflowInfo);
256
- }
257
- #registerTransaction(txn, params = {}) {
258
- if (this.transactionInfoMap.has(txn.name)) {
259
- throw new error_1.DBOSError(`Repeated Transaction name: ${txn.name}`);
260
- }
261
- const txnInfo = {
262
- transaction: txn,
263
- config: params,
264
- };
265
- this.transactionInfoMap.set(txn.name, txnInfo);
266
- }
267
- #registerCommunicator(comm, params = {}) {
268
- if (this.communicatorInfoMap.has(comm.name)) {
269
- throw new error_1.DBOSError(`Repeated Commmunicator name: ${comm.name}`);
270
- }
271
- const commInfo = {
272
- communicator: comm,
273
- config: params,
274
- };
275
- this.communicatorInfoMap.set(comm.name, commInfo);
276
- }
277
- async workflow(wf, params, ...args) {
278
- if (this.debugMode) {
279
- return this.debugWorkflow(wf, params, undefined, undefined, ...args);
280
- }
281
- return this.internalWorkflow(wf, params, undefined, undefined, ...args);
282
- }
283
- // If callerUUID and functionID are set, it means the workflow is invoked from within a workflow.
284
- async internalWorkflow(wf, params, callerUUID, callerFunctionID, ...args) {
285
- const workflowUUID = params.workflowUUID ? params.workflowUUID : this.#generateUUID();
286
- const presetUUID = params.workflowUUID ? true : false;
287
- const wInfo = this.workflowInfoMap.get(wf.name);
288
- if (wInfo === undefined) {
289
- throw new error_1.DBOSNotRegisteredError(wf.name);
290
- }
291
- const wConfig = wInfo.config;
292
- const wCtxt = new workflow_1.WorkflowContextImpl(this, params.parentCtx, workflowUUID, wConfig, wf.name, presetUUID);
293
- // This is to accomodate the testing runtime, that does not go through HTTP handlers to start workflows
294
- // Ideally we would expose the executorID to the environment instead of propagating it through headers.
295
- if (wCtxt.executorID === 'local' && wCtxt.request.headers && wCtxt.request.headers[exports.DBOSExecutorIDHeader]) {
296
- wCtxt.executorID = wCtxt.request.headers[exports.DBOSExecutorIDHeader];
297
- }
298
- const internalStatus = {
299
- workflowUUID: workflowUUID,
300
- status: workflow_1.StatusString.PENDING,
301
- name: wf.name,
302
- authenticatedUser: wCtxt.authenticatedUser,
303
- output: undefined,
304
- error: "",
305
- assumedRole: wCtxt.assumedRole,
306
- authenticatedRoles: wCtxt.authenticatedRoles,
307
- request: wCtxt.request,
308
- executorID: wCtxt.executorID,
309
- };
310
- // Synchronously set the workflow's status to PENDING and record workflow inputs.
311
- if (!wCtxt.isTempWorkflow) {
312
- args = await this.systemDatabase.initWorkflowStatus(internalStatus, args);
313
- }
314
- else {
315
- // For temporary workflows, instead asynchronously record inputs.
316
- this.systemDatabase.bufferWorkflowInputs(workflowUUID, args);
317
- }
318
- const runWorkflow = async () => {
319
- let result;
320
- // Execute the workflow.
321
- try {
322
- result = await wf(wCtxt, ...args);
323
- if (wCtxt.isTempWorkflow) {
324
- internalStatus.name = `${DBOSExecutor.tempWorkflowName}-${wCtxt.tempWfOperationType}-${wCtxt.tempWfOperationName}`;
325
- }
326
- internalStatus.output = result;
327
- internalStatus.status = workflow_1.StatusString.SUCCESS;
328
- this.systemDatabase.bufferWorkflowOutput(workflowUUID, internalStatus);
329
- wCtxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
330
- }
331
- catch (err) {
332
- if (err instanceof error_1.DBOSWorkflowConflictUUIDError) {
333
- // Retrieve the handle and wait for the result.
334
- const retrievedHandle = this.retrieveWorkflow(workflowUUID);
335
- result = await retrievedHandle.getResult();
336
- wCtxt.span.setAttribute("cached", true);
337
- wCtxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
338
- }
339
- else {
340
- // Record the error.
341
- const e = err;
342
- this.logger.error(e);
343
- if (wCtxt.isTempWorkflow) {
344
- internalStatus.name = `${DBOSExecutor.tempWorkflowName}-${wCtxt.tempWfOperationType}-${wCtxt.tempWfOperationName}`;
345
- }
346
- internalStatus.error = JSON.stringify((0, serialize_error_1.serializeError)(e));
347
- internalStatus.status = workflow_1.StatusString.ERROR;
348
- await this.systemDatabase.recordWorkflowError(workflowUUID, internalStatus);
349
- // TODO: Log errors, but not in the tests when they're expected.
350
- wCtxt.span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e.message });
351
- throw err;
352
- }
353
- }
354
- finally {
355
- this.tracer.endSpan(wCtxt.span);
356
- }
357
- // Asynchronously flush the result buffer.
358
- if (wCtxt.resultBuffer.size > 0) {
359
- this.workflowResultBuffer.set(wCtxt.workflowUUID, wCtxt.resultBuffer);
360
- }
361
- return result;
362
- };
363
- const workflowPromise = runWorkflow();
364
- // Need to await for the workflow and capture errors.
365
- const awaitWorkflowPromise = workflowPromise
366
- .catch((error) => {
367
- this.logger.debug("Captured error in awaitWorkflowPromise: " + error);
368
- })
369
- .finally(() => {
370
- // Remove itself from pending workflow map.
371
- this.pendingWorkflowMap.delete(workflowUUID);
372
- });
373
- this.pendingWorkflowMap.set(workflowUUID, awaitWorkflowPromise);
374
- // Return the normal handle that doesn't capture errors.
375
- return new workflow_1.InvokedHandle(this.systemDatabase, workflowPromise, workflowUUID, wf.name, callerUUID, callerFunctionID);
376
- }
377
- /**
378
- * DEBUG MODE workflow execution, skipping all the recording
379
- */
380
- // eslint-disable-next-line @typescript-eslint/require-await
381
- async debugWorkflow(wf, params, callerUUID, callerFunctionID, ...args) {
382
- // In debug mode, we must have a specific workflow UUID.
383
- if (!params.workflowUUID) {
384
- throw new error_1.DBOSDebuggerError("Workflow UUID not found!");
385
- }
386
- const workflowUUID = params.workflowUUID;
387
- const wInfo = this.workflowInfoMap.get(wf.name);
388
- if (wInfo === undefined) {
389
- throw new error_1.DBOSDebuggerError("Workflow unregistered! " + wf.name);
390
- }
391
- const wConfig = wInfo.config;
392
- const wCtxt = new debug_workflow_1.WorkflowContextDebug(this, params.parentCtx, workflowUUID, wConfig, wf.name);
393
- // A workflow must have run before.
394
- const wfStatus = await this.systemDatabase.getWorkflowStatus(workflowUUID);
395
- const recordedInputs = await this.systemDatabase.getWorkflowInputs(workflowUUID);
396
- if (!wfStatus || !recordedInputs) {
397
- throw new error_1.DBOSDebuggerError("Workflow status or inputs not found! UUID: " + workflowUUID);
398
- }
399
- // Make sure we use the same input.
400
- if (JSON.stringify(args) !== JSON.stringify(recordedInputs)) {
401
- throw new error_1.DBOSDebuggerError(`Detect different input for the workflow UUID ${workflowUUID}!\n Received: ${JSON.stringify(args)}\n Original: ${JSON.stringify(recordedInputs)}`);
402
- }
403
- const workflowPromise = wf(wCtxt, ...args)
404
- .then(async (result) => {
405
- // Check if the result is the same.
406
- const recordedResult = await this.systemDatabase.getWorkflowResult(workflowUUID);
407
- if (result === undefined && !recordedResult) {
408
- return result;
409
- }
410
- if (JSON.stringify(result) !== JSON.stringify(recordedResult)) {
411
- this.logger.error(`Detect different output for the workflow UUID ${workflowUUID}!\n Received: ${JSON.stringify(result)}\n Original: ${JSON.stringify(recordedResult)}`);
412
- }
413
- return recordedResult; // Always return the recorded result.
414
- });
415
- return new workflow_1.InvokedHandle(this.systemDatabase, workflowPromise, workflowUUID, wf.name, callerUUID, callerFunctionID);
416
- }
417
- async transaction(txn, params, ...args) {
418
- // Create a workflow and call transaction.
419
- const temp_workflow = async (ctxt, ...args) => {
420
- const ctxtImpl = ctxt;
421
- ctxtImpl.tempWfOperationType = TempWorkflowType.transaction;
422
- ctxtImpl.tempWfOperationName = txn.name;
423
- return await ctxtImpl.transaction(txn, ...args);
424
- };
425
- return (await this.workflow(temp_workflow, params, ...args)).getResult();
426
- }
427
- async external(commFn, params, ...args) {
428
- // Create a workflow and call external.
429
- const temp_workflow = async (ctxt, ...args) => {
430
- const ctxtImpl = ctxt;
431
- ctxtImpl.tempWfOperationType = TempWorkflowType.external;
432
- ctxtImpl.tempWfOperationName = commFn.name;
433
- return await ctxtImpl.external(commFn, ...args);
434
- };
435
- return (await this.workflow(temp_workflow, params, ...args)).getResult();
436
- }
437
- async send(destinationUUID, message, topic, idempotencyKey) {
438
- // Create a workflow and call send.
439
- const temp_workflow = async (ctxt, destinationUUID, message, topic) => {
440
- const ctxtImpl = ctxt;
441
- ctxtImpl.tempWfOperationType = TempWorkflowType.send;
442
- return await ctxt.send(destinationUUID, message, topic);
443
- };
444
- const workflowUUID = idempotencyKey ? destinationUUID + idempotencyKey : undefined;
445
- return (await this.workflow(temp_workflow, { workflowUUID: workflowUUID }, destinationUUID, message, topic)).getResult();
446
- }
447
- /**
448
- * Wait for a workflow to emit an event, then return its value.
449
- */
450
- async getEvent(workflowUUID, key, timeoutSeconds = DBOSExecutor.defaultNotificationTimeoutSec) {
451
- return this.systemDatabase.getEvent(workflowUUID, key, timeoutSeconds);
452
- }
453
- /**
454
- * Retrieve a handle for a workflow UUID.
455
- */
456
- retrieveWorkflow(workflowUUID) {
457
- return new workflow_1.RetrievedHandle(this.systemDatabase, workflowUUID);
458
- }
459
- /* INTERNAL HELPERS */
460
- #generateUUID() {
461
- return (0, uuid_1.v4)();
462
- }
463
- /**
464
- * A recovery process that by default runs during executor init time.
465
- * It runs to completion all pending workflows that were executing when the previous executor failed.
466
- */
467
- async recoverPendingWorkflows(executorIDs = ["local"]) {
468
- const pendingWorkflows = [];
469
- for (const execID of executorIDs) {
470
- this.logger.debug(`Recovering workflows of executor: ${execID}`);
471
- const wIDs = await this.systemDatabase.getPendingWorkflows(execID);
472
- pendingWorkflows.push(...wIDs);
473
- }
474
- const handlerArray = [];
475
- for (const workflowUUID of pendingWorkflows) {
476
- try {
477
- handlerArray.push(await this.executeWorkflowUUID(workflowUUID));
478
- }
479
- catch (e) {
480
- this.logger.warn(`Recovery of workflow ${workflowUUID} failed: ${e.message}`);
481
- }
482
- }
483
- return handlerArray;
484
- }
485
- async executeWorkflowUUID(workflowUUID) {
486
- const wfStatus = await this.systemDatabase.getWorkflowStatus(workflowUUID);
487
- const inputs = await this.systemDatabase.getWorkflowInputs(workflowUUID);
488
- if (!inputs || !wfStatus) {
489
- this.logger.error(`Failed to find inputs for workflowUUID: ${workflowUUID}`);
490
- throw new error_1.DBOSError(`Failed to find inputs for workflow UUID: ${workflowUUID}`);
491
- }
492
- const parentCtx = this.#getRecoveryContext(workflowUUID, wfStatus);
493
- const wfInfo = this.workflowInfoMap.get(wfStatus.workflowName);
494
- if (wfInfo) {
495
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
496
- return this.workflow(wfInfo.workflow, { workflowUUID: workflowUUID, parentCtx: parentCtx ?? undefined }, ...inputs);
497
- }
498
- // Should be temporary workflows. Parse the name of the workflow.
499
- const wfName = wfStatus.workflowName;
500
- const nameArr = wfName.split("-");
501
- if (!nameArr[0].startsWith(DBOSExecutor.tempWorkflowName)) {
502
- throw new error_1.DBOSError(`This should never happen! Cannot find workflow info for a non-temporary workflow! UUID ${workflowUUID}, name ${wfName}`);
503
- }
504
- let temp_workflow;
505
- if (nameArr[1] === TempWorkflowType.transaction) {
506
- const txnInfo = this.transactionInfoMap.get(nameArr[2]);
507
- if (!txnInfo) {
508
- throw new error_1.DBOSError(`Cannot find transaction info for UUID ${workflowUUID}, name ${wfName}`);
509
- }
510
- temp_workflow = async (ctxt, ...args) => {
511
- const ctxtImpl = ctxt;
512
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument
513
- return await ctxtImpl.transaction(txnInfo.transaction, ...args);
514
- };
515
- }
516
- else if (nameArr[1] === TempWorkflowType.external) {
517
- const commInfo = this.communicatorInfoMap.get(nameArr[2]);
518
- if (!commInfo) {
519
- throw new error_1.DBOSError(`Cannot find transaction info for UUID ${workflowUUID}, name ${wfName}`);
520
- }
521
- temp_workflow = async (ctxt, ...args) => {
522
- const ctxtImpl = ctxt;
523
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument
524
- return await ctxtImpl.external(commInfo.communicator, ...args);
525
- };
526
- }
527
- else if (nameArr[1] === TempWorkflowType.send) {
528
- temp_workflow = async (ctxt, ...args) => {
529
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
530
- return await ctxt.send(args[0], args[1], args[2]);
531
- };
532
- }
533
- else {
534
- throw new error_1.DBOSError(`Unrecognized temporary workflow! UUID ${workflowUUID}, name ${wfName}`);
535
- }
536
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
537
- return this.workflow(temp_workflow, { workflowUUID: workflowUUID, parentCtx: parentCtx ?? undefined }, ...inputs);
538
- }
539
- #getRecoveryContext(workflowUUID, status) {
540
- const executorID = status.request.headers && status.request.headers[exports.DBOSExecutorIDHeader] ? status.request.headers[exports.DBOSExecutorIDHeader] : "local";
541
- const span = this.tracer.startSpan(status.workflowName, {
542
- operationUUID: workflowUUID,
543
- operationType: exports.OperationType.WORKFLOW,
544
- status: status.status,
545
- authenticatedUser: status.authenticatedUser,
546
- assumedRole: status.assumedRole,
547
- authenticatedRoles: status.authenticatedRoles,
548
- executorID: executorID,
549
- });
550
- const oc = new context_1.DBOSContextImpl(status.workflowName, span, this.logger);
551
- oc.request = status.request;
552
- oc.authenticatedUser = status.authenticatedUser;
553
- oc.authenticatedRoles = status.authenticatedRoles;
554
- oc.assumedRole = status.assumedRole;
555
- oc.workflowUUID = workflowUUID;
556
- return oc;
557
- }
558
- /* BACKGROUND PROCESSES */
559
- /**
560
- * Periodically flush the workflow output buffer to the system database.
561
- */
562
- async flushWorkflowBuffers() {
563
- if (this.initialized) {
564
- await this.systemDatabase.flushWorkflowInputsBuffer();
565
- await this.flushWorkflowResultBuffer();
566
- await this.systemDatabase.flushWorkflowStatusBuffer();
567
- }
568
- }
569
- async flushWorkflowResultBuffer() {
570
- const localBuffer = new Map(this.workflowResultBuffer);
571
- this.workflowResultBuffer.clear();
572
- const totalSize = localBuffer.size;
573
- const flushBatchSize = 50;
574
- try {
575
- let finishedCnt = 0;
576
- while (finishedCnt < totalSize) {
577
- let sqlStmt = "INSERT INTO dbos.transaction_outputs (workflow_uuid, function_id, output, error, txn_id, txn_snapshot) VALUES ";
578
- let paramCnt = 1;
579
- const values = [];
580
- const batchUUIDs = [];
581
- for (const [workflowUUID, wfBuffer] of localBuffer) {
582
- for (const [funcID, recorded] of wfBuffer) {
583
- const output = recorded.output;
584
- const txnSnapshot = recorded.txn_snapshot;
585
- if (paramCnt > 1) {
586
- sqlStmt += ", ";
587
- }
588
- sqlStmt += `($${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, null, $${paramCnt++})`;
589
- values.push(workflowUUID, funcID, JSON.stringify(output), JSON.stringify(null), txnSnapshot);
590
- }
591
- batchUUIDs.push(workflowUUID);
592
- finishedCnt++;
593
- if (batchUUIDs.length >= flushBatchSize) {
594
- // Cap at the batch size.
595
- break;
596
- }
597
- }
598
- this.logger.debug(sqlStmt);
599
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
600
- await this.userDatabase.query(sqlStmt, ...values);
601
- // Clean up after each batch succeeds
602
- batchUUIDs.forEach((value) => { localBuffer.delete(value); });
603
- }
604
- }
605
- catch (error) {
606
- error.message = `Error flushing workflow result buffer: ${error.message}`;
607
- this.logger.error(error);
608
- // If there is a failure in flushing the buffer, return items to the global buffer for retrying later.
609
- for (const [workflowUUID, wfBuffer] of localBuffer) {
610
- if (!this.workflowResultBuffer.has(workflowUUID)) {
611
- this.workflowResultBuffer.set(workflowUUID, wfBuffer);
612
- }
613
- }
614
- }
615
- }
616
- logRegisteredHTTPUrls() {
617
- this.logger.info("HTTP endpoints supported:");
618
- this.registeredOperations.forEach((registeredOperation) => {
619
- const ro = registeredOperation;
620
- if (ro.apiURL) {
621
- this.logger.info(" " + ro.apiType.padEnd(4) + " : " + ro.apiURL);
622
- const roles = ro.getRequiredRoles();
623
- if (roles.length > 0) {
624
- this.logger.info(" Required Roles: " + JSON.stringify(roles));
625
- }
626
- }
627
- });
628
- }
629
- }
630
- exports.DBOSExecutor = DBOSExecutor;
631
- //# sourceMappingURL=dbos-executor.js.map