Skip to content
Merged
2 changes: 2 additions & 0 deletions docgen/content-sources/toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/providers/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {});
}
Expand All @@ -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(
Expand All @@ -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> | any) {
const cloudFunction = makeCloudFunction({
contextOnlyHandler: handler,
Expand Down