firebase-functions
firebase-functions copied to clipboard
Add v2 Schedule Triggers
Adds schedule triggers to the v2 namespace.
- Replaces pub/sub with an http underlying function
- Updated syntax to match with the other v2 triggers
This change does not add the invoker property to the container contract.
export const sch = v2.schedule.onSchedule("* * * * *", () => {});
export const sch = v2.schedule.onSchedule(
{
schedule: "* * * * *",
timeZone: "utc",
},
() => {}
);
Note to self: some of the types in this trigger are also going to need the Field/Expression treatment.
@Berlioz I can update this PR to take the work off your plate, what example should I be looking at?
Force merging - @inlined's comments have all been addressed.
The new V2 onSchedule cloud function does not seem to have a way to set timeoutSeconds or memory options.
For instance, my V1 scheduled cloud function currently sets both using runWith():
exports.function = functions.runWith({timeoutSeconds: 300, memory: '512MB'}).pubsub.schedule('0 22 * * 0-6').onRun(() => {...});
However, the currently listed ScheduleOptions listed in the V2 documentation does not list either of these properties: https://firebase.google.com/docs/functions/beta/reference/firebase-functions.scheduler.scheduleoptions
Are these properties going to be added to ScheduleOptions?
Hey @kbi-daniel! The ScheduleOptions extends the base GlobalOptions, so options like timeout and memory should be available. Eg.
exports.v2schedule = onSchedule(
{
// ScheduleOptions
schedule: "every 2 minutes",
maxBackoffSeconds: 20,
// GlobalOptions
memory: "1GiB",
timeoutSeconds: 50,
}, (event) => {
console.log(event);
});
Thanks @taeold. Worked as expected!