1 | import { ResetValue } from "../../common/options";
|
2 | import { timezone } from "../../common/timezone";
|
3 | import { ManifestRequiredAPI } from "../../runtime/manifest";
|
4 | import { HttpsFunction } from "./https";
|
5 | import { Expression } from "../../params";
|
6 | import * as options from "../options";
|
7 | /**
|
8 | * Interface representing a ScheduleEvent that is passed to the function handler.
|
9 | */
|
10 | export interface ScheduledEvent {
|
11 | /**
|
12 | * The Cloud Scheduler job name.
|
13 | * Populated via the X-CloudScheduler-JobName header.
|
14 | *
|
15 | * If invoked manually, this field is undefined.
|
16 | */
|
17 | jobName?: string;
|
18 | /**
|
19 | * For Cloud Scheduler jobs specified in the unix-cron format,
|
20 | * this is the job schedule time in RFC3339 UTC "Zulu" format.
|
21 | * Populated via the X-CloudScheduler-ScheduleTime header.
|
22 | *
|
23 | * If the schedule is manually triggered, this field will be
|
24 | * the function execution time.
|
25 | */
|
26 | scheduleTime: string;
|
27 | }
|
28 | /** The Cloud Function type for Schedule triggers. */
|
29 | export interface ScheduleFunction extends HttpsFunction {
|
30 | __requiredAPIs?: ManifestRequiredAPI[];
|
31 | run(data: ScheduledEvent): void | Promise<void>;
|
32 | }
|
33 | /** Options that can be set on a Schedule trigger. */
|
34 | export interface ScheduleOptions extends options.GlobalOptions {
|
35 | /** The schedule, in Unix Crontab or AppEngine syntax. */
|
36 | schedule: string;
|
37 | /** The timezone that the schedule executes in. */
|
38 | timeZone?: timezone | Expression<string> | ResetValue;
|
39 | /** The number of retry attempts for a failed run. */
|
40 | retryCount?: number | Expression<number> | ResetValue;
|
41 | /** The time limit for retrying. */
|
42 | maxRetrySeconds?: number | Expression<number> | ResetValue;
|
43 | /** The minimum time to wait before retying. */
|
44 | minBackoffSeconds?: number | Expression<number> | ResetValue;
|
45 | /** The maximum time to wait before retrying. */
|
46 | maxBackoffSeconds?: number | Expression<number> | ResetValue;
|
47 | /** The time between will double max doublings times. */
|
48 | maxDoublings?: number | Expression<number> | ResetValue;
|
49 | }
|
50 | /**
|
51 | * Handler for scheduled functions. Triggered whenever the associated
|
52 | * scheduler job sends a http request.
|
53 | * @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
|
54 | * @param handler - A function to execute when triggered.
|
55 | * @returns A function that you can export and deploy.
|
56 | */
|
57 | export declare function onSchedule(schedule: string, handler: (event: ScheduledEvent) => void | Promise<void>): ScheduleFunction;
|
58 | /**
|
59 | * Handler for scheduled functions. Triggered whenever the associated
|
60 | * scheduler job sends a http request.
|
61 | * @param options - Options to set on scheduled functions.
|
62 | * @param handler - A function to execute when triggered.
|
63 | * @returns A function that you can export and deploy.
|
64 | */
|
65 | export declare function onSchedule(options: ScheduleOptions, handler: (event: ScheduledEvent) => void | Promise<void>): ScheduleFunction;
|