mirror of
https://github.com/docmost/docmost.git
synced 2025-11-18 23:11:12 +10:00
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:
@ -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',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,4 +5,8 @@ export interface IPageBacklinkJob {
|
||||
pageId: string;
|
||||
workspaceId: string;
|
||||
mentions: MentionNode[];
|
||||
}
|
||||
|
||||
export interface IStripeSeatsSyncJob {
|
||||
workspaceId: string;
|
||||
}
|
||||
@ -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> {
|
||||
|
||||
@ -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],
|
||||
|
||||
Reference in New Issue
Block a user