简体   繁体   English

如何为 firebase 实现异步调度云 function?

[英]How to implement async scheduled cloud function for firebase?

I have a question about scheduled cloud functions with Firebase.我对 Firebase 的预定云功能有疑问。 I want to schedule a function that gets executed every x minutes.我想安排一个每 x 分钟执行一次的 function。

After all necessary documents are loaded, an async function should be called for each existing document.加载所有必要的文档后,应为每个现有文档调用异步 function。

If these functions are asynchronous, can there be a timeout of the scheduledFunction?如果这些函数是异步的,会不会有scheduledFunction的超时? Is the whole time considered or can there be only timeouts for the individual async functions?是否考虑了整个时间,或者单个异步函数是否只有超时?

Thanks in advance提前致谢

export scheduledFunction = functions.runWith( { memory: '2GB' }).pubsub.schedule('* * * * *').onRun(async context => {

// load all documents where x == y
// after completion (await): call async function for each document (function submits a HTTP POST request and gets response)

});

If these functions are asynchronous, can there be a timeout of the scheduledFunction?如果这些函数是异步的,会不会有scheduledFunction的超时?

The default timeout for all background functions is 60 seconds.所有后台功能的默认超时为 60 秒。 You can configure that upward to a maximum of 540 seconds, as described in the documentation .文档中所述,您可以将其配置为最多 540 秒。

Is the whole time considered or can there be only timeouts for the individual async functions?是否考虑了整个时间,或者单个异步函数是否只有超时?

The timeout is for the entire function, not the individual calls it makes while running.超时适用于整个 function,而不是它在运行时发出的单个调用。 If the timeout is exceeded, the function is forcibly terminated before the work is complete.如果超过超时时间,function 在工作完成之前被强制终止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase Cloud Functions异步功能 - Firebase Cloud Functions async function 如何从 firebase 云 function 返回数据并返回异步响应? - How to return data from firebase cloud function and return async response? 如何从 Firebase 云调用异步函数 Function - How to call async functions from a Firebase Cloud Function Firebase:Firestore 未更新 Cloud Function 的计划函数中的数据 - Firebase : Firestore not updating data in Cloud Function's scheduled function 具有异步数据库读取功能的 DialogFlow Firebase Cloud Function - DialogFlow Firebase Cloud Function with async database read 预定 Firebase 云函数超时 - Scheduled Firebase cloud functions timeout 如何在Cloud Functions的Cloud Functions中实现json对象? - How to implement json object in Cloud Functions for Firebase? Firebase Cloud Function 与 Google Secrets Manager 如何让 async/await 工作 - Firebase Cloud Function with Google Secrets Manager how to get the async/await to work Firebase云异步错误(函数返回未定义,预期的承诺或值) - Firebase Cloud Async Error(Function returned undefined, expected Promise or value) Google Cloud / Firebase功能:等待仅在异步功能中有效 - Google Cloud / Firebase Functions: await is only valid in async function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM