如何在Firebase中动态创建Cron作业 [英] How to create cron jobs dynamically in firebase

查看:70
本文介绍了如何在Firebase中动态创建Cron作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何使用Firebase动态设置Cron Jobs吗?我想构建一个规则引擎,客户端可以使用该引擎指定规则,操作和计划,并基于此我需要计划该特定规则。由于计划由客户掌握。我可以为作业设置一个预定义的频率。

Does anyone know how can I set up Cron Jobs dynamically with Firebase? I want to build a rule engine using which the Client can specify the rules, actions, and schedule and based on that I need to schedule that particular rule. Since the scheduling is in the hand of the Client. I can set a predefined frequency for the JOB.

我知道在Node.js中我可以使用 node-schedule之类的库来实现。但是由于客户严格希望使用Firebase和Angular。我不能使用该解决方案

I know in Node.js I can do it with libraries like "node-schedule". But since the Client strictly wants to use Firebase and Angular. I can't use that solution

推荐答案

没有办法仅靠Cloud Functions动态创建计划功能。

There is no way to dynamically create schedule functions with just Cloud Functions.

两种最常见的方法是:

  • Have a regularly scheduled Cloud Function (say every minute) that then reads the tasks from a database, and executes the tasks that are up.
  • Use a separate scheduler service that has an API to create schedules, like Cloud Tasks. Doug wrote a great article about that in How to schedule a Cloud Function to run in the future with Cloud Tasks (to build a Firestore document TTL).

另请参见:

  • How to create cron jobs in firebase programmatically

这篇关于如何在Firebase中动态创建Cron作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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