UNPKG

@axinom/mosaic-transactional-inbox-outbox

Version:

This library encapsulates the Mosaic based transactional inbox and outbox pattern

31 lines 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OutboxInboxHealthCheckHandler = exports.getServiceHealthCheckMessagingSettings = void 0; const inbox_1 = require("../inbox"); const getServiceHealthCheckMessagingSettings = (routingKey) => ({ messageType: 'OutboxInboxHealthCheckCommand', queue: 'inbox', routingKey, action: 'command', aggregateType: 'service', }); exports.getServiceHealthCheckMessagingSettings = getServiceHealthCheckMessagingSettings; class OutboxInboxHealthCheckHandler extends inbox_1.TransactionalInboxMessageHandler { /** * Constructor * @param messagingSettings The messaging settings - you can use `getServiceHealthCheckMessagingSettings` to create the object * @param config The service configuration including the serviceId * @param routingKey The routing key e.g. '<my-service>.health_check' */ constructor(messagingSettings, logger, config) { super(messagingSettings, logger, config); } async handleMessage({ payload }, rootClient) { await rootClient.query('UPDATE app_private.messaging_health SET success = true WHERE key = $1;', [payload.nonce]); } async handleErrorMessage(_error, { payload }, rootClient) { await rootClient.query('UPDATE app_private.messaging_health SET success = false WHERE key = $1;', [payload.nonce]); } } exports.OutboxInboxHealthCheckHandler = OutboxInboxHealthCheckHandler; //# sourceMappingURL=outbox-inbox-health-check-handler.js.map