Cloud Functions和Firebase Functions之间有什么区别? [英] What is the difference between Cloud Functions and Firebase Functions?

查看:170
本文介绍了Cloud Functions和Firebase Functions之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

云功能看起来都一样.请描述每个的用例.

Cloud Functions and Firebase Functions (or "Cloud Functions for Firebase") both look the same. Please describe the use case of each.

两者都使用HTTP函数.

Both use HTTP functions.

云功能中:

exports.helloHttp = function helloHttp (req, res) {
  res.send(`Hello ${req.body.name || 'World'}!`);
};

以及 Firebase功能中:

exports.helloWorld = functions.https.onRequest((request, response) => {
  response.send("Hello from Firebase!");
});

这些之间有什么区别?

推荐答案

没有称为Firebase Functions的产品.

There is no product called Firebase Functions.

有三件事:

  1. Google Cloud Functions ,它使您可以在Google基础架构中运行代码片段以响应事件.
  2. Firebase的云功能,它会基于Firebase中的事件触发Google Cloud Functions(例如数据库或文件写入,用户创建等)
  3. 用于云功能的Firebase SDK ,其中包括一个库(易称为firebase-functions)您可以在Functions代码中使用它来访问Firebase数据(例如写入数据库的数据的快照)
  1. Google Cloud Functions, which allow you to run snippets of code in Google's infrastructure in response to events.
  2. Cloud Functions for Firebase, which triggers Google Cloud Functions based on events in Firebase (such as database or file writes, user creation, etc)
  3. Firebase SDK for Cloud Functions, which includes a library (confusingly called firebase-functions) that you use in your Functions code to access Firebase data (such as the snapshot of the data that was written to the database)

因此,Firebase为Google Cloud Functions提供了一个(相对较薄的)包装,以使后者产品更易于使用并将其与Firebase集成.从某种意义上讲,这类似于Firebase如何将Google Cloud Storage集成到用于Firebase的Cloud Storage"(以前称为Firebase Storage)中.

So Firebase provides a (relatively thin) wrapper around Google Cloud Functions, to make the latter product easier to use and integrate it with Firebase. In that senses it is similar to how Firebase integrates Google Cloud Storage into "Cloud Storage for Firebase" (formerly known as Firebase Storage).

如果您使用的是不带Firebase的Google Cloud Platform,则应使用普通的 Google Cloud Functions .如果您使用Firebase或对Cloud Functions感兴趣的移动开发人员,则应使用 Cloud Functions用于Firebase .

If you're using Google Cloud Platform without Firebase, then you should use plain Google Cloud Functions. If you're on Firebase or if you're a mobile developer interested in Cloud Functions, you should use Cloud Functions for Firebase.

这篇关于Cloud Functions和Firebase Functions之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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