Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(queue): get rid of repeat options from default #1284

Merged
merged 2 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this option really needed? I am thinking the user is not able to configure this key, it is computed automatically from the "repeat" option.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, in this case is like prevMillis option, I'll change the description as prevMillis saying that this is an internal param


/**
* 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