Cloud Functions for Firebase based timer

倾然丶 夕夏残阳落幕 提交于 2019-12-21 21:35:24

问题


So I know that Cloud Functions for Firebase don't natively support cron jobs, and one have to depend on an external source to trigger an HTTP cloud function. But I don't think this will work in my case.

I have an app in which users can create competitions that end in 24 hours, thus each time a competition is created, I need to set up a timer that triggers one time after 24 hours.

Do you guys have any idea on how this problem can be approached?


回答1:


At this moment the solution that the Firebase guys are providing for solving the cron issue is to use Google App Engine to deploy a server and trigger the functions via Pub/Sub hooks. Here you can find the tutorial. Basically you have to:

  1. Create a Cloud Function that responds to a PubSub hook.
  2. Deploy an App Engine that will publish an event depending on the cron setup you set.

If you don't want to setup an App Engine you can use an external resource like cron-job.org that can call your HTTP Cloud Function.



来源:https://stackoverflow.com/questions/43079187/cloud-functions-for-firebase-based-timer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!