Skip to content
Open
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
1 change: 1 addition & 0 deletions src/deploy/functions/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface ScheduleTrigger {
schedule?: string;
timeZone?: string | null;
retryConfig?: ScheduleRetryConfig | null;
attemptDeadline?: string | null;
}

/** Something that has a ScheduleTrigger */
Expand Down
4 changes: 4 additions & 0 deletions src/deploy/functions/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export interface ScheduleTrigger {
schedule: string | Expression<string>;
timeZone?: Field<string>;
retryConfig?: ScheduleRetryConfig | null;
attemptDeadline?: Field<string>;
}

export type HttpsTriggered = { httpsTrigger: HttpsTrigger };
Expand Down Expand Up @@ -602,6 +603,9 @@ function discoverTrigger(endpoint: Endpoint, region: string, r: Resolver): backe
if (endpoint.scheduleTrigger.timeZone !== undefined) {
bkSchedule.timeZone = r.resolveString(endpoint.scheduleTrigger.timeZone);
}
if (endpoint.scheduleTrigger.attemptDeadline !== undefined) {
bkSchedule.attemptDeadline = r.resolveString(endpoint.scheduleTrigger.attemptDeadline);
}
Comment on lines 603 to +608
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness and consistency with other parts of the codebase (e.g., lines 597 and 611), you can use the r.resolveStrings helper function to resolve both timeZone and attemptDeadline.

    r.resolveStrings(bkSchedule, endpoint.scheduleTrigger, "timeZone", "attemptDeadline");

if (endpoint.scheduleTrigger.retryConfig) {
const bkRetry: backend.ScheduleRetryConfig = {};
r.resolveInts(
Expand Down
2 changes: 2 additions & 0 deletions src/deploy/functions/runtimes/discovery/v1alpha1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ function assertBuildEndpoint(ep: WireEndpoint, id: string): void {
schedule: "Field<string>",
timeZone: "Field<string>?",
retryConfig: "object?",
attemptDeadline: "Field<string>?",
});
if (ep.scheduleTrigger.retryConfig) {
assertKeyTypes(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
Expand Down Expand Up @@ -320,6 +321,7 @@ function parseEndpointForBuild(
// invalid values before actually modifying prod.
schedule: ep.scheduleTrigger.schedule || "",
timeZone: ep.scheduleTrigger.timeZone ?? null,
attemptDeadline: ep.scheduleTrigger.attemptDeadline ?? null,
};
if (ep.scheduleTrigger.retryConfig) {
st.retryConfig = {};
Expand Down
4 changes: 4 additions & 0 deletions src/gcp/cloudscheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface HttpTarget {
httpMethod: HttpMethod;
headers?: Record<string, string>;
body?: string;
attemptDeadline?: string;

// oneof authorizationHeader
oauthToken?: OauthToken;
Expand Down Expand Up @@ -249,6 +250,9 @@ export async function jobFromEndpoint(
endpoint.serviceAccount ?? (await gce.getDefaultServiceAccount(projectNumber)),
},
};
if (endpoint.scheduleTrigger.attemptDeadline) {
job.httpTarget.attemptDeadline = endpoint.scheduleTrigger.attemptDeadline;
}
} else {
assertExhaustive(endpoint.platform);
}
Expand Down