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.56 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.increaseMessageFinishedAttempts = void 0; /** * Does increase the finished_attempts count by one. * @param message The message to NOT acknowledge. * @param client The database client. Must be part of the transaction where the message handling changes are done. * @param config The configuration settings that defines the database schema. */ const increaseMessageFinishedAttempts = (_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 finished_attempts = finished_attempts + 1 WHERE id = $1;`, [id]); }); exports.increaseMessageFinishedAttempts = increaseMessageFinishedAttempts; //# sourceMappingURL=increase-message-finished-attempts.js.map