Difference between starting firestore emulator through `firebase` and `gcloud`?(通过`Firebase`和`gCloud`启动FireStore模拟器有什么区别?)
本文介绍了通过`Firebase`和`gCloud`启动FireStore模拟器有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过:启动FireStore模拟器有什么不同
firebase emulators:start --only firestore
和:
gcloud beta emulators firestore start
这两个选项都允许我的Python应用程序实现与数据库的连接,如下所示:
import google
from google.cloud import firestore
os.environ["FIRESTORE_EMULATOR_HOST"] = "localhost:8081"
os.environ["FIRESTORE_EMULATOR_HOST_PATH"] = "localhost:8081/firestore"
os.environ["FIRESTORE_HOST"] = "http://localhost:8081"
credentials = mock.Mock(spec=google.auth.credentials.Credentials)
client = firestore.Client(credentials=credentials)
我自己注意到的一个区别是,firebase似乎尊重我的firebase.json,特别是像这样指定的主机端口:
{
"emulators": {
"firestore": {
"port": "8081"
}
}
}
另一方面,gcloud忽略firebase.json,而是选择一个随机端口,除非我显式地通过--host-port传递端口。这是两者之间更大差异的一部分吗?还有哪些其他差异?
推荐答案
我一直在查找这两个工具的文档,它们所做的几乎是相同的事情。
使用Firebase tool可以启动多个Firebase产品的仿真器,而gcloud command允许您启动GCP仿真器。FiRestore只是它们共同拥有的产品,因此它们的实用程序应该相同或相似。 关于功能差异,firebase提供了允许您在模拟会话之间保存和恢复数据的--import和--export-on-exit标志。它还提供了可视化security rules如何处理当前查询的方法。
除了这些功能之外,我还要注意设置端口和规则文件的不同方法:
firebase emulators使用firebase.json文件。gcloud beta emulators使用标志--host-port和--rules来实现相同的功能。
gcloud,请使用它。
这篇关于通过`Firebase`和`gCloud`启动FireStore模拟器有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
编程基础网
本文标题为:通过`Firebase`和`gCloud`启动FireStore模拟器有什么区别?
基础教程推荐
猜你喜欢
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
