Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions spec/runtime/manifest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ describe("initScheduleTrigger", () => {
expect(st).to.deep.eq({
schedule: "every 30 minutes",
timeZone: RESET_VALUE,
attemptDeadlineSeconds: RESET_VALUE,
retryConfig: {
retryCount: RESET_VALUE,
maxDoublings: RESET_VALUE,
Expand Down
5 changes: 5 additions & 0 deletions spec/v2/providers/scheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { runHandler } from "../../helper";
const MINIMAL_SCHEDULE_TRIGGER: ManifestEndpoint["scheduleTrigger"] = {
schedule: "",
timeZone: options.RESET_VALUE,
attemptDeadlineSeconds: options.RESET_VALUE,
retryConfig: {
retryCount: options.RESET_VALUE,
maxRetrySeconds: options.RESET_VALUE,
Expand Down Expand Up @@ -66,6 +67,7 @@ describe("schedule", () => {
expect(schedule.getOpts(options)).to.deep.eq({
schedule: "* * * * *",
timeZone: "utc",
attemptDeadlineSeconds: undefined,
retryConfig: {
retryCount: 3,
maxRetrySeconds: 1,
Expand Down Expand Up @@ -108,6 +110,7 @@ describe("schedule", () => {
{
schedule: "* * * * *",
timeZone: "utc",
attemptDeadlineSeconds: 300,
retryCount: 3,
maxRetrySeconds: 10,
minBackoffSeconds: 11,
Expand All @@ -127,6 +130,7 @@ describe("schedule", () => {
scheduleTrigger: {
schedule: "* * * * *",
timeZone: "utc",
attemptDeadlineSeconds: 300,
retryConfig: {
retryCount: 3,
maxRetrySeconds: 10,
Expand Down Expand Up @@ -159,6 +163,7 @@ describe("schedule", () => {
scheduleTrigger: {
schedule: "* * * * *",
timeZone: undefined,
attemptDeadlineSeconds: undefined,
retryConfig: {
retryCount: undefined,
maxRetrySeconds: undefined,
Expand Down
11 changes: 9 additions & 2 deletions src/runtime/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export interface ManifestEndpoint {
scheduleTrigger?: {
schedule: string | Expression<string>;
timeZone?: string | Expression<string> | ResetValue;
attemptDeadlineSeconds?: number | Expression<number> | ResetValue;
retryConfig?: {
retryCount?: number | Expression<number> | ResetValue;
maxRetrySeconds?: string | Expression<string> | ResetValue;
Expand Down Expand Up @@ -259,12 +260,14 @@ const RESETTABLE_V1_SCHEDULE_OPTIONS: Omit<
const RESETTABLE_V2_SCHEDULE_OPTIONS: Omit<
ResettableKeys<ManifestEndpoint["scheduleTrigger"]["retryConfig"]>,
"maxRetryDuration" | "maxBackoffDuration" | "minBackoffDuration"
> = {
> &
Pick<ResettableKeys<ManifestEndpoint["scheduleTrigger"]>, "attemptDeadlineSeconds"> = {
retryCount: null,
maxDoublings: null,
maxRetrySeconds: null,
minBackoffSeconds: null,
maxBackoffSeconds: null,
attemptDeadlineSeconds: null,
};

function initScheduleTrigger(
Expand All @@ -278,7 +281,11 @@ function initScheduleTrigger(
};
if (opts.every((opt) => !opt?.preserveExternalChanges)) {
for (const key of Object.keys(resetOptions)) {
scheduleTrigger.retryConfig[key] = RESET_VALUE;
if (key === "attemptDeadlineSeconds") {
scheduleTrigger[key] = RESET_VALUE;
} else {
scheduleTrigger.retryConfig[key] = RESET_VALUE;
}
}
scheduleTrigger = { ...scheduleTrigger, timeZone: RESET_VALUE };
}
Expand Down
7 changes: 6 additions & 1 deletion src/v2/providers/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { withInit } from "../../common/onInit";
interface SeparatedOpts {
schedule: string | Expression<string>;
timeZone?: timezone | Expression<string> | ResetValue;
attemptDeadlineSeconds?: number | Expression<number> | ResetValue;
retryConfig?: {
retryCount?: number | Expression<number> | ResetValue;
maxRetrySeconds?: number | Expression<number> | ResetValue;
Expand All @@ -63,6 +64,7 @@ export function getOpts(args: string | ScheduleOptions): SeparatedOpts {
return {
schedule: args.schedule,
timeZone: args.timeZone,
attemptDeadlineSeconds: args.attemptDeadlineSeconds,
retryConfig: {
retryCount: args.retryCount,
maxRetrySeconds: args.maxRetrySeconds,
Expand Down Expand Up @@ -111,6 +113,9 @@ export interface ScheduleOptions extends options.GlobalOptions {
/** The timezone that the schedule executes in. */
timeZone?: timezone | Expression<string> | ResetValue;

/** The deadline for job attempts. Defaults to 180 seconds. */
attemptDeadlineSeconds?: number | Expression<number> | ResetValue;

/** The number of retry attempts for a failed run. */
retryCount?: number | Expression<number> | ResetValue;

Expand Down Expand Up @@ -196,7 +201,7 @@ export function onSchedule(
scheduleTrigger: initV2ScheduleTrigger(separatedOpts.schedule, globalOpts, separatedOpts.opts),
};

copyIfPresent(ep.scheduleTrigger, separatedOpts, "timeZone");
copyIfPresent(ep.scheduleTrigger, separatedOpts, "timeZone", "attemptDeadlineSeconds");
copyIfPresent(
ep.scheduleTrigger.retryConfig,
separatedOpts.retryConfig,
Expand Down
Loading