Skip to content

Commit

Permalink
feat: add timezone option to request job options
Browse files Browse the repository at this point in the history
  • Loading branch information
yujiosaka committed Oct 25, 2023
1 parent d1b269b commit 2be0f51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ requestJobStart(options: JobStartOptions): Promise<Job>
- `startBuffer?` (**optional**): [Duration] | [number] - Adds a delay before the job starts.
- `retryInterval?` (**optional**): [Duration] | [number] - Allows bypassing of an active job lock after a specified period.
- `requiredJobNames?` (**optional**): [Array]<[string]> - Specifies dependencies using their job names.
- `timezone?` (**optional**): [string] - Overrides `timezone` of the constructor argument.
- `noLock?` (**optional**): [boolean] - Bypasses job locks, letting other processes run the job.
- `jobIntervalStartedAt?` (**optional**): [Date] - Sets the start interval manually. Use with the `noLock` option.

Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type BaseRequestJobOptions = {
startBuffer?: Duration | number;
retryInterval?: Duration | number;
requiredJobNames?: string[];
timezone?: string;
};

/**
Expand All @@ -61,7 +62,7 @@ export default class Cronyx<S extends BaseJobStore<I>, I = JobLockId<S>> {

async requestJobExec(options: RequestJobOptions, task: (job: Job<I>) => Promise<void>): Promise<void> {
const jobRunner = new JobRunner(this.#jobStore, options.jobName, options.jobInterval, {
timezone: this.#timezone,
timezone: options.timezone ?? this.#timezone,
requiredJobNames: options.requiredJobNames,
startBuffer: options.startBuffer,
retryInterval: options.retryInterval,
Expand All @@ -73,7 +74,7 @@ export default class Cronyx<S extends BaseJobStore<I>, I = JobLockId<S>> {

async requestJobStart(options: RequestJobOptions): Promise<Job<I> | null> {
const jobRunner = new JobRunner(this.#jobStore, options.jobName, options.jobInterval, {
timezone: this.#timezone,
timezone: options.timezone ?? this.#timezone,
requiredJobNames: options.requiredJobNames,
startBuffer: options.startBuffer,
retryInterval: options.retryInterval,
Expand Down

0 comments on commit 2be0f51

Please sign in to comment.