Skip to content

Commit

Permalink
fix: allow passing forkMode to every
Browse files Browse the repository at this point in the history
  • Loading branch information
simllll committed May 10, 2022
1 parent 7dbc668 commit ff274ba
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,31 +387,31 @@ export class Agenda extends EventEmitter {
interval: string | number,
names: string[],
data?: undefined,
options?: { timezone?: string; skipImmediate?: boolean }
options?: { timezone?: string; skipImmediate?: boolean; forkMode?: boolean }
): Promise<Job<void>[]>;
async every(
interval: string | number,
name: string,
data?: undefined,
options?: { timezone?: string; skipImmediate?: boolean }
options?: { timezone?: string; skipImmediate?: boolean; forkMode?: boolean }
): Promise<Job<void>>;
async every<DATA = unknown>(
interval: string | number,
names: string[],
data: DATA,
options?: { timezone?: string; skipImmediate?: boolean }
options?: { timezone?: string; skipImmediate?: boolean; forkMode?: boolean }
): Promise<Job<DATA>[]>;
async every<DATA = unknown>(
interval: string | number,
name: string,
data: DATA,
options?: { timezone?: string; skipImmediate?: boolean }
options?: { timezone?: string; skipImmediate?: boolean; forkMode?: boolean }
): Promise<Job<DATA>>;
async every(
interval: string | number,
names: string | string[],
data?: unknown,
options?: { timezone?: string; skipImmediate?: boolean }
options?: { timezone?: string; skipImmediate?: boolean; forkMode?: boolean }
): Promise<Job<any> | Job<any>[]> {
/**
* Internal method to setup job that gets run every interval
Expand All @@ -427,6 +427,9 @@ export class Agenda extends EventEmitter {
const job = this.create(name, data);
job.attrs.type = 'single';
job.repeatEvery(interval, options);
if (options?.forkMode) {
job.forkMode(options.forkMode)
}
await job.save();

return job;
Expand Down

0 comments on commit ff274ba

Please sign in to comment.