diff --git a/docgen/content-sources/toc.yaml b/docgen/content-sources/toc.yaml index a394975df..37093f7c2 100644 --- a/docgen/content-sources/toc.yaml +++ b/docgen/content-sources/toc.yaml @@ -106,6 +106,8 @@ toc: path: /docs/reference/functions/providers_pubsub_.message.html - title: 'TopicBuilder' path: /docs/reference/functions/providers_pubsub_.topicbuilder.html + - title: 'ScheduleBuilder' + path: /docs/reference/functions/providers_pubsub_.schedulebuilder.html - title: 'functions.remoteconfig' path: /docs/reference/functions/providers_remoteconfig_.html diff --git a/src/providers/pubsub.ts b/src/providers/pubsub.ts index 0f12f669c..264ef9480 100644 --- a/src/providers/pubsub.ts +++ b/src/providers/pubsub.ts @@ -98,6 +98,12 @@ export class TopicBuilder { } } +/** + * Registers a Cloud Function to run at specified times. + * + * @param schedule The schedule, in Unix Crontab or AppEngine syntax. + * @return ScheduleBuilder interface. + */ export function schedule(schedule: string): ScheduleBuilder { return _scheduleWithOptions(schedule, {}); } @@ -120,6 +126,15 @@ export function _scheduleWithOptions( }); } +/** + * The builder for scheduled functions, which are powered by + * Google Pub/Sub and Cloud Scheduler. Describes the Cloud Scheduler + * job that is deployed to trigger a scheduled function at the provided + * frequency. For more information, see + * [Schedule functions](/docs/functions/schedule-functions). + * + * Access via [`functions.pubsub.schedule()`](providers_pubsub_.html#schedule). + */ export class ScheduleBuilder { /** @hidden */ constructor( @@ -137,6 +152,14 @@ export class ScheduleBuilder { return this; } + /** + * Event handler for scheduled functions. Triggered whenever the associated + * scheduler job sends a Pub/Sub message. + * + * @param handler Handler that fires whenever the associated + * scheduler job sends a Pub/Sub message. + * @return A Cloud Function that you can export and deploy. + */ onRun(handler: (context: EventContext) => PromiseLike | any) { const cloudFunction = makeCloudFunction({ contextOnlyHandler: handler,