1 | import * as express from "express";
|
2 | import { Request } from "../../common/providers/https";
|
3 | import { RateLimits, RetryConfig, TaskContext } from "../../common/providers/tasks";
|
4 | import { ManifestEndpoint, ManifestRequiredAPI } from "../../runtime/manifest";
|
5 | export { RetryConfig, RateLimits, TaskContext };
|
6 | /**
|
7 | * Options for configuring the task queue to listen to.
|
8 | */
|
9 | export interface TaskQueueOptions {
|
10 | /** How a task should be retried in the event of a non-2xx return. */
|
11 | retryConfig?: RetryConfig;
|
12 | /** How congestion control should be applied to the function. */
|
13 | rateLimits?: RateLimits;
|
14 | /**
|
15 | * Who can enqueue tasks for this function.
|
16 | * If left unspecified, only service accounts which have
|
17 | * `roles/cloudtasks.enqueuer` and `roles/cloudfunctions.invoker`
|
18 | * will have permissions.
|
19 | */
|
20 | invoker?: "private" | string | string[];
|
21 | }
|
22 | /**
|
23 | * A handler for tasks.
|
24 | */
|
25 | export interface TaskQueueFunction {
|
26 | (req: Request, res: express.Response): Promise<void>;
|
27 | /** @alpha */
|
28 | __trigger: unknown;
|
29 | /** @alpha */
|
30 | __endpoint: ManifestEndpoint;
|
31 | /** @alpha */
|
32 | __requiredAPIs?: ManifestRequiredAPI[];
|
33 | /**
|
34 | * The callback passed to the `TaskQueueFunction` constructor.
|
35 | * @param data - The body enqueued into a task queue.
|
36 | * @param context - The request context of the enqueued task
|
37 | * @returns Any return value. Google Cloud Functions will await any promise
|
38 | * before shutting down your function. Resolved return values
|
39 | * are only used for unit testing purposes.
|
40 | */
|
41 | run(data: any, context: TaskContext): void | Promise<void>;
|
42 | }
|
43 | /**
|
44 | * Builder for creating a `TaskQueueFunction`.
|
45 | */
|
46 | export declare class TaskQueueBuilder {
|
47 | private readonly tqOpts?;
|
48 | private readonly depOpts?;
|
49 | /**
|
50 | * Creates a handler for tasks sent to a Google Cloud Tasks queue.
|
51 | * @param handler - A callback to handle task requests.
|
52 | * @returns A function you can export and deploy.
|
53 | */
|
54 | onDispatch(handler: (data: any, context: TaskContext) => void | Promise<void>): TaskQueueFunction;
|
55 | }
|
56 | /**
|
57 | * Declares a function that can handle tasks enqueued using the Firebase Admin SDK.
|
58 | * @param options - Configuration for the Task Queue that feeds into this function.
|
59 | * Omitting options will configure a Task Queue with default settings.
|
60 | */
|
61 | export declare function taskQueue(options?: TaskQueueOptions): TaskQueueBuilder;
|