Firebase功能:可以将功能分成多个项目 [英] Firebase Functions: is it OK to divide functions to multiple projects

查看:137
本文介绍了Firebase功能:可以将功能分成多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与此处的问题有关: Google Cloud / Firebase函数,处理每个函数的依赖关系



因此,为了更好地管理依赖关系,是否允许将函数划分为我们认为合适的项目?



这将创建一个master项目,它包含数据库和存储中的数据以及其他空的项目,但只包含某些功能。



以下项目的主要内容:My Awesome App,My Awesome App Stats Api,My Awesome App Admin Api等。

解决方案

这取决于你正在写什么类型的函数。

如果你想写数据库触发器,他们必须在与正在接收写入的数据库相同的项目。您不能在第一个项目中响应第二个项目的数据库写入。



如果要编写HTTP触发器,可以启动admin SDK以指向到不同的项目查询等。

我没有特别看到任何需要在生产环境中碎片化你的功能。云功能将根据需要扩展您的功能来处理负载,不同项目中的不同功能在这方面应该没有什么不同。

This is in relation to the question here: Google Cloud / Firebase Functions, handling dependencies per function

So, to manage dependencies better, is it allowed to divide the functions to as many projects as we see fit?

This would create one "master" project, that contains the data in database and storage + the projects that are otherwise empty, but contain only certain functions.

Thins of the following projects: My Awesome App, My Awesome App Stats Api, My Awesome App Admin Api etc.

解决方案

It depends on what kinds of functions you're writing.

If you want to write database triggers, they have to be in the same project as the database that's receiving the writes. You can't have a second project respond to writes from the database in the first project.

If you want to write HTTP triggers, you can init the admin SDK to point to different projects for querying and such.

I don't particularly see any need to "shard" your functions like this in a production environment. Cloud Functions will scale your functions as needed to handle the load, and having different functions in different projects shouldn't make a difference in that respect.

这篇关于Firebase功能:可以将功能分成多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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