我不得不恢复使用 Firebase 函数 V1 来安排函数的运行,并在代码中指定运行时选项,包括 timeoutSeconds 和内存(用 TypeScript 编写):
const runtimeOpts = {
timeoutSeconds: 540,
memory: "1GB" as const,
};
exports.cleanupEvents = functions
.runWith(runtimeOpts)
.pubsub.schedule("0 0 * * *")
.timeZone("Europe/Berlin")
.onRun(async () => {
await cleanupOldEvents(adminDb);
logger.log("Event cleanup finished");
});
Run Code Online (Sandbox Code Playgroud)
有谁知道Firebase函数V2是否可以使用onSchedule语法在代码中指定这些runtimeOpts?无需进入谷歌云控制台并在那里手动设置。
我尝试过将“onSchedule”和“runWith”链接在一起,看看 Emmet 提出的其他可能性,但到目前为止没有运气。