fixing up db's and data-service
This commit is contained in:
parent
aca98fdce4
commit
71f9b0a886
9 changed files with 211 additions and 19 deletions
|
|
@ -94,6 +94,34 @@ export class Queue {
|
|||
return await this.bullQueue.addBulk(jobs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a scheduled job with cron-like pattern
|
||||
*/
|
||||
async addScheduledJob(
|
||||
name: string,
|
||||
data: JobData,
|
||||
cronPattern: string,
|
||||
options: JobOptions = {}
|
||||
): Promise<Job> {
|
||||
const scheduledOptions: JobOptions = {
|
||||
...options,
|
||||
repeat: {
|
||||
pattern: cronPattern,
|
||||
// Use job name as repeat key to prevent duplicates
|
||||
key: `${this.queueName}:${name}`,
|
||||
},
|
||||
};
|
||||
|
||||
logger.info('Adding scheduled job', {
|
||||
queueName: this.queueName,
|
||||
jobName: name,
|
||||
cronPattern,
|
||||
repeatKey: scheduledOptions.repeat?.key
|
||||
});
|
||||
|
||||
return await this.bullQueue.add(name, data, scheduledOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get queue statistics
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -46,6 +46,13 @@ export interface JobOptions {
|
|||
type: 'exponential' | 'fixed';
|
||||
delay: number;
|
||||
};
|
||||
repeat?: {
|
||||
pattern?: string;
|
||||
key?: string;
|
||||
limit?: number;
|
||||
every?: number;
|
||||
immediately?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface QueueOptions {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue