Muh*_*ota 59 firebase google-cloud-platform google-cloud-functions
云功能和Firebase功能(或"Firebase的云功能")看起来都一样.请描述每个用例.
两者都使用HTTP功能.
在云功能中:
exports.helloHttp = function helloHttp (req, res) {
res.send(`Hello ${req.body.name || 'World'}!`);
};
Run Code Online (Sandbox Code Playgroud)
并在Firebase功能中:
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
Run Code Online (Sandbox Code Playgroud)
这些有什么区别?
Fra*_*len 116
没有名为Firebase Functions的产品.
有三个不同的东西:
firebase-functions您在功能代码中用于访问Firebase数据的库(容易混淆地称为)(例如写入数据库的数据的快照)因此,Firebase围绕Google Cloud Functions提供了一个(相对较薄的)包装,使后一种产品更易于使用,并将其与Firebase集成.从这个意义上说,它与Firebase将Google云端存储集成到"Firebase for Firebase"(以前称为Firebase存储)的方式类似.
如果您使用的是没有Firebase的Google Cloud Platform,那么您应该使用普通的Google Cloud Functions.如果您使用的是Firebase,或者您是对云功能感兴趣的移动开发人员,则应使用Cloud Functions for Firebase.
还有一个额外的区别:Firebase Functions 只能用 JS 或 Node.JS 实现,而 Cloud Functions 还允许使用 Python 和 Go。
如果您使用 Spark 计划,则它们的定价方式也存在细微差别。查看https://firebase.google.com/pricing与https://cloud.google.com/functions/pricing 如果您使用 Blaze 计划,价格是相同的。
我碰巧在我的 Firebase 项目中使用了两者。
Google Cloud Platform, GCP,有一篇文章解决了这个问题,Google Cloud Functions and Firebase。
谷歌云函数和 Firebase
Google Cloud Functions 是 Google 的无服务器计算解决方案,用于创建事件驱动的应用程序。它是 Google Cloud Platform 团队和 Firebase 团队的联合产品。
对于Google Cloud Platform 开发人员,Cloud Functions充当连接层,允许您通过侦听和响应事件在 Google Cloud Platform (GCP) 服务之间编织逻辑。
对于Firebase 开发人员,Cloud Functions for Firebase提供了一种方法来扩展 Firebase 的行为并通过添加服务器端代码来集成 Firebase 功能。
这两种解决方案都可以在完全托管的环境中快速可靠地执行功能,您无需担心管理任何服务器或配置任何基础设施。
...
Cloud Functions for Firebase 已针对 Firebase 开发人员进行了优化:
- Firebase SDK 通过代码配置您的功能
- 与 Firebase 控制台和 Firebase CLI 集成
- 与 Google Cloud Functions 相同的触发器,以及 Firebase 实时数据库、Firebase 身份验证和 Firebase Analytics 触发器
官方 Google 视频 描述差异:GCP 与 Firebase - Functions & Firestore
| 归档时间: |
|
| 查看次数: |
10743 次 |
| 最近记录: |