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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) 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/cli.js +0 -12
  20. package/dist/packages/dbos-cloud/cli.js.map +1 -1
  21. package/dist/packages/dbos-cloud/cloudutils.d.ts +7 -0
  22. package/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
  23. package/dist/packages/dbos-cloud/cloudutils.js +44 -3
  24. package/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
  25. package/dist/packages/dbos-cloud/login.d.ts.map +1 -1
  26. package/dist/packages/dbos-cloud/login.js +3 -4
  27. package/dist/packages/dbos-cloud/login.js.map +1 -1
  28. package/dist/packages/dbos-cloud/register.d.ts.map +1 -1
  29. package/dist/packages/dbos-cloud/register.js +1 -2
  30. package/dist/packages/dbos-cloud/register.js.map +1 -1
  31. package/dist/packages/dbos-cloud/userdb.d.ts +0 -2
  32. package/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
  33. package/dist/packages/dbos-cloud/userdb.js +4 -177
  34. package/dist/packages/dbos-cloud/userdb.js.map +1 -1
  35. package/dist/src/context.d.ts +1 -0
  36. package/dist/src/context.d.ts.map +1 -1
  37. package/dist/src/dbos-runtime/cli.d.ts.map +1 -1
  38. package/dist/src/dbos-runtime/cli.js +14 -0
  39. package/dist/src/dbos-runtime/cli.js.map +1 -1
  40. package/dist/src/dbos-runtime/migrate.d.ts +3 -0
  41. package/dist/src/dbos-runtime/migrate.d.ts.map +1 -0
  42. package/dist/src/dbos-runtime/migrate.js +175 -0
  43. package/dist/src/dbos-runtime/migrate.js.map +1 -0
  44. package/dist/src/httpServer/server.d.ts +2 -1
  45. package/dist/src/httpServer/server.d.ts.map +1 -1
  46. package/dist/src/system_database.d.ts +2 -0
  47. package/dist/src/system_database.d.ts.map +1 -1
  48. package/dist/src/system_database.js +26 -11
  49. package/dist/src/system_database.js.map +1 -1
  50. package/dist/src/testing/testing_runtime.d.ts +2 -1
  51. package/dist/src/testing/testing_runtime.d.ts.map +1 -1
  52. package/dist/src/utils.d.ts +1 -1
  53. package/dist/src/utils.d.ts.map +1 -1
  54. package/dist/src/utils.js +20 -4
  55. package/dist/src/utils.js.map +1 -1
  56. package/dist/tsconfig.build.tsbuildinfo +1 -1
  57. package/examples/hello/start_postgres_docker.sh +1 -1
  58. package/migrations/20240123182943_schema.js +8 -0
  59. package/migrations/20240123183021_tables.js +48 -0
  60. package/migrations/20240123183025_indexes.js +14 -0
  61. package/migrations/20240123183030_triggers.js +39 -0
  62. package/package.json +1 -1
  63. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.d.ts.map +1 -1
  64. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.js +1 -2
  65. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.js.map +1 -1
  66. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts.map +1 -1
  67. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.js +5 -7
  68. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.js.map +1 -1
  69. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.d.ts.map +1 -1
  70. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.js +1 -2
  71. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.js.map +1 -1
  72. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +1 -1
  73. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.js +1 -2
  74. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.js.map +1 -1
  75. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.d.ts.map +1 -1
  76. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.js +1 -2
  77. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.js.map +1 -1
  78. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.d.ts.map +1 -1
  79. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.js +1 -2
  80. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.js.map +1 -1
  81. package/packages/dbos-cloud/dist/packages/dbos-cloud/cli.js +0 -12
  82. package/packages/dbos-cloud/dist/packages/dbos-cloud/cli.js.map +1 -1
  83. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.d.ts +7 -0
  84. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
  85. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.js +44 -3
  86. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
  87. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.d.ts.map +1 -1
  88. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.js +3 -4
  89. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.js.map +1 -1
  90. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.d.ts.map +1 -1
  91. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.js +1 -2
  92. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.js.map +1 -1
  93. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.d.ts +0 -2
  94. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
  95. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.js +4 -177
  96. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.js.map +1 -1
  97. package/packages/dbos-cloud/dist/src/utils.d.ts +1 -1
  98. package/packages/dbos-cloud/dist/src/utils.d.ts.map +1 -1
  99. package/packages/dbos-cloud/dist/src/utils.js +20 -4
  100. package/packages/dbos-cloud/dist/src/utils.js.map +1 -1
  101. package/packages/dbos-cloud/package.json +1 -1
  102. package/packages/dbos-openapi/package.json +1 -1
  103. package/packages/dbos-cloud/dist/schemas/system_db_schema.d.ts +0 -34
  104. package/packages/dbos-cloud/dist/schemas/system_db_schema.d.ts.map +0 -1
  105. package/packages/dbos-cloud/dist/schemas/system_db_schema.js +0 -77
  106. package/packages/dbos-cloud/dist/schemas/system_db_schema.js.map +0 -1
  107. package/packages/dbos-cloud/dist/schemas/user_db_schema.d.ts +0 -11
  108. package/packages/dbos-cloud/dist/schemas/user_db_schema.d.ts.map +0 -1
  109. package/packages/dbos-cloud/dist/schemas/user_db_schema.js +0 -16
  110. package/packages/dbos-cloud/dist/schemas/user_db_schema.js.map +0 -1
  111. package/packages/dbos-cloud/dist/src/communicator.d.ts +0 -25
  112. package/packages/dbos-cloud/dist/src/communicator.d.ts.map +0 -1
  113. package/packages/dbos-cloud/dist/src/communicator.js +0 -26
  114. package/packages/dbos-cloud/dist/src/communicator.js.map +0 -1
  115. package/packages/dbos-cloud/dist/src/context.d.ts +0 -64
  116. package/packages/dbos-cloud/dist/src/context.d.ts.map +0 -1
  117. package/packages/dbos-cloud/dist/src/context.js +0 -96
  118. package/packages/dbos-cloud/dist/src/context.js.map +0 -1
  119. package/packages/dbos-cloud/dist/src/data_validation.d.ts +0 -3
  120. package/packages/dbos-cloud/dist/src/data_validation.d.ts.map +0 -1
  121. package/packages/dbos-cloud/dist/src/data_validation.js +0 -168
  122. package/packages/dbos-cloud/dist/src/data_validation.js.map +0 -1
  123. package/packages/dbos-cloud/dist/src/dbos-executor.d.ts +0 -102
  124. package/packages/dbos-cloud/dist/src/dbos-executor.d.ts.map +0 -1
  125. package/packages/dbos-cloud/dist/src/dbos-executor.js +0 -631
  126. package/packages/dbos-cloud/dist/src/dbos-executor.js.map +0 -1
  127. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.d.ts +0 -3
  128. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.d.ts.map +0 -1
  129. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.js +0 -13
  130. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.js.map +0 -1
  131. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.d.ts +0 -8
  132. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.d.ts.map +0 -1
  133. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.js +0 -47
  134. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.js.map +0 -1
  135. package/packages/dbos-cloud/dist/src/dbos-runtime/config.d.ts +0 -29
  136. package/packages/dbos-cloud/dist/src/dbos-runtime/config.d.ts.map +0 -1
  137. package/packages/dbos-cloud/dist/src/dbos-runtime/config.js +0 -111
  138. package/packages/dbos-cloud/dist/src/dbos-runtime/config.js.map +0 -1
  139. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.d.ts +0 -4
  140. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.d.ts.map +0 -1
  141. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.js +0 -21
  142. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.js.map +0 -1
  143. package/packages/dbos-cloud/dist/src/dbos-runtime/init.d.ts +0 -7
  144. package/packages/dbos-cloud/dist/src/dbos-runtime/init.d.ts.map +0 -1
  145. package/packages/dbos-cloud/dist/src/dbos-runtime/init.js +0 -51
  146. package/packages/dbos-cloud/dist/src/dbos-runtime/init.js.map +0 -1
  147. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.d.ts +0 -28
  148. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.d.ts.map +0 -1
  149. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.js +0 -95
  150. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.js.map +0 -1
  151. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.d.ts +0 -38
  152. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.d.ts.map +0 -1
  153. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.js +0 -211
  154. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.js.map +0 -1
  155. package/packages/dbos-cloud/dist/src/decorators.d.ts +0 -118
  156. package/packages/dbos-cloud/dist/src/decorators.d.ts.map +0 -1
  157. package/packages/dbos-cloud/dist/src/decorators.js +0 -467
  158. package/packages/dbos-cloud/dist/src/decorators.js.map +0 -1
  159. package/packages/dbos-cloud/dist/src/error.d.ts +0 -47
  160. package/packages/dbos-cloud/dist/src/error.d.ts.map +0 -1
  161. package/packages/dbos-cloud/dist/src/error.js +0 -171
  162. package/packages/dbos-cloud/dist/src/error.js.map +0 -1
  163. package/packages/dbos-cloud/dist/src/httpServer/handler.d.ts +0 -54
  164. package/packages/dbos-cloud/dist/src/httpServer/handler.d.ts.map +0 -1
  165. package/packages/dbos-cloud/dist/src/httpServer/handler.js +0 -175
  166. package/packages/dbos-cloud/dist/src/httpServer/handler.js.map +0 -1
  167. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.d.ts +0 -11
  168. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.d.ts.map +0 -1
  169. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.js +0 -19
  170. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.js.map +0 -1
  171. package/packages/dbos-cloud/dist/src/httpServer/middleware.d.ts +0 -56
  172. package/packages/dbos-cloud/dist/src/httpServer/middleware.d.ts.map +0 -1
  173. package/packages/dbos-cloud/dist/src/httpServer/middleware.js +0 -57
  174. package/packages/dbos-cloud/dist/src/httpServer/middleware.js.map +0 -1
  175. package/packages/dbos-cloud/dist/src/httpServer/server.d.ts +0 -45
  176. package/packages/dbos-cloud/dist/src/httpServer/server.d.ts.map +0 -1
  177. package/packages/dbos-cloud/dist/src/httpServer/server.js +0 -253
  178. package/packages/dbos-cloud/dist/src/httpServer/server.js.map +0 -1
  179. package/packages/dbos-cloud/dist/src/system_database.d.ts +0 -89
  180. package/packages/dbos-cloud/dist/src/system_database.d.ts.map +0 -1
  181. package/packages/dbos-cloud/dist/src/system_database.js +0 -447
  182. package/packages/dbos-cloud/dist/src/system_database.js.map +0 -1
  183. package/packages/dbos-cloud/dist/src/telemetry/collector.d.ts +0 -16
  184. package/packages/dbos-cloud/dist/src/telemetry/collector.d.ts.map +0 -1
  185. package/packages/dbos-cloud/dist/src/telemetry/collector.js +0 -65
  186. package/packages/dbos-cloud/dist/src/telemetry/collector.js.map +0 -1
  187. package/packages/dbos-cloud/dist/src/telemetry/exporters.d.ts +0 -15
  188. package/packages/dbos-cloud/dist/src/telemetry/exporters.d.ts.map +0 -1
  189. package/packages/dbos-cloud/dist/src/telemetry/exporters.js +0 -59
  190. package/packages/dbos-cloud/dist/src/telemetry/exporters.js.map +0 -1
  191. package/packages/dbos-cloud/dist/src/telemetry/index.d.ts +0 -11
  192. package/packages/dbos-cloud/dist/src/telemetry/index.d.ts.map +0 -1
  193. package/packages/dbos-cloud/dist/src/telemetry/index.js +0 -19
  194. package/packages/dbos-cloud/dist/src/telemetry/index.js.map +0 -1
  195. package/packages/dbos-cloud/dist/src/telemetry/logs.d.ts +0 -47
  196. package/packages/dbos-cloud/dist/src/telemetry/logs.d.ts.map +0 -1
  197. package/packages/dbos-cloud/dist/src/telemetry/logs.js +0 -195
  198. package/packages/dbos-cloud/dist/src/telemetry/logs.js.map +0 -1
  199. package/packages/dbos-cloud/dist/src/telemetry/traces.d.ts +0 -14
  200. package/packages/dbos-cloud/dist/src/telemetry/traces.d.ts.map +0 -1
  201. package/packages/dbos-cloud/dist/src/telemetry/traces.js +0 -52
  202. package/packages/dbos-cloud/dist/src/telemetry/traces.js.map +0 -1
  203. package/packages/dbos-cloud/dist/src/transaction.d.ts +0 -29
  204. package/packages/dbos-cloud/dist/src/transaction.d.ts.map +0 -1
  205. package/packages/dbos-cloud/dist/src/transaction.js +0 -27
  206. package/packages/dbos-cloud/dist/src/transaction.js.map +0 -1
  207. package/packages/dbos-cloud/dist/src/user_database.d.ts +0 -132
  208. package/packages/dbos-cloud/dist/src/user_database.d.ts.map +0 -1
  209. package/packages/dbos-cloud/dist/src/user_database.js +0 -332
  210. package/packages/dbos-cloud/dist/src/user_database.js.map +0 -1
  211. package/packages/dbos-cloud/dist/src/workflow.d.ts +0 -195
  212. package/packages/dbos-cloud/dist/src/workflow.d.ts.map +0 -1
  213. package/packages/dbos-cloud/dist/src/workflow.js +0 -498
  214. package/packages/dbos-cloud/dist/src/workflow.js.map +0 -1
