@@ -38,51 +38,67 @@ import {
3838import { DeploymentOptions } from '../function-configuration' ;
3939import { ManifestEndpoint , ManifestRequiredAPI } from '../runtime/manifest' ;
4040
41- export {
42- /** @hidden */
43- RetryConfig as RetryPolicy ,
44- /** @hidden */
45- RateLimits ,
46- /** @hidden */
47- TaskContext ,
48- } ;
41+ export { RetryConfig , RateLimits , TaskContext } ;
4942
5043/**
51- * Configurations for Task Queue Functions.
52- * @hidden
44+ * Options for configuring the task queue to listen to.
5345 */
5446export interface TaskQueueOptions {
47+ /** How a task should be retried in the event of a non-2xx return. */
5548 retryConfig ?: RetryConfig ;
49+ /** How congestion control should be applied to the function. */
5650 rateLimits ?: RateLimits ;
5751
5852 /**
5953 * Who can enqueue tasks for this function.
6054 * If left unspecified, only service accounts which have
61- * roles/cloudtasks.enqueuer and roles/cloudfunctions.invoker
55+ * ` roles/cloudtasks.enqueuer` and ` roles/cloudfunctions.invoker`
6256 * will have permissions.
6357 */
6458 invoker ?: 'private' | string | string [ ] ;
6559}
6660
67- /** @hidden */
61+ /**
62+ * A handler for tasks.
63+ */
6864export interface TaskQueueFunction {
6965 ( req : Request , res : express . Response ) : Promise < void > ;
7066
67+ /** @alpha */
7168 __trigger : unknown ;
69+
70+ /** @alpha */
7271 __endpoint : ManifestEndpoint ;
72+
73+ /** @alpha */
7374 __requiredAPIs ?: ManifestRequiredAPI [ ] ;
7475
76+ /**
77+ * The callback passed to the `TaskQueueFunction` constructor.
78+ * @param data - The body enqueued into a task queue.
79+ * @param context - The request context of the enqueued task
80+ * @returns Any return value. Google Cloud Functions will await any promise
81+ * before shutting down your function. Resolved return values
82+ * are only used for unit testing purposes.
83+ */
7584 run ( data : any , context : TaskContext ) : void | Promise < void > ;
7685}
7786
78- /** @hidden */
87+ /**
88+ * Builder for creating a `TaskQueueFunction`.
89+ */
7990export class TaskQueueBuilder {
8091 /** @internal */
8192 constructor (
8293 private readonly tqOpts ?: TaskQueueOptions ,
8394 private readonly depOpts ?: DeploymentOptions
8495 ) { }
8596
97+ /**
98+ * Creates a handler for tasks sent to a Google Cloud Tasks queue.
99+ * @param handler - A callback to handle task requests.
100+ * @returns A Cloud Function you can export and deploy.
101+ */
86102 onDispatch (
87103 handler : ( data : any , context : TaskContext ) => void | Promise < void >
88104 ) : TaskQueueFunction {
@@ -137,8 +153,8 @@ export class TaskQueueBuilder {
137153
138154/**
139155 * Declares a function that can handle tasks enqueued using the Firebase Admin SDK.
140- * @param options Configuration for the Task Queue that feeds into this function.
141- * @hidden
156+ * @param options - Configuration for the Task Queue that feeds into this function.
157+ * Omitting options will configure a Task Queue with default settings.
142158 */
143159export function taskQueue ( options ?: TaskQueueOptions ) : TaskQueueBuilder {
144160 return new TaskQueueBuilder ( options ) ;
0 commit comments