Aim*_*bol 3 node.js google-cloud-functions
我在项目中使用 Google Firebase,最近开始使用第二代 Google Cloud 函数,有一个函数使用调度程序,每 5 分钟调用该函数一次。我想知道如何增加此功能的内存。我不想使用“setGlobalOptions({)”,因为这将适用于所有函数。有没有办法只针对这个功能来实现这一点。该函数如下所示:
// const { setGlobalOptions } = require('firebase-functions/v2');
const { onSchedule } = require('firebase-functions/v2/scheduler');
// I don't want this option since it applies to all functions
// setGlobalOptions({ memory:"512MiB" });
// there is no way to add options to onSchedule()??
exports.myFunction = onSchedule(
'*/5 * * * *',
async (context) => {
// code goes here
}
);
Run Code Online (Sandbox Code Playgroud)
您可以传递ScheduleOptions对象作为第一个参数,该对象基本上是GlobalOptions的扩展,用于在每个函数的基础上使用这些选项,因此您可以按如下方式设置每个函数的内存:
import {
onSchedule
} from "firebase-functions/v2/scheduler";
export const myScheduleFunction = onSchedule({
memory: "512MiB",
timeoutSeconds: 60,
schedule: "*/5 * * * *",
// include other options here from SchedulerOptions or GlobalOptions
},
async (context) => {
// code goes here
}
);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
476 次 |
最近记录: |