有人知道如何使用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.
两种最常见的方法是:
- 具有定期调度的云功能(例如每分钟),然后从数据库中读取任务,并执行启动的任务。
- 使用具有API的单独计划程序服务来创建计划,例如Cloud Tasks。道格在如何安排Cloud Function在将来与Cloud Tasks一起运行(以构建Firestore文档TTL)。 / li>
- 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).
另请参见:
- 如何在firebase中以编程方式创建cron作业
- How to create cron jobs in firebase programmatically
更多推荐
如何在Firebase中动态创建Cron作业
发布评论