基于Firebase的计时器的云功能 [英] Cloud Functions for Firebase based timer

查看:89
本文介绍了基于Firebase的计时器的云功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我知道Firebase的Cloud Functions本身不支持cron作业,并且必须依靠外部源来触发HTTP云功能.但是我认为这对我来说不起作用.

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.

我有一个应用程序,用户可以在其中创建可在24小时内结束的比赛,因此,每次创建比赛时,我都需要设置一个计时器,该计时器在24小时后触发一次.

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?

推荐答案

目前,Firebase员工为解决cron问题而提供的解决方案是使用Google App Engine部署服务器并通过Pub/触发功能子钩. 在这里,您可以找到本教程. 基本上,您必须:

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. 创建一个响应PubSub挂钩的Cloud Function.
  2. 部署一个App Engine,该引擎将根据您设置的cron设置发布事件.

如果您不想设置App Engine,则可以使用cron-job.org之类的外部资源来调用HTTP Cloud Function.

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.

这篇关于基于Firebase的计时器的云功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