如何增加firebase调度函数的内存限制?



文档提到使用.runWith({memory: "1GB"}),但是我如何将此选项用于像这样的计划函数:

functions.pubsub.schedule('every 10 minutes').onRun(async (context) => {
console.log("Do something");
});

按以下步骤操作:

functions.runWith({memory: "1GB"}).pubsub.schedule('every 10 minutes').onRun(async (context) => {
console.log("Do something");
// Don't forget to return a Promise if necessary!! 
// See https://firebase.google.com/docs/functions/terminate-functions
});

就目前而言,如果您正在使用Firebase,那么本机方法是使用onSchedule它有两个参数!项>和处理

const { onSchedule } = require("firebase-functions/v2/scheduler");
exports.theScheduledFunction = onSchedule(
{
schedule: "* */5 * * *", // Cron Syntax
memory: "512MiB", // Allocate 512 MiB memory
timeoutSeconds: 300, // Set a timeout of 300 seconds
},
async (event) => {
// Place your code here
}
);

使用firebase clifirebase deploy --only functions:theScheduledFunction

最新更新