Skip to content

Commit

Permalink
fix(queue): get rid of repeat options from defaultJobOptions (#1284)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Jun 16, 2022
1 parent 1769ce1 commit cdd2a20
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
3 changes: 2 additions & 1 deletion src/classes/queue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { get } from 'lodash';
import { v4 } from 'uuid';
import {
BaseJobOptions,
IoredisListener,
JobsOptions,
QueueOptions,
Expand Down Expand Up @@ -94,7 +95,7 @@ export class Queue<
NameType extends string = string,
> extends QueueGetters<DataType, ResultType, NameType> {
token = v4();
jobsOpts: JobsOptions;
jobsOpts: BaseJobOptions;
limiter: {
groupKey: string;
} = null;
Expand Down
58 changes: 27 additions & 31 deletions src/interfaces/jobs-options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RepeatOptions, KeepJobs, BackoffOptions } from './';

export interface JobsOptions {
export interface BaseJobOptions {
/**
* Timestamp when the job was created.
* @defaultValue Date.now()
Expand Down Expand Up @@ -28,16 +28,6 @@ export interface JobsOptions {
*/
attempts?: number;

/**
* Repeat this job, for example based on a `cron` schedule.
*/
repeat?: RepeatOptions;

/**
* Base repeat job key.
*/
repeatJobKey?: string;

/**
* Rate limiter key to use if rate limiter enabled.
*
Expand All @@ -57,21 +47,6 @@ export interface JobsOptions {
*/
lifo?: boolean;

/**
* The number of milliseconds after which the job should be
* fail with a timeout error.
*/
timeout?: number;

/**
* Override the job ID - by default, the job ID is a unique
* integer, but you can use this setting to override it.
* If you use this option, it is up to you to ensure the
* jobId is unique. If you attempt to add a job with an id that
* already exists, it will not be added.
*/
jobId?: string;

/**
* If true, removes the job when it successfully completes
* When given an number, it specifies the maximum amount of
Expand All @@ -94,6 +69,32 @@ export interface JobsOptions {
*/
stackTraceLimit?: number;

/**
* Limits the size in bytes of the job's data payload (as a JSON serialized string).
*/
sizeLimit?: number;
}

export interface JobsOptions extends BaseJobOptions {
/**
* Repeat this job, for example based on a `cron` schedule.
*/
repeat?: RepeatOptions;

/**
* Internal property used by repeatable jobs to save base repeat job key.
*/
repeatJobKey?: string;

/**
* Override the job ID - by default, the job ID is a unique
* integer, but you can use this setting to override it.
* If you use this option, it is up to you to ensure the
* jobId is unique. If you attempt to add a job with an id that
* already exists, it will not be added.
*/
jobId?: string;

/**
*
*/
Expand All @@ -106,9 +107,4 @@ export interface JobsOptions {
* Internal property used by repeatable jobs.
*/
prevMillis?: number;

/**
* Limits the size in bytes of the job's data payload (as a JSON serialized string).
*/
sizeLimit?: number;
}
4 changes: 2 additions & 2 deletions src/interfaces/queue-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JobsOptions } from './jobs-options';
import { BaseJobOptions } from './jobs-options';
import { ConnectionOptions } from './redis-options';

export enum ClientType {
Expand Down Expand Up @@ -35,7 +35,7 @@ export interface QueueBaseOptions {
* Options for the Queue class.
*/
export interface QueueOptions extends QueueBaseOptions {
defaultJobOptions?: JobsOptions;
defaultJobOptions?: BaseJobOptions;

/**
* Options for the rate limiter.
Expand Down

0 comments on commit cdd2a20

Please sign in to comment.