feat: billing sync (cloud) (#899)

* Set page history to 5 minutes interval

* * Configure default queue options

* sync

* * stripe seats sync (cloud)
This commit is contained in:
Philip Okugbe
2025-03-17 11:00:23 +00:00
committed by GitHub
parent 21c3ad0ecc
commit f45bdddb23
8 changed files with 44 additions and 14 deletions

View File

@ -2,6 +2,7 @@ export enum QueueName {
EMAIL_QUEUE = '{email-queue}',
ATTACHMENT_QUEUE = '{attachment-queue}',
GENERAL_QUEUE = '{general-queue}',
BILLING_QUEUE = '{billing-queue}',
}
export enum QueueJob {
@ -11,6 +12,6 @@ export enum QueueJob {
PAGE_CONTENT_UPDATE = 'page-content-update',
PAGE_BACKLINKS = 'page-backlinks',
STRIPE_SEATS_SYNC = 'sync-stripe-seats',
}

View File

@ -5,4 +5,8 @@ export interface IPageBacklinkJob {
pageId: string;
workspaceId: string;
mentions: MentionNode[];
}
export interface IStripeSeatsSyncJob {
workspaceId: string;
}

View File

@ -106,19 +106,25 @@ export class BacklinksProcessor extends WorkerHost implements OnModuleDestroy {
@OnWorkerEvent('active')
onActive(job: Job) {
this.logger.debug(`Processing ${job.name} job`);
if (job.name === QueueJob.PAGE_BACKLINKS) {
this.logger.debug(`Processing ${job.name} job`);
}
}
@OnWorkerEvent('failed')
onError(job: Job) {
this.logger.error(
`Error processing ${job.name} job. Reason: ${job.failedReason}`,
);
if (job.name === QueueJob.PAGE_BACKLINKS) {
this.logger.error(
`Error processing ${job.name} job. Reason: ${job.failedReason}`,
);
}
}
@OnWorkerEvent('completed')
onCompleted(job: Job) {
this.logger.debug(`Completed ${job.name} job`);
if (job.name === QueueJob.PAGE_BACKLINKS) {
this.logger.debug(`Completed ${job.name} job`);
}
}
async onModuleDestroy(): Promise<void> {

View File

@ -24,7 +24,13 @@ import { BacklinksProcessor } from './processors/backlinks.processor';
attempts: 3,
backoff: {
type: 'exponential',
delay: 10000,
delay: 20 * 1000,
},
removeOnComplete: {
count: 200,
},
removeOnFail: {
count: 100,
},
},
};
@ -40,6 +46,9 @@ import { BacklinksProcessor } from './processors/backlinks.processor';
BullModule.registerQueue({
name: QueueName.GENERAL_QUEUE,
}),
BullModule.registerQueue({
name: QueueName.BILLING_QUEUE,
}),
],
exports: [BullModule],
providers: [BacklinksProcessor],