@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,462 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.PostgresSystemDatabase = exports.migrateSystemDatabase = void 0;
8
- const serialize_error_1 = require("serialize-error");
9
- const dbos_executor_1 = require("./dbos-executor");
10
- const pg_1 = require("pg");
11
- const error_1 = require("./error");
12
- const workflow_1 = require("./workflow");
13
- const utils_1 = require("./utils");
14
- const knex_1 = __importDefault(require("knex"));
15
- const path_1 = __importDefault(require("path"));
16
- async function migrateSystemDatabase(systemPoolConfig) {
17
- const migrationsDirectory = path_1.default.join((0, utils_1.findPackageRoot)(__dirname), 'migrations');
18
- const knexConfig = {
19
- client: 'pg',
20
- connection: systemPoolConfig,
21
- migrations: {
22
- directory: migrationsDirectory,
23
- tableName: 'knex_migrations'
24
- }
25
- };
26
- const knexDB = (0, knex_1.default)(knexConfig);
27
- await knexDB.migrate.latest();
28
- await knexDB.destroy();
29
- }
30
- exports.migrateSystemDatabase = migrateSystemDatabase;
31
- class PostgresSystemDatabase {
32
- pgPoolConfig;
33
- systemDatabaseName;
34
- logger;
35
- pool;
36
- systemPoolConfig;
37
- notificationsClient = null;
38
- notificationsMap = {};
39
- workflowEventsMap = {};
40
- workflowStatusBuffer = new Map();
41
- workflowInputsBuffer = new Map();
42
- flushBatchSize = 100;
43
- constructor(pgPoolConfig, systemDatabaseName, logger) {
44
- this.pgPoolConfig = pgPoolConfig;
45
- this.systemDatabaseName = systemDatabaseName;
46
- this.logger = logger;
47
- this.systemPoolConfig = { ...pgPoolConfig };
48
- this.systemPoolConfig.database = systemDatabaseName;
49
- this.pool = new pg_1.Pool(this.systemPoolConfig);
50
- }
51
- async init() {
52
- const pgSystemClient = new pg_1.Client(this.pgPoolConfig);
53
- await pgSystemClient.connect();
54
- // Create the system database and load tables.
55
- const dbExists = await pgSystemClient.query(`SELECT EXISTS (SELECT FROM pg_database WHERE datname = '${this.systemDatabaseName}')`);
56
- if (!dbExists.rows[0].exists) {
57
- // Create the DBOS system database.
58
- await pgSystemClient.query(`CREATE DATABASE "${this.systemDatabaseName}"`);
59
- }
60
- await migrateSystemDatabase(this.systemPoolConfig);
61
- await this.listenForNotifications();
62
- await pgSystemClient.end();
63
- }
64
- async destroy() {
65
- if (this.notificationsClient) {
66
- this.notificationsClient.removeAllListeners();
67
- this.notificationsClient.release();
68
- }
69
- await this.pool.end();
70
- }
71
- async checkWorkflowOutput(workflowUUID) {
72
- const { rows } = await this.pool.query(`SELECT status, output, error FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status WHERE workflow_uuid=$1`, [workflowUUID]);
73
- if (rows.length === 0 || rows[0].status === workflow_1.StatusString.PENDING) {
74
- return dbos_executor_1.dbosNull;
75
- }
76
- else if (rows[0].status === workflow_1.StatusString.ERROR) {
77
- throw (0, serialize_error_1.deserializeError)(JSON.parse(rows[0].error));
78
- }
79
- else {
80
- return JSON.parse(rows[0].output);
81
- }
82
- }
83
- async initWorkflowStatus(initStatus, args) {
84
- 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]);
85
- 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)]);
86
- return JSON.parse(rows[0].inputs);
87
- }
88
- bufferWorkflowOutput(workflowUUID, status) {
89
- this.workflowStatusBuffer.set(workflowUUID, status);
90
- }
91
- /**
92
- * Flush the workflow output buffer to the database.
93
- */
94
- async flushWorkflowStatusBuffer() {
95
- const localBuffer = new Map(this.workflowStatusBuffer);
96
- this.workflowStatusBuffer.clear();
97
- const totalSize = localBuffer.size;
98
- try {
99
- let finishedCnt = 0;
100
- while (finishedCnt < totalSize) {
101
- 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 `;
102
- let paramCnt = 1;
103
- const values = [];
104
- const batchUUIDs = [];
105
- for (const [workflowUUID, status] of localBuffer) {
106
- if (paramCnt > 1) {
107
- sqlStmt += ", ";
108
- }
109
- sqlStmt += `($${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++})`;
110
- 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);
111
- batchUUIDs.push(workflowUUID);
112
- finishedCnt++;
113
- if (batchUUIDs.length >= this.flushBatchSize) {
114
- // Cap at the batch size.
115
- break;
116
- }
117
- }
118
- sqlStmt += " ON CONFLICT (workflow_uuid) DO UPDATE SET status=EXCLUDED.status, output=EXCLUDED.output;";
119
- await this.pool.query(sqlStmt, values);
120
- // Clean up after each batch succeeds
121
- batchUUIDs.forEach((value) => { localBuffer.delete(value); });
122
- }
123
- }
124
- catch (error) {
125
- error.message = `Error flushing workflow buffer: ${error.message}`;
126
- this.logger.error(error);
127
- // If there is a failure in flushing the buffer, return items to the global buffer for retrying later.
128
- for (const [workflowUUID, output] of localBuffer) {
129
- if (!this.workflowStatusBuffer.has(workflowUUID)) {
130
- this.workflowStatusBuffer.set(workflowUUID, output);
131
- }
132
- }
133
- }
134
- return;
135
- }
136
- async recordWorkflowError(workflowUUID, status) {
137
- 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)
138
- 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]);
139
- }
140
- async getPendingWorkflows(executorID) {
141
- 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]);
142
- return rows.map(i => i.workflow_uuid);
143
- }
144
- bufferWorkflowInputs(workflowUUID, args) {
145
- this.workflowInputsBuffer.set(workflowUUID, args);
146
- }
147
- async flushWorkflowInputsBuffer() {
148
- const localBuffer = new Map(this.workflowInputsBuffer);
149
- this.workflowInputsBuffer.clear();
150
- const totalSize = localBuffer.size;
151
- try {
152
- let finishedCnt = 0;
153
- while (finishedCnt < totalSize) {
154
- let sqlStmt = `INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_inputs (workflow_uuid, inputs) VALUES `;
155
- let paramCnt = 1;
156
- const values = [];
157
- const batchUUIDs = [];
158
- for (const [workflowUUID, args] of localBuffer) {
159
- if (paramCnt > 1) {
160
- sqlStmt += ", ";
161
- }
162
- sqlStmt += `($${paramCnt++}, $${paramCnt++})`;
163
- values.push(workflowUUID, JSON.stringify(args));
164
- batchUUIDs.push(workflowUUID);
165
- finishedCnt++;
166
- if (batchUUIDs.length >= this.flushBatchSize) {
167
- // Cap at the batch size.
168
- break;
169
- }
170
- }
171
- sqlStmt += " ON CONFLICT (workflow_uuid) DO NOTHING;";
172
- await this.pool.query(sqlStmt, values);
173
- // Clean up after each batch succeeds
174
- batchUUIDs.forEach((value) => { localBuffer.delete(value); });
175
- }
176
- }
177
- catch (error) {
178
- error.message = `Error flushing workflow inputs buffer: ${error.message}`;
179
- this.logger.error(error);
180
- // If there is a failure in flushing the buffer, return items to the global buffer for retrying later.
181
- for (const [workflowUUID, args] of localBuffer) {
182
- if (!this.workflowInputsBuffer.has(workflowUUID)) {
183
- this.workflowInputsBuffer.set(workflowUUID, args);
184
- }
185
- }
186
- }
187
- return;
188
- }
189
- async getWorkflowInputs(workflowUUID) {
190
- const { rows } = await this.pool.query(`SELECT inputs FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_inputs WHERE workflow_uuid=$1`, [workflowUUID]);
191
- if (rows.length === 0) {
192
- return null;
193
- }
194
- return JSON.parse(rows[0].inputs);
195
- }
196
- async checkOperationOutput(workflowUUID, functionID) {
197
- 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]);
198
- if (rows.length === 0) {
199
- return dbos_executor_1.dbosNull;
200
- }
201
- else if (JSON.parse(rows[0].error) !== null) {
202
- throw (0, serialize_error_1.deserializeError)(JSON.parse(rows[0].error));
203
- }
204
- else {
205
- return JSON.parse(rows[0].output);
206
- }
207
- }
208
- async recordOperationOutput(workflowUUID, functionID, output) {
209
- const serialOutput = JSON.stringify(output);
210
- try {
211
- 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]);
212
- }
213
- catch (error) {
214
- const err = error;
215
- if (err.code === "40001" || err.code === "23505") {
216
- // Serialization and primary key conflict (Postgres).
217
- throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
218
- }
219
- else {
220
- throw err;
221
- }
222
- }
223
- }
224
- async recordOperationError(workflowUUID, functionID, error) {
225
- const serialErr = JSON.stringify((0, serialize_error_1.serializeError)(error));
226
- try {
227
- 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]);
228
- }
229
- catch (error) {
230
- const err = error;
231
- if (err.code === "40001" || err.code === "23505") {
232
- // Serialization and primary key conflict (Postgres).
233
- throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
234
- }
235
- else {
236
- throw err;
237
- }
238
- }
239
- }
240
- /**
241
- * Guard the operation, throwing an error if a conflicting execution is detected.
242
- */
243
- async recordNotificationOutput(client, workflowUUID, functionID, output) {
244
- try {
245
- 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)]);
246
- }
247
- catch (error) {
248
- await client.query("ROLLBACK");
249
- client.release();
250
- const err = error;
251
- if (err.code === "40001" || err.code === "23505") {
252
- // Serialization and primary key conflict (Postgres).
253
- throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
254
- }
255
- else {
256
- throw err;
257
- }
258
- }
259
- }
260
- nullTopic = "__null__topic__";
261
- async send(workflowUUID, functionID, destinationUUID, message, topic) {
262
- topic = topic ?? this.nullTopic;
263
- const client = await this.pool.connect();
264
- await client.query("BEGIN ISOLATION LEVEL READ COMMITTED");
265
- 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]);
266
- if (rows.length > 0) {
267
- await client.query("ROLLBACK");
268
- client.release();
269
- return;
270
- }
271
- await client.query(`INSERT INTO ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.notifications (destination_uuid, topic, message) VALUES ($1, $2, $3);`, [destinationUUID, topic, JSON.stringify(message)]);
272
- await this.recordNotificationOutput(client, workflowUUID, functionID, undefined);
273
- await client.query("COMMIT");
274
- client.release();
275
- }
276
- async recv(workflowUUID, functionID, topic, timeoutSeconds = dbos_executor_1.DBOSExecutor.defaultNotificationTimeoutSec) {
277
- topic = topic ?? this.nullTopic;
278
- // First, check for previous executions.
279
- 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;
280
- if (checkRows.length > 0) {
281
- return JSON.parse(checkRows[0].output);
282
- }
283
- // Then, register the key with the global notifications listener.
284
- let resolveNotification;
285
- const messagePromise = new Promise((resolve) => {
286
- resolveNotification = resolve;
287
- });
288
- const payload = `${workflowUUID}::${topic}`;
289
- this.notificationsMap[payload] = resolveNotification; // The resolver assignment in the Promise definition runs synchronously.
290
- let timer;
291
- const timeoutPromise = new Promise((resolve) => {
292
- timer = setTimeout(() => {
293
- resolve();
294
- }, timeoutSeconds * 1000);
295
- });
296
- const received = Promise.race([messagePromise, timeoutPromise]);
297
- // Check if the key is already in the DB, then wait for the notification if it isn't.
298
- 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;
299
- if (initRecvRows.length === 0) {
300
- await received;
301
- }
302
- clearTimeout(timer);
303
- // Transactionally consume and return the message if it's in the DB, otherwise return null.
304
- const client = await this.pool.connect();
305
- await client.query(`BEGIN ISOLATION LEVEL READ COMMITTED`);
306
- const finalRecvRows = (await client.query(`WITH oldest_entry AS (
307
- SELECT destination_uuid, topic, message, created_at_epoch_ms
308
- FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.notifications
309
- WHERE destination_uuid = $1
310
- AND topic = $2
311
- ORDER BY created_at_epoch_ms ASC
312
- LIMIT 1
313
- )
314
-
315
- DELETE FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.notifications
316
- USING oldest_entry
317
- WHERE notifications.destination_uuid = oldest_entry.destination_uuid
318
- AND notifications.topic = oldest_entry.topic
319
- AND notifications.created_at_epoch_ms = oldest_entry.created_at_epoch_ms
320
- RETURNING notifications.*;`, [workflowUUID, topic])).rows;
321
- let message = null;
322
- if (finalRecvRows.length > 0) {
323
- message = JSON.parse(finalRecvRows[0].message);
324
- }
325
- await this.recordNotificationOutput(client, workflowUUID, functionID, message);
326
- await client.query(`COMMIT`);
327
- client.release();
328
- return message;
329
- }
330
- async setEvent(workflowUUID, functionID, key, message) {
331
- const client = await this.pool.connect();
332
- await client.query("BEGIN ISOLATION LEVEL READ COMMITTED");
333
- 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]);
334
- if (rows.length > 0) {
335
- await client.query("ROLLBACK");
336
- client.release();
337
- return;
338
- }
339
- ({ 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)]));
340
- if (rows.length === 0) {
341
- await client.query("ROLLBACK");
342
- client.release();
343
- throw new error_1.DuplicateWorkflowEventError(workflowUUID, key);
344
- }
345
- await this.recordNotificationOutput(client, workflowUUID, functionID, undefined);
346
- await client.query("COMMIT");
347
- client.release();
348
- }
349
- async getEvent(workflowUUID, key, timeoutSeconds, callerUUID, functionID) {
350
- // Check if the operation has been done before for OAOO (only do this inside a workflow).
351
- if (callerUUID !== undefined && functionID !== undefined) {
352
- 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]);
353
- if (rows.length > 0) {
354
- return JSON.parse(rows[0].output);
355
- }
356
- }
357
- // Register the key with the global notifications listener.
358
- let resolveNotification;
359
- const valuePromise = new Promise((resolve) => {
360
- resolveNotification = resolve;
361
- });
362
- this.workflowEventsMap[`${workflowUUID}::${key}`] = resolveNotification; // The resolver assignment in the Promise definition runs synchronously.
363
- let timer;
364
- const timeoutPromise = new Promise((resolve) => {
365
- timer = setTimeout(() => {
366
- resolve();
367
- }, timeoutSeconds * 1000);
368
- });
369
- const received = Promise.race([valuePromise, timeoutPromise]);
370
- // Check if the key is already in the DB, then wait for the notification if it isn't.
371
- 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;
372
- if (initRecvRows.length === 0) {
373
- await received;
374
- }
375
- clearTimeout(timer);
376
- // Return the value if it's in the DB, otherwise return null.
377
- let value = null;
378
- if (initRecvRows.length > 0) {
379
- value = JSON.parse(initRecvRows[0].value);
380
- }
381
- else {
382
- // Read it again from the database.
383
- 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;
384
- if (finalRecvRows.length > 0) {
385
- value = JSON.parse(finalRecvRows[0].value);
386
- }
387
- }
388
- // Record the output if it is inside a workflow.
389
- if (callerUUID !== undefined && functionID !== undefined) {
390
- await this.recordOperationOutput(callerUUID, functionID, value);
391
- }
392
- return value;
393
- }
394
- async getWorkflowStatus(workflowUUID, callerUUID, functionID) {
395
- // Check if the operation has been done before for OAOO (only do this inside a workflow).
396
- if (callerUUID !== undefined && functionID !== undefined) {
397
- 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]);
398
- if (rows.length > 0) {
399
- return JSON.parse(rows[0].output);
400
- }
401
- }
402
- 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]);
403
- let value = null;
404
- if (rows.length > 0) {
405
- value = {
406
- status: rows[0].status,
407
- workflowName: rows[0].name,
408
- authenticatedUser: rows[0].authenticated_user,
409
- assumedRole: rows[0].assumed_role,
410
- authenticatedRoles: JSON.parse(rows[0].authenticated_roles),
411
- request: JSON.parse(rows[0].request),
412
- };
413
- }
414
- // Record the output if it is inside a workflow.
415
- if (callerUUID !== undefined && functionID !== undefined) {
416
- await this.recordOperationOutput(callerUUID, functionID, value);
417
- }
418
- return value;
419
- }
420
- async getWorkflowResult(workflowUUID) {
421
- const pollingIntervalMs = 1000;
422
- // eslint-disable-next-line no-constant-condition
423
- while (true) {
424
- const { rows } = await this.pool.query(`SELECT status, output, error FROM ${dbos_executor_1.DBOSExecutor.systemDBSchemaName}.workflow_status WHERE workflow_uuid=$1`, [workflowUUID]);
425
- if (rows.length > 0) {
426
- const status = rows[0].status;
427
- if (status === workflow_1.StatusString.SUCCESS) {
428
- return JSON.parse(rows[0].output);
429
- }
430
- else if (status === workflow_1.StatusString.ERROR) {
431
- throw (0, serialize_error_1.deserializeError)(JSON.parse(rows[0].error));
432
- }
433
- }
434
- await (0, utils_1.sleep)(pollingIntervalMs);
435
- }
436
- }
437
- /* BACKGROUND PROCESSES */
438
- /**
439
- * A background process that listens for notifications from Postgres then signals the appropriate
440
- * workflow listener by resolving its promise.
441
- */
442
- async listenForNotifications() {
443
- this.notificationsClient = await this.pool.connect();
444
- await this.notificationsClient.query("LISTEN dbos_notifications_channel;");
445
- await this.notificationsClient.query("LISTEN dbos_workflow_events_channel;");
446
- const handler = (msg) => {
447
- if (msg.channel === 'dbos_notifications_channel') {
448
- if (msg.payload && msg.payload in this.notificationsMap) {
449
- this.notificationsMap[msg.payload]();
450
- }
451
- }
452
- else {
453
- if (msg.payload && msg.payload in this.workflowEventsMap) {
454
- this.workflowEventsMap[msg.payload]();
455
- }
456
- }
457
- };
458
- this.notificationsClient.on("notification", handler);
459
- }
460
- }
461
- exports.PostgresSystemDatabase = PostgresSystemDatabase;
462
- //# 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;AAE1D,mCAAiD;AAGjD,gDAAwB;AACxB,gDAAwB;AAiDjB,KAAK,UAAU,qBAAqB,CAAC,gBAA4B;IACtE,MAAM,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,IAAA,uBAAe,EAAC,SAAS,CAAC,EAAE,YAAY,CAAC,CAAC;IAChF,MAAM,UAAU,GAAG;QACjB,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,gBAAgB;QAC5B,UAAU,EAAE;YACR,SAAS,EAAE,mBAAmB;YAC9B,SAAS,EAAE,iBAAiB;SAC/B;KACJ,CAAC;IACA,MAAM,MAAM,GAAG,IAAA,cAAI,EAAC,UAAU,CAAC,CAAA;IAC/B,MAAM,MAAM,CAAC,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M,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;AA1dD,wDA0dC"}
@@ -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"}