Skip to content

Commit 781590c

Browse files
authored
feat: remove attemptDeadlineSeconds in v2 scheduled functions (#1776)
* feat: tie scheduled function attemptDeadline to timeoutSeconds * feat: tie scheduled function attemptDeadline to timeoutSeconds * run formatter. * run formatter. * nit: fix formatting
1 parent 2c2c78d commit 781590c

File tree

4 files changed

+5
-25
lines changed

4 files changed

+5
-25
lines changed

spec/runtime/manifest.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ describe("initScheduleTrigger", () => {
286286
expect(st).to.deep.eq({
287287
schedule: "every 30 minutes",
288288
timeZone: RESET_VALUE,
289-
attemptDeadlineSeconds: RESET_VALUE,
290289
retryConfig: {
291290
retryCount: RESET_VALUE,
292291
maxDoublings: RESET_VALUE,

spec/v2/providers/scheduler.spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { runHandler } from "../../helper";
3232
const MINIMAL_SCHEDULE_TRIGGER: ManifestEndpoint["scheduleTrigger"] = {
3333
schedule: "",
3434
timeZone: options.RESET_VALUE,
35-
attemptDeadlineSeconds: options.RESET_VALUE,
3635
retryConfig: {
3736
retryCount: options.RESET_VALUE,
3837
maxRetrySeconds: options.RESET_VALUE,
@@ -67,7 +66,6 @@ describe("schedule", () => {
6766
expect(schedule.getOpts(options)).to.deep.eq({
6867
schedule: "* * * * *",
6968
timeZone: "utc",
70-
attemptDeadlineSeconds: undefined,
7169
retryConfig: {
7270
retryCount: 3,
7371
maxRetrySeconds: 1,
@@ -110,7 +108,7 @@ describe("schedule", () => {
110108
{
111109
schedule: "* * * * *",
112110
timeZone: "utc",
113-
attemptDeadlineSeconds: 300,
111+
timeoutSeconds: 300,
114112
retryCount: 3,
115113
maxRetrySeconds: 10,
116114
minBackoffSeconds: 11,
@@ -127,10 +125,10 @@ describe("schedule", () => {
127125
platform: "gcfv2",
128126
labels: { key: "val" },
129127
region: ["us-central1"],
128+
timeoutSeconds: 300,
130129
scheduleTrigger: {
131130
schedule: "* * * * *",
132131
timeZone: "utc",
133-
attemptDeadlineSeconds: 300,
134132
retryConfig: {
135133
retryCount: 3,
136134
maxRetrySeconds: 10,
@@ -163,7 +161,6 @@ describe("schedule", () => {
163161
scheduleTrigger: {
164162
schedule: "* * * * *",
165163
timeZone: undefined,
166-
attemptDeadlineSeconds: undefined,
167164
retryConfig: {
168165
retryCount: undefined,
169166
maxRetrySeconds: undefined,

src/runtime/manifest.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export interface ManifestEndpoint {
9797
scheduleTrigger?: {
9898
schedule: string | Expression<string>;
9999
timeZone?: string | Expression<string> | ResetValue;
100-
attemptDeadlineSeconds?: number | Expression<number> | ResetValue;
101100
retryConfig?: {
102101
retryCount?: number | Expression<number> | ResetValue;
103102
maxRetrySeconds?: string | Expression<string> | ResetValue;
@@ -260,14 +259,12 @@ const RESETTABLE_V1_SCHEDULE_OPTIONS: Omit<
260259
const RESETTABLE_V2_SCHEDULE_OPTIONS: Omit<
261260
ResettableKeys<ManifestEndpoint["scheduleTrigger"]["retryConfig"]>,
262261
"maxRetryDuration" | "maxBackoffDuration" | "minBackoffDuration"
263-
> &
264-
Pick<ResettableKeys<ManifestEndpoint["scheduleTrigger"]>, "attemptDeadlineSeconds"> = {
262+
> = {
265263
retryCount: null,
266264
maxDoublings: null,
267265
maxRetrySeconds: null,
268266
minBackoffSeconds: null,
269267
maxBackoffSeconds: null,
270-
attemptDeadlineSeconds: null,
271268
};
272269

273270
function initScheduleTrigger(
@@ -281,11 +278,7 @@ function initScheduleTrigger(
281278
};
282279
if (opts.every((opt) => !opt?.preserveExternalChanges)) {
283280
for (const key of Object.keys(resetOptions)) {
284-
if (key === "attemptDeadlineSeconds") {
285-
scheduleTrigger[key] = RESET_VALUE;
286-
} else {
287-
scheduleTrigger.retryConfig[key] = RESET_VALUE;
288-
}
281+
scheduleTrigger.retryConfig[key] = RESET_VALUE;
289282
}
290283
scheduleTrigger = { ...scheduleTrigger, timeZone: RESET_VALUE };
291284
}

src/v2/providers/scheduler.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import { withInit } from "../../common/onInit";
4242
interface SeparatedOpts {
4343
schedule: string | Expression<string>;
4444
timeZone?: timezone | Expression<string> | ResetValue;
45-
attemptDeadlineSeconds?: number | Expression<number> | ResetValue;
4645
retryConfig?: {
4746
retryCount?: number | Expression<number> | ResetValue;
4847
maxRetrySeconds?: number | Expression<number> | ResetValue;
@@ -64,7 +63,6 @@ export function getOpts(args: string | ScheduleOptions): SeparatedOpts {
6463
return {
6564
schedule: args.schedule,
6665
timeZone: args.timeZone,
67-
attemptDeadlineSeconds: args.attemptDeadlineSeconds,
6866
retryConfig: {
6967
retryCount: args.retryCount,
7068
maxRetrySeconds: args.maxRetrySeconds,
@@ -113,13 +111,6 @@ export interface ScheduleOptions extends options.GlobalOptions {
113111
/** The timezone that the schedule executes in. */
114112
timeZone?: timezone | Expression<string> | ResetValue;
115113

116-
/**
117-
* The deadline for job attempts in seconds. If the request handler does not respond by this deadline,
118-
* the request is cancelled and the attempt is marked as a `DEADLINE_EXCEEDED` failure.
119-
* The value must be between 15 and 1800. Defaults to 180.
120-
*/
121-
attemptDeadlineSeconds?: number | Expression<number> | ResetValue;
122-
123114
/** The number of retry attempts for a failed run. */
124115
retryCount?: number | Expression<number> | ResetValue;
125116

@@ -205,7 +196,7 @@ export function onSchedule(
205196
scheduleTrigger: initV2ScheduleTrigger(separatedOpts.schedule, globalOpts, separatedOpts.opts),
206197
};
207198

208-
copyIfPresent(ep.scheduleTrigger, separatedOpts, "timeZone", "attemptDeadlineSeconds");
199+
copyIfPresent(ep.scheduleTrigger, separatedOpts, "timeZone");
209200
copyIfPresent(
210201
ep.scheduleTrigger.retryConfig,
211202
separatedOpts.retryConfig,

0 commit comments

Comments
 (0)