作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须恢复使用 Firebase 函数 V1,以便安排函数的运行,并在代码(用 TypeScript 编写)中指定运行时选项,包括 timeoutSeconds 和内存:
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");
});
有谁知道 Firebase 功能 V2 是否可以使用 onSchedule语法也在代码中指定这些runtimeOpts?无需进入谷歌云控制台并在那里手动设置。
到目前为止,我已经尝试将“onSchedule”和“runWith”链接在一起,并查看 Emmet 提出的其他可能性,但没有成功。
最佳答案
API documentation for onSchedule建议您可以传递一个对象作为第一个参数,即 ScheduleOptions对象, GlobalOptions 的扩展:
onSchedule({
schedule: "your-schedule-here",
timeoutSeconds: your-timeout,
memory: your-memory,
// include other options here from SchedulerOptions or GlobalOptions
}, (event) => { ... })
关于node.js - 有没有办法使用 onSchedule 并使用 Firebase 函数 V2 设置自定义 'timeoutSeconds' 和 'memory' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76385289/
我是一名优秀的程序员,十分优秀!