@@ -1,447 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PostgresSystemDatabase = void 0;
5
- const serialize_error_1 = require("serialize-error");
6
- const dbos_executor_1 = require("./dbos-executor");
7
- const pg_1 = require("pg");
8
- const error_1 = require("./error");
9
- const workflow_1 = require("./workflow");
10
- const system_db_schema_1 = require("../schemas/system_db_schema");
11
- const utils_1 = require("./utils");
12
- class PostgresSystemDatabase {
13
- pgPoolConfig;
14
- systemDatabaseName;
15
- logger;
16
- pool;
17
- notificationsClient = null;
18
- notificationsMap = {};
19
- workflowEventsMap = {};
20
- workflowStatusBuffer = new Map();
21
- workflowInputsBuffer = new Map();
22
- flushBatchSize = 100;
23
- constructor(pgPoolConfig, systemDatabaseName, logger) {
24
- this.pgPoolConfig = pgPoolConfig;
25
- this.systemDatabaseName = systemDatabaseName;
26
- this.logger = logger;
27
- const poolConfig = { ...pgPoolConfig };
28
- poolConfig.database = systemDatabaseName;
29
- this.pool = new pg_1.Pool(poolConfig);
30
- }
31
- async init() {
32
- const pgSystemClient = new pg_1.Client(this.pgPoolConfig);
33
- await pgSystemClient.connect();
34
- // Create the system database and load tables.
35
- const dbExists = await pgSystemClient.query(`SELECT EXISTS (SELECT FROM pg_database WHERE datname = '${this.systemDatabaseName}')`);
36
- if (!dbExists.rows[0].exists) {
37
- // Create the DBOS system database.
38
- await pgSystemClient.query(`CREATE DATABASE "${this.systemDatabaseName}"`);
39
- }
40
- // Check if the system schema exist.
41
- const schemaExists = await this.pool.query(`SELECT EXISTS (SELECT FROM information_schema.schemata WHERE schema_name = '${dbos_executor_1.DBOSExecutor.systemDBSchemaName}')`);
42
- if (!schemaExists.rows[0].exists) {
43
- // Load the DBOS system schemas.
44
- await this.pool.query(system_db_schema_1.systemDBSchema);
45
- }
46
- await this.listenForNotifications();
47
- await pgSystemClient.end();
48
- }
49
- async destroy() {
50
- if (this.notificationsClient) {
51
- this.notificationsClient.removeAllListeners();
52
- this.notificationsClient.release();
53
- }
54
- await this.pool.end();
55
- }
56
- async checkWorkflowOutput(workflowUUID) {
57
- const { rows } = await this.pool.query(`SELECT status, output, error FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status WHERE workflow_uuid=$1`, [workflowUUID]);
58
- if (rows.length === 0 || rows[0].status === workflow_1.StatusString.PENDING) {
59
- return dbos_executor_1.dbosNull;
60
- }
61
- else if (rows[0].status === workflow_1.StatusString.ERROR) {
62
- throw (0, serialize_error_1.deserializeError)(JSON.parse(rows[0].error));
63
- }
64
- else {
65
- return JSON.parse(rows[0].output);
66
- }
67
- }
68
- async initWorkflowStatus(initStatus, args) {
69
- await this.pool.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status (workflow_uuid, status, name, authenticated_user, assumed_role, authenticated_roles, request, output, executor_id) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (workflow_uuid) DO NOTHING`, [initStatus.workflowUUID, initStatus.status, initStatus.name, initStatus.authenticatedUser, initStatus.assumedRole, JSON.stringify(initStatus.authenticatedRoles), JSON.stringify(initStatus.request), null, initStatus.executorID]);
70
- const { rows } = await this.pool.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_inputs (workflow_uuid, inputs) VALUES($1, $2) ON CONFLICT (workflow_uuid) DO UPDATE SET workflow_uuid = excluded.workflow_uuid RETURNING inputs`, [initStatus.workflowUUID, JSON.stringify(args)]);
71
- return JSON.parse(rows[0].inputs);
72
- }
73
- bufferWorkflowOutput(workflowUUID, status) {
74
- this.workflowStatusBuffer.set(workflowUUID, status);
75
- }
76
- /**
77
- * Flush the workflow output buffer to the database.
78
- */
79
- async flushWorkflowStatusBuffer() {
80
- const localBuffer = new Map(this.workflowStatusBuffer);
81
- this.workflowStatusBuffer.clear();
82
- const totalSize = localBuffer.size;
83
- try {
84
- let finishedCnt = 0;
85
- while (finishedCnt < totalSize) {
86
- let sqlStmt = `INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status (workflow_uuid, status, name, authenticated_user, assumed_role, authenticated_roles, request, output, executor_id) VALUES `;
87
- let paramCnt = 1;
88
- const values = [];
89
- const batchUUIDs = [];
90
- for (const [workflowUUID, status] of localBuffer) {
91
- if (paramCnt > 1) {
92
- sqlStmt += ", ";
93
- }
94
- sqlStmt += `($${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++})`;
95
- values.push(workflowUUID, status.status, status.name, status.authenticatedUser, status.assumedRole, JSON.stringify(status.authenticatedRoles), JSON.stringify(status.request), JSON.stringify(status.output), status.executorID);
96
- batchUUIDs.push(workflowUUID);
97
- finishedCnt++;
98
- if (batchUUIDs.length >= this.flushBatchSize) {
99
- // Cap at the batch size.
100
- break;
101
- }
102
- }
103
- sqlStmt += " ON CONFLICT (workflow_uuid) DO UPDATE SET status=EXCLUDED.status, output=EXCLUDED.output;";
104
- await this.pool.query(sqlStmt, values);
105
- // Clean up after each batch succeeds
106
- batchUUIDs.forEach((value) => { localBuffer.delete(value); });
107
- }
108
- }
109
- catch (error) {
110
- error.message = `Error flushing workflow buffer: ${error.message}`;
111
- this.logger.error(error);
112
- // If there is a failure in flushing the buffer, return items to the global buffer for retrying later.
113
- for (const [workflowUUID, output] of localBuffer) {
114
- if (!this.workflowStatusBuffer.has(workflowUUID)) {
115
- this.workflowStatusBuffer.set(workflowUUID, output);
116
- }
117
- }
118
- }
119
- return;
120
- }
121
- async recordWorkflowError(workflowUUID, status) {
122
- await this.pool.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status (workflow_uuid, status, name, authenticated_user, assumed_role, authenticated_roles, request, error, executor_id) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (workflow_uuid)
123
- DO UPDATE SET status=EXCLUDED.status, error=EXCLUDED.error;`, [workflowUUID, workflow_1.StatusString.ERROR, status.name, status.authenticatedUser, status.assumedRole, JSON.stringify(status.authenticatedRoles), JSON.stringify(status.request), status.error, status.executorID]);
124
- }
125
- async getPendingWorkflows(executorID) {
126
- const { rows } = await this.pool.query(`SELECT workflow_uuid FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status WHERE status=$1 AND executor_id=$2`, [workflow_1.StatusString.PENDING, executorID]);
127
- return rows.map(i => i.workflow_uuid);
128
- }
129
- bufferWorkflowInputs(workflowUUID, args) {
130
- this.workflowInputsBuffer.set(workflowUUID, args);
131
- }
132
- async flushWorkflowInputsBuffer() {
133
- const localBuffer = new Map(this.workflowInputsBuffer);
134
- this.workflowInputsBuffer.clear();
135
- const totalSize = localBuffer.size;
136
- try {
137
- let finishedCnt = 0;
138
- while (finishedCnt < totalSize) {
139
- let sqlStmt = `INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_inputs (workflow_uuid, inputs) VALUES `;
140
- let paramCnt = 1;
141
- const values = [];
142
- const batchUUIDs = [];
143
- for (const [workflowUUID, args] of localBuffer) {
144
- if (paramCnt > 1) {
145
- sqlStmt += ", ";
146
- }
147
- sqlStmt += `($${paramCnt++}, $${paramCnt++})`;
148
- values.push(workflowUUID, JSON.stringify(args));
149
- batchUUIDs.push(workflowUUID);
150
- finishedCnt++;
151
- if (batchUUIDs.length >= this.flushBatchSize) {
152
- // Cap at the batch size.
153
- break;
154
- }
155
- }
156
- sqlStmt += " ON CONFLICT (workflow_uuid) DO NOTHING;";
157
- await this.pool.query(sqlStmt, values);
158
- // Clean up after each batch succeeds
159
- batchUUIDs.forEach((value) => { localBuffer.delete(value); });
160
- }
161
- }
162
- catch (error) {
163
- error.message = `Error flushing workflow inputs buffer: ${error.message}`;
164
- this.logger.error(error);
165
- // If there is a failure in flushing the buffer, return items to the global buffer for retrying later.
166
- for (const [workflowUUID, args] of localBuffer) {
167
- if (!this.workflowInputsBuffer.has(workflowUUID)) {
168
- this.workflowInputsBuffer.set(workflowUUID, args);
169
- }
170
- }
171
- }
172
- return;
173
- }
174
- async getWorkflowInputs(workflowUUID) {
175
- const { rows } = await this.pool.query(`SELECT inputs FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_inputs WHERE workflow_uuid=$1`, [workflowUUID]);
176
- if (rows.length === 0) {
177
- return null;
178
- }
179
- return JSON.parse(rows[0].inputs);
180
- }
181
- async checkOperationOutput(workflowUUID, functionID) {
182
- const { rows } = await this.pool.query(`SELECT output, error FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs WHERE workflow_uuid=$1 AND function_id=$2`, [workflowUUID, functionID]);
183
- if (rows.length === 0) {
184
- return dbos_executor_1.dbosNull;
185
- }
186
- else if (JSON.parse(rows[0].error) !== null) {
187
- throw (0, serialize_error_1.deserializeError)(JSON.parse(rows[0].error));
188
- }
189
- else {
190
- return JSON.parse(rows[0].output);
191
- }
192
- }
193
- async recordOperationOutput(workflowUUID, functionID, output) {
194
- const serialOutput = JSON.stringify(output);
195
- try {
196
- await this.pool.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs (workflow_uuid, function_id, output) VALUES ($1, $2, $3);`, [workflowUUID, functionID, serialOutput]);
197
- }
198
- catch (error) {
199
- const err = error;
200
- if (err.code === "40001" || err.code === "23505") {
201
- // Serialization and primary key conflict (Postgres).
202
- throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
203
- }
204
- else {
205
- throw err;
206
- }
207
- }
208
- }
209
- async recordOperationError(workflowUUID, functionID, error) {
210
- const serialErr = JSON.stringify((0, serialize_error_1.serializeError)(error));
211
- try {
212
- await this.pool.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs (workflow_uuid, function_id, error) VALUES ($1, $2, $3);`, [workflowUUID, functionID, serialErr]);
213
- }
214
- catch (error) {
215
- const err = error;
216
- if (err.code === "40001" || err.code === "23505") {
217
- // Serialization and primary key conflict (Postgres).
218
- throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
219
- }
220
- else {
221
- throw err;
222
- }
223
- }
224
- }
225
- /**
226
- * Guard the operation, throwing an error if a conflicting execution is detected.
227
- */
228
- async recordNotificationOutput(client, workflowUUID, functionID, output) {
229
- try {
230
- await client.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs (workflow_uuid, function_id, output) VALUES ($1, $2, $3);`, [workflowUUID, functionID, JSON.stringify(output)]);
231
- }
232
- catch (error) {
233
- await client.query("ROLLBACK");
234
- client.release();
235
- const err = error;
236
- if (err.code === "40001" || err.code === "23505") {
237
- // Serialization and primary key conflict (Postgres).
238
- throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
239
- }
240
- else {
241
- throw err;
242
- }
243
- }
244
- }
245
- nullTopic = "__null__topic__";
246
- async send(workflowUUID, functionID, destinationUUID, message, topic) {
247
- topic = topic ?? this.nullTopic;
248
- const client = await this.pool.connect();
249
- await client.query("BEGIN ISOLATION LEVEL READ COMMITTED");
250
- const { rows } = await client.query(`SELECT output FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs WHERE workflow_uuid=$1 AND function_id=$2`, [workflowUUID, functionID]);
251
- if (rows.length > 0) {
252
- await client.query("ROLLBACK");
253
- client.release();
254
- return;
255
- }
256
- await client.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.notifications (destination_uuid, topic, message) VALUES ($1, $2, $3);`, [destinationUUID, topic, JSON.stringify(message)]);
257
- await this.recordNotificationOutput(client, workflowUUID, functionID, undefined);
258
- await client.query("COMMIT");
259
- client.release();
260
- }
261
- async recv(workflowUUID, functionID, topic, timeoutSeconds = dbos_executor_1.DBOSExecutor.defaultNotificationTimeoutSec) {
262
- topic = topic ?? this.nullTopic;
263
- // First, check for previous executions.
264
- const checkRows = (await this.pool.query(`SELECT output FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs WHERE workflow_uuid=$1 AND function_id=$2`, [workflowUUID, functionID])).rows;
265
- if (checkRows.length > 0) {
266
- return JSON.parse(checkRows[0].output);
267
- }
268
- // Then, register the key with the global notifications listener.
269
- let resolveNotification;
270
- const messagePromise = new Promise((resolve) => {
271
- resolveNotification = resolve;
272
- });
273
- const payload = `${workflowUUID}::${topic}`;
274
- this.notificationsMap[payload] = resolveNotification; // The resolver assignment in the Promise definition runs synchronously.
275
- let timer;
276
- const timeoutPromise = new Promise((resolve) => {
277
- timer = setTimeout(() => {
278
- resolve();
279
- }, timeoutSeconds * 1000);
280
- });
281
- const received = Promise.race([messagePromise, timeoutPromise]);
282
- // Check if the key is already in the DB, then wait for the notification if it isn't.
283
- const initRecvRows = (await this.pool.query(`SELECT topic FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.notifications WHERE destination_uuid=$1 AND topic=$2;`, [workflowUUID, topic])).rows;
284
- if (initRecvRows.length === 0) {
285
- await received;
286
- }
287
- clearTimeout(timer);
288
- // Transactionally consume and return the message if it's in the DB, otherwise return null.
289
- const client = await this.pool.connect();
290
- await client.query(`BEGIN ISOLATION LEVEL READ COMMITTED`);
291
- const finalRecvRows = (await client.query(`WITH oldest_entry AS (
292
- SELECT destination_uuid, topic, message, created_at_epoch_ms
293
- FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.notifications
294
- WHERE destination_uuid = $1
295
- AND topic = $2
296
- ORDER BY created_at_epoch_ms ASC
297
- LIMIT 1
298
- )
299
-
300
- DELETE FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.notifications
301
- USING oldest_entry
302
- WHERE notifications.destination_uuid = oldest_entry.destination_uuid
303
- AND notifications.topic = oldest_entry.topic
304
- AND notifications.created_at_epoch_ms = oldest_entry.created_at_epoch_ms
305
- RETURNING notifications.*;`, [workflowUUID, topic])).rows;
306
- let message = null;
307
- if (finalRecvRows.length > 0) {
308
- message = JSON.parse(finalRecvRows[0].message);
309
- }
310
- await this.recordNotificationOutput(client, workflowUUID, functionID, message);
311
- await client.query(`COMMIT`);
312
- client.release();
313
- return message;
314
- }
315
- async setEvent(workflowUUID, functionID, key, message) {
316
- const client = await this.pool.connect();
317
- await client.query("BEGIN ISOLATION LEVEL READ COMMITTED");
318
- let { rows } = await client.query(`SELECT output FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs WHERE workflow_uuid=$1 AND function_id=$2`, [workflowUUID, functionID]);
319
- if (rows.length > 0) {
320
- await client.query("ROLLBACK");
321
- client.release();
322
- return;
323
- }
324
- ({ rows } = await client.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_events (workflow_uuid, key, value) VALUES ($1, $2, $3) ON CONFLICT (workflow_uuid, key) DO NOTHING RETURNING workflow_uuid;`, [workflowUUID, key, JSON.stringify(message)]));
325
- if (rows.length === 0) {
326
- await client.query("ROLLBACK");
327
- client.release();
328
- throw new error_1.DuplicateWorkflowEventError(workflowUUID, key);
329
- }
330
- await this.recordNotificationOutput(client, workflowUUID, functionID, undefined);
331
- await client.query("COMMIT");
332
- client.release();
333
- }
334
- async getEvent(workflowUUID, key, timeoutSeconds, callerUUID, functionID) {
335
- // Check if the operation has been done before for OAOO (only do this inside a workflow).
336
- if (callerUUID !== undefined && functionID !== undefined) {
337
- const { rows } = await this.pool.query(`SELECT output FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs WHERE workflow_uuid=$1 AND function_id=$2`, [callerUUID, functionID]);
338
- if (rows.length > 0) {
339
- return JSON.parse(rows[0].output);
340
- }
341
- }
342
- // Register the key with the global notifications listener.
343
- let resolveNotification;
344
- const valuePromise = new Promise((resolve) => {
345
- resolveNotification = resolve;
346
- });
347
- this.workflowEventsMap[`${workflowUUID}::${key}`] = resolveNotification; // The resolver assignment in the Promise definition runs synchronously.
348
- let timer;
349
- const timeoutPromise = new Promise((resolve) => {
350
- timer = setTimeout(() => {
351
- resolve();
352
- }, timeoutSeconds * 1000);
353
- });
354
- const received = Promise.race([valuePromise, timeoutPromise]);
355
- // Check if the key is already in the DB, then wait for the notification if it isn't.
356
- const initRecvRows = (await this.pool.query(`SELECT key, value FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_events WHERE workflow_uuid=$1 AND key=$2;`, [workflowUUID, key])).rows;
357
- if (initRecvRows.length === 0) {
358
- await received;
359
- }
360
- clearTimeout(timer);
361
- // Return the value if it's in the DB, otherwise return null.
362
- let value = null;
363
- if (initRecvRows.length > 0) {
364
- value = JSON.parse(initRecvRows[0].value);
365
- }
366
- else {
367
- // Read it again from the database.
368
- const finalRecvRows = (await this.pool.query(`SELECT value FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_events WHERE workflow_uuid=$1 AND key=$2;`, [workflowUUID, key])).rows;
369
- if (finalRecvRows.length > 0) {
370
- value = JSON.parse(finalRecvRows[0].value);
371
- }
372
- }
373
- // Record the output if it is inside a workflow.
374
- if (callerUUID !== undefined && functionID !== undefined) {
375
- await this.recordOperationOutput(callerUUID, functionID, value);
376
- }
377
- return value;
378
- }
379
- async getWorkflowStatus(workflowUUID, callerUUID, functionID) {
380
- // Check if the operation has been done before for OAOO (only do this inside a workflow).
381
- if (callerUUID !== undefined && functionID !== undefined) {
382
- const { rows } = await this.pool.query(`SELECT output FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.operation_outputs WHERE workflow_uuid=$1 AND function_id=$2`, [callerUUID, functionID]);
383
- if (rows.length > 0) {
384
- return JSON.parse(rows[0].output);
385
- }
386
- }
387
- const { rows } = await this.pool.query(`SELECT status, name, authenticated_user, assumed_role, authenticated_roles, request FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status WHERE workflow_uuid=$1`, [workflowUUID]);
388
- let value = null;
389
- if (rows.length > 0) {
390
- value = {
391
- status: rows[0].status,
392
- workflowName: rows[0].name,
393
- authenticatedUser: rows[0].authenticated_user,
394
- assumedRole: rows[0].assumed_role,
395
- authenticatedRoles: JSON.parse(rows[0].authenticated_roles),
396
- request: JSON.parse(rows[0].request),
397
- };
398
- }
399
- // Record the output if it is inside a workflow.
400
- if (callerUUID !== undefined && functionID !== undefined) {
401
- await this.recordOperationOutput(callerUUID, functionID, value);
402
- }
403
- return value;
404
- }
405
- async getWorkflowResult(workflowUUID) {
406
- const pollingIntervalMs = 1000;
407
- // eslint-disable-next-line no-constant-condition
408
- while (true) {
409
- const { rows } = await this.pool.query(`SELECT status, output, error FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status WHERE workflow_uuid=$1`, [workflowUUID]);
410
- if (rows.length > 0) {
411
- const status = rows[0].status;
412
- if (status === workflow_1.StatusString.SUCCESS) {
413
- return JSON.parse(rows[0].output);
414
- }
415
- else if (status === workflow_1.StatusString.ERROR) {
416
- throw (0, serialize_error_1.deserializeError)(JSON.parse(rows[0].error));
417
- }
418
- }
419
- await (0, utils_1.sleep)(pollingIntervalMs);
420
- }
421
- }
422
- /* BACKGROUND PROCESSES */
423
- /**
424
- * A background process that listens for notifications from Postgres then signals the appropriate
425
- * workflow listener by resolving its promise.
426
- */
427
- async listenForNotifications() {
428
- this.notificationsClient = await this.pool.connect();
429
- await this.notificationsClient.query("LISTEN dbos_notifications_channel;");
430
- await this.notificationsClient.query("LISTEN dbos_workflow_events_channel;");
431
- const handler = (msg) => {
432
- if (msg.channel === 'dbos_notifications_channel') {
433
- if (msg.payload && msg.payload in this.notificationsMap) {
434
- this.notificationsMap[msg.payload]();
435
- }
436
- }
437
- else {
438
- if (msg.payload && msg.payload in this.workflowEventsMap) {
439
- this.workflowEventsMap[msg.payload]();
440
- }
441
- }
442
- };
443
- this.notificationsClient.on("notification", handler);
444
- }
445
- }
446
- exports.PostgresSystemDatabase = PostgresSystemDatabase;
447
- //# sourceMappingURL=system_database.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"system_database.js","sourceRoot":"","sources":["../../../../src/system_database.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;AAEvD,qDAAmE;AACnE,mDAAmE;AACnE,2BAAuF;AACvF,mCAAqF;AACrF,yCAA0D;AAC1D,kEAAkJ;AAClJ,mCAAgC;AAmDhC,MAAa,sBAAsB;IAWZ;IAAmC;IAAqC;IAVpF,IAAI,CAAO;IAEpB,mBAAmB,GAAsB,IAAI,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IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACrD,MAAM,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC3E,MAAM,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC7E,MAAM,OAAO,GAAG,CAAC,GAAiB,EAAE,EAAE;YACpC,IAAI,GAAG,CAAC,OAAO,KAAK,4BAA4B,EAAE,CAAC;gBACjD,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACxD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBACzD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QACF,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF;AA/dD,wDA+dC"}
@@ -1,16 +0,0 @@
1
- import { ITelemetryExporter } from "./exporters";
2
- import { Span } from "@opentelemetry/sdk-trace-base";
3
- import { LogRecord } from "@opentelemetry/api-logs";
4
- export type TelemetrySignal = LogRecord | Span;
5
- export declare class TelemetryCollector {
6
- readonly exporter?: ITelemetryExporter | undefined;
7
- private readonly signals;
8
- private readonly signalBufferID;
9
- private readonly processAndExportSignalsIntervalMs;
10
- constructor(exporter?: ITelemetryExporter | undefined);
11
- destroy(): Promise<void>;
12
- push(signal: TelemetrySignal): void;
13
- private pop;
14
- processAndExportSignals(): Promise<void>;
15
- }
16
- //# sourceMappingURL=collector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../../../src/telemetry/collector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;AAmB/C,qBAAa,kBAAkB;IASjB,QAAQ,CAAC,QAAQ,CAAC;IAP9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAGhD,OAAO,CAAC,QAAQ,CAAC,iCAAiC,CAAO;gBAGpC,QAAQ,CAAC,gCAAoB;IAM5C,OAAO;IAKb,IAAI,CAAC,MAAM,EAAE,eAAe;IAI5B,OAAO,CAAC,GAAG;IAIL,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;CAqB/C"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TelemetryCollector = void 0;
4
- class SignalsQueue {
5
- data = [];
6
- push(signal) {
7
- this.data.push(signal);
8
- }
9
- pop() {
10
- return this.data.shift();
11
- }
12
- size() {
13
- return this.data.length;
14
- }
15
- }
16
- // TODO: Handle temporary workflows properly.
17
- class TelemetryCollector {
18
- exporter;
19
- // Signals buffer management
20
- signals = new SignalsQueue();
21
- signalBufferID;
22
- // We iterate on an interval and export whatever has accumulated so far
23
- processAndExportSignalsIntervalMs = 100;
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- constructor(exporter) {
26
- this.exporter = exporter;
27
- this.signalBufferID = setInterval(() => {
28
- void this.processAndExportSignals();
29
- }, this.processAndExportSignalsIntervalMs);
30
- }
31
- async destroy() {
32
- clearInterval(this.signalBufferID);
33
- await this.processAndExportSignals();
34
- }
35
- push(signal) {
36
- this.signals.push(signal);
37
- }
38
- pop() {
39
- return this.signals.pop();
40
- }
41
- async processAndExportSignals() {
42
- const batch = [];
43
- while (this.signals.size() > 0) {
44
- const signal = this.pop();
45
- if (!signal) {
46
- break;
47
- }
48
- batch.push(signal);
49
- }
50
- if (batch.length > 0) {
51
- const exports = [];
52
- if (this.exporter) {
53
- exports.push(this.exporter.export(batch));
54
- }
55
- try {
56
- await Promise.all(exports);
57
- }
58
- catch (e) {
59
- console.error(e.message);
60
- }
61
- }
62
- }
63
- }
64
- exports.TelemetryCollector = TelemetryCollector;
65
- //# sourceMappingURL=collector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collector.js","sourceRoot":"","sources":["../../../../../src/telemetry/collector.ts"],"names":[],"mappings":";;;AAMA,MAAM,YAAY;IAChB,IAAI,GAAsB,EAAE,CAAC;IAE7B,IAAI,CAAC,MAAuB;QAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1B,CAAC;CACF;AAED,6CAA6C;AAC7C,MAAa,kBAAkB;IASR;IARrB,4BAA4B;IACX,OAAO,GAAiB,IAAI,YAAY,EAAE,CAAC;IAC3C,cAAc,CAAiB;IAEhD,wEAAwE;IACvD,iCAAiC,GAAG,GAAG,CAAC;IAEzD,8DAA8D;IAC9D,YAAqB,QAA6B;QAA7B,aAAQ,GAAR,QAAQ,CAAqB;QAChD,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE;YACrC,KAAK,IAAI,CAAC,uBAAuB,EAAE,CAAC;QACtC,CAAC,EAAE,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,OAAO;QACX,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,MAAM,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACvC,CAAC;IAED,IAAI,CAAC,MAAuB;QAC1B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAEO,GAAG;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,MAAM,KAAK,GAAsB,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM;YACR,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,OAAO,GAAG,EAAE,CAAC;YACnB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5C,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAjDD,gDAiDC"}
@@ -1,15 +0,0 @@
1
- import { TelemetrySignal } from "./collector";
2
- export interface OTLPExporterConfig {
3
- logsEndpoint?: string;
4
- tracesEndpoint?: string;
5
- }
6
- export interface ITelemetryExporter {
7
- export(signal: TelemetrySignal[]): Promise<void>;
8
- }
9
- export declare class TelemetryExporter implements ITelemetryExporter {
10
- private readonly tracesExporter?;
11
- private readonly logsExporter?;
12
- constructor(config: OTLPExporterConfig);
13
- export(signals: TelemetrySignal[]): Promise<void>;
14
- }
15
- //# sourceMappingURL=exporters.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exporters.d.ts","sourceRoot":"","sources":["../../../../../src/telemetry/exporters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9C,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD;AAED,qBAAa,iBAAkB,YAAW,kBAAkB;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAoB;IACpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAkB;gBACpC,MAAM,EAAE,kBAAkB;IAehC,MAAM,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAmCxD"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TelemetryExporter = void 0;
4
- const _1 = require("./");
5
- const exporter_trace_otlp_proto_1 = require("@opentelemetry/exporter-trace-otlp-proto");
6
- const exporter_logs_otlp_proto_1 = require("@opentelemetry/exporter-logs-otlp-proto");
7
- const core_1 = require("@opentelemetry/core");
8
- class TelemetryExporter {
9
- tracesExporter;
10
- logsExporter;
11
- constructor(config) {
12
- if (config.tracesEndpoint) {
13
- this.tracesExporter = new exporter_trace_otlp_proto_1.OTLPTraceExporter({
14
- url: config.tracesEndpoint,
15
- });
16
- console.log(`Traces will be exported to ${config.tracesEndpoint}`);
17
- }
18
- if (config.logsEndpoint) {
19
- this.logsExporter = new exporter_logs_otlp_proto_1.OTLPLogExporter({
20
- url: config.logsEndpoint,
21
- });
22
- console.log(`Logs will be exported to ${config.logsEndpoint}`);
23
- }
24
- }
25
- async export(signals) {
26
- return await new Promise((resolve) => {
27
- // Sort out traces and logs
28
- const exportSpans = [];
29
- const exportLogs = [];
30
- signals.forEach((signal) => {
31
- if ((0, _1.isTraceSignal)(signal)) {
32
- exportSpans.push(signal);
33
- }
34
- if ((0, _1.isLogSignal)(signal)) {
35
- exportLogs.push(signal);
36
- }
37
- });
38
- if (exportSpans.length > 0 && this.tracesExporter) {
39
- this.tracesExporter.export(exportSpans, (results) => {
40
- if (results.code !== core_1.ExportResultCode.SUCCESS) {
41
- console.warn(`Trace export failed: ${results.code}`);
42
- console.warn(results);
43
- }
44
- });
45
- }
46
- if (exportLogs.length > 0 && this.logsExporter) {
47
- this.logsExporter.export(exportLogs, (results) => {
48
- if (results.code !== core_1.ExportResultCode.SUCCESS) {
49
- console.warn(`Log export failed: ${results.code}`);
50
- console.warn(results);
51
- }
52
- });
53
- }
54
- resolve();
55
- });
56
- }
57
- }
58
- exports.TelemetryExporter = TelemetryExporter;
59
- //# sourceMappingURL=exporters.js.map