forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebhook.processor.ts
More file actions
28 lines (24 loc) · 870 Bytes
/
Copy pathwebhook.processor.ts
File metadata and controls
28 lines (24 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Process, Processor } from '@nestjs/bull';
import { Logger } from '@nestjs/common';
import { Job } from 'bull';
import { WebhookDeliveryService } from './webhook-delivery.service';
@Processor('webhook_queue')
export class WebhookProcessor {
private readonly logger = new Logger(WebhookProcessor.name);
constructor(
private readonly deliveryService: WebhookDeliveryService,
) {}
@Process('deliver')
async handleDelivery(job: Job<any>) {
this.logger.log(`Processing webhook delivery job ${job.id}`);
try {
await this.deliveryService.processDelivery(job.data);
this.logger.log(`Webhook delivery job ${job.id} completed successfully`);
} catch (error: any) {
this.logger.error(
`Webhook delivery job ${job.id} failed: ${error.message}`,
);
throw error; // Re-throw to trigger retry
}
}
}