UNPKG

pg-transactional-outbox

Version:

A PostgreSQL based transactional outbox and inbox pattern implementation to support exactly once message processing (with at least once message delivery).

24 lines 1.58 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.markMessageAbandoned = void 0; /** * Marks the message as abandoned by setting the abandoned_at date to the current date and time. * @param message The message to mark as abandoned. * @param client The database client. Must be part of the transaction where the error handling changes are done. * @param config The configuration settings that defines database schema. */ const markMessageAbandoned = (_a, client_1, _b) => __awaiter(void 0, [_a, client_1, _b], void 0, function* ({ id }, client, { settings }) { yield client.query( /* sql */ `UPDATE ${settings.dbSchema}.${settings.dbTable} SET abandoned_at = clock_timestamp(), finished_attempts = finished_attempts + 1 WHERE id = $1;`, [id]); }); exports.markMessageAbandoned = markMessageAbandoned; //# sourceMappingURL=mark-message-abandoned.js.map