我应该使用测试文件部署云函数吗?

huangapple go评论79阅读模式
英文:

Should I deploy cloud function with test files

问题

我应该部署用Golang编写的云函数及其测试文件吗?这样做有什么好处,还是只会占用更多的存储空间并增加成本?

关于成本,我还想澄清一下我的疑问——云函数的源代码是否也计入成本、空间、配额或任何限制?目前,我将所有函数放在一个地方(子包装),并为每个函数上传完整的源代码。这是为了管理Golang的依赖关系。

英文:

Should I deploy cloud function written in golang with its test files? Is there any benefit or it just consumes more space in storage and adds on to the cost?

Asking about cost, I would also like to clarify my doubt - Does Cloud function source also count towards cost, space, quota or any limit? Currently, I have all functions at one place (sub-packaged) and I upload complete source code for each function. This is to manage golang dependencies.

答案1

得分: 1

> 我不认为你有必要部署用Golang编写的云函数及其测试文件。

> 这样做没有任何好处,只会增加存储空间和成本。

> 云函数的源代码也会计入成本、空间、配额或任何限制吗?

当你部署云函数时,GCP会将函数的源代码存储在Cloud Storage中,并在Container Registry中存储构建。你需要支付这个存储的费用,但是费用很少,根据定价页面,大约是每GB每月0.026美元。

云函数还有一些配额限制。每个区域最多可以有1000个函数。

我认为你不需要过多担心这些费用和配额限制。但是如果你愿意,你可以使用.gcloudignore文件告诉GCP在部署云函数时忽略某些文件,使用的是与.gitignore相同的语法。

示例:

.gcloudignore
.git
.gitignore

# 二进制文件
*.exe
*.exe~
*.dll

# 测试文件
*_test.go
英文:

> Should I deploy cloud function written in golang with its test files?

I don't see any reason why you should

> Is there any benefit or it just consumes more space in storage and adds on to the cost?

I think it would only increase costs and delay your deployments, even if just a little bit

> Does Cloud function source also count towards cost, space, quota or any limit?

When you deploy a Cloud Function, GCP stores the function's source code in Cloud Storage and stores a build on Container Registry. You pay for this storage pricing, but it's very little, around $0.026 per GB per month according to this pricing page.

Cloud functions also have some quotas. You can have 1000 functions per region.


I don't think you should worry too much about that pricing and quota limits. But if you want to, you can easily tell GCP to ignore some files when deploying your Cloud Function with gcloud, using a .gcloudignore file (same syntax as .gitignore).

Example:

.gcloudignore
.git
.gitignore

# Binaries
*.exe
*.exe~
*.dll

# test files
*_test.go

huangapple
  • 本文由 发表于 2021年8月14日 03:14:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/68777374.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定