@goparrot/pubsub-event-bus
Version:
NestJS EventBus extension for RabbitMQ PubSub
39 lines • 1.43 kB
JavaScript
import { __decorate } from "tslib";
import { Injectable } from '@nestjs/common';
import { AutoAckEnum } from '../../interface';
import { AbstractHandleWrapperStrategy } from './AbstractHandleWrapperStrategy';
let ManualStrategy = class ManualStrategy extends AbstractHandleWrapperStrategy {
constructor() {
super(...arguments);
this.strategy = AutoAckEnum.NEVER;
}
implementAckAndNack(handlerWrapper, channelWrapper) {
const { handler } = handlerWrapper;
Reflect.defineProperty(handler.prototype, 'ack', {
...Reflect.getOwnPropertyDescriptor(handler.prototype, 'ack'),
value(event) {
const message = event.message();
if (message) {
channelWrapper.ack(message);
}
},
});
Reflect.defineProperty(handler.prototype, 'nack', {
...Reflect.getOwnPropertyDescriptor(handler.prototype, 'nack'),
value(event) {
const message = event.message();
if (message) {
channelWrapper.nack(message);
}
},
});
}
process(handlerWrapper, channelWrapper) {
this.implementAckAndNack(handlerWrapper, channelWrapper);
}
};
ManualStrategy = __decorate([
Injectable()
], ManualStrategy);
export { ManualStrategy };
//# sourceMappingURL=ManualStrategy.js.map