@sotatech/nest-taskflow
Version:
A task flow management library for NestJS with Redis Pub/Sub integration.
28 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OnTaskVerified = OnTaskVerified;
const common_1 = require("@nestjs/common");
const event_emitter_1 = require("@nestjs/event-emitter");
const callback_helper_1 = require("../callback/callback-helper");
function OnTaskVerified(queueName, options = {}) {
const logger = new common_1.Logger('OnTaskVerified');
return (target, propertyKey, descriptor) => {
const originalMethod = descriptor.value;
descriptor.value = async function (...args) {
const [event] = args;
const { id: taskId } = event;
if (!taskId) {
logger.error('Task ID is required for retry logic');
return;
}
const callbackFn = async () => {
logger.log(`Executing task verification for task ${taskId}`);
return originalMethod.apply(this, args);
};
await callback_helper_1.CallbackHelper.executeWithRetry(callbackFn, taskId, options);
};
(0, event_emitter_1.OnEvent)(`task.verified.${queueName}`)(target, propertyKey, descriptor);
return descriptor;
};
}
//# sourceMappingURL=on-task-verified.decorator.js.map