简体   繁体   English

firebase实时数据库事件触发的谷歌云功能

[英]Google cloud function triggered by firebase realtime database events

Apparently some of onCreate/onDelete events our cloud function is triggered by are received more than once!显然,我们的云函数触发的一些 onCreate/onDelete 事件不止一次收到! We've observed them arriving even 3 times a few seconds apart from each other spread between instances of the cloud function.我们观察到它们在云函数的实例之间传播甚至相隔几秒钟到达 3 次。 Is it a normal behavior or there is something we've been doing wrong?这是正常行为还是我们做错了什么?

Have a look at the content of this "Firebase Google Group" post , that I paste below.看看我粘贴在下面的这篇“Firebase Google Group” 帖子的内容。 It was written in August 2018 but is still fully valid at the time of writing this "copy/paste answer".它写于 2018 年 8 月,但在撰写此“复制/粘贴答案”时仍然完全有效。

Cloud Functions typically guarantees that your functions are run "at least once", meaning that it's very possible (but typically rare) that an event may get delivered to your function more than once. Cloud Functions 通常保证您的函数“至少运行一次”,这意味着一个事件很可能(但通常很少)被多次传递给您的函数。 To deal with this, your functions should be "idempotent", meaning that the receipt of the same event multiple times should result in no further changes to whatever it is you need to update.为了解决这个问题,你的函数应该是“幂等的”,这意味着多次接收同一个事件应该不会导致你需要更新的任何内容发生进一步的变化。 This can be kind of challenging, but it's one of the properties of serverless systems that needs to be dealt with, if it's problematic for your app.这可能有点挑战性,但如果它对您的应用程序有问题,它是需要处理的无服务器系统的属性之一。

https://cloud.google.com/functions/docs/bestpractices/tips#write_idempotent_functions https://cloud.google.com/functions/docs/bestpractices/tips#write_idempotent_functions

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

相关问题 Firebase实时数据库中的云功能 - Cloud Function in Firebase Realtime Database 通过Firebase Realtime数据库的Create事件类型触发的Python云功能 - Cloud Function with Python triggered via Create event type of Firebase Realtime Database Google Cloud Platform 中的 Firebase 实时数据库 - Firebase Realtime Database in Google Cloud Platform Firebase 云函数实时数据库触发器 - Firebase Cloud Function Realtime Database Trigger 将Firebase Auth与Firebase实时数据库或Google Cloud Datastore结合在一起? - Combining Firebase Auth with Firebase Realtime Database or Google Cloud Datastore? 具有Google Cloud功能的Firebase-实时数据库验证以检查尚未使用的用户名 - Firebase with Google Cloud Function - Realtime Database Validation to check username not already taken Firebase实时数据库事件未在APK中触发,但在编辑器中 - Firebase realtime DB events not triggered in APK, but are in editor 如果Firebase实时数据库中存在数据库节点,请使用云功能检查 - Checking with Cloud Function if a database node exists in Firebase Realtime Database 如何使用Google云功能从Firebase实时数据库中读取值? - How to read a value from Firebase realtime database with a Google cloud functions? Firebase实时数据库到Cloud Firestore - Firebase Realtime Database to Cloud Firestore
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM