如何/可以手动调用触发器Firebase函数? [英] How/Can I manually call a trigger Firebase Function?

查看:100
本文介绍了如何/可以手动调用触发器Firebase函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的应用程序中,我们一直在使用可调用函数,有时冷启动可能会令人头疼,因为我们仍在开发它,并且除我们之外没有用户使用它们.

In our app we are constantly using callable functions and sometimes the cold start can be a headache, given the fact that we are still developing it and there are no users using them other than us.

我们认为加快此过程的目的是在登录并打开应用程序时调用每个函数(它们数量不多,目前大约20个,我们的账单不会付诸东流).只是返回一个空值,而不执行其中的任何其他代码.这将对它们进行热加载,以便在接下来的几分钟内使用,避免冷启动,并允许我们快速轻松地测试前端和后端代码.

What we thought to speed up this process is to call every function (they're not much, around 20 at the moment, our bill won't go to the moon) when we open the app, before logging in, and just returning a null value without executing any other code inside it. This will hot-load them to be used in the next few minutes, avoiding cold starts and allowing us to test our front+back-end code quick and easily.

但是,我们有一些触发功能,例如在创建后添加用户详细信息,这些功能确实具有冷启动功能,但是无法调用,因此我们无法热加载"这些功能.

However, we have some trigger functions like adding user details after creation, that do have cold starts, but can't be called, so we can't "hot load them".

是否有任何方法可以实际触发这些功能并通过参数发送数据?还是有其他方法可以解决这种情况?

Is there any way to actually trigger these functions AND send them data through a parameter? Or this there any other approach to this situation?

推荐答案

不基于HTTP的触发器称为后台触发器". Firebase工具无法提供以编程方式触发部署到Cloud Functions的后台功能的方法,而无需实际执行会触发该功能的操作.没有直接调用,就像使用本地仿真器时一样.

Triggers that are not based on HTTP are called "background triggers". The Firebase tools don't provide way to programmatically trigger a background function deployed to Cloud Functions without actually performing that action that would trigger it. There is no direct invocation, like there is when you're using the local emulator.

如果您愿意采用Google Cloud工具,则可以使用gcloud命令>行或Google Cloud控制台直接触发功能.

If you're willing to adopt Google Cloud tools, you can use the gcloud command line or the Google Cloud console to trigger a function directly.

这篇关于如何/可以手动调用触发器Firebase函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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