[英]Does GCP / Cloud Functions have a library concept like AWS Lambda Layers?
Does GCP / Cloud Functions have a library concept anything like AWS Lambda Layers? GCP / Cloud Functions 是否有类似 AWS Lambda Layers 的库概念? Meaning, if we wanted to reduce code duplication and roll out a common library layer for our Google Cloud Functions, how would we do it?
意思是,如果我们想减少代码重复并为我们的 Google Cloud Functions 推出一个公共库层,我们该怎么做?
No, you haven't this kind of feature with Cloud Function.不,Cloud Function 没有这种功能。 I have 3 immediate alternatives in mind
我有 3 个直接的选择
Project tree项目树
root
|
- Common
|
- Functions
|
- function A
|
- function B
In function A and function B you use the common file in the Common directory.在 function A 和 function B 中,您使用 Common 目录中的公用文件。 When you deploy your function, do it in the
root
directory and use the source directory to indicate in which directory to look for the function to deploy当您部署 function 时,请在
root
目录中执行此操作并使用源目录指示在哪个目录中查找要部署的 function
gcloud functions deploy --source=function/functionA ...
Trade Off交易
Google's Cloud Platform now has Artifact Registry.谷歌的云平台现在有 Artifact Registry。 This service can used to store NodeJS packages (not sure about other runtimes) that can be referenced from a GCP Cloud Function.
此服务可用于存储可从 GCP Cloud Function 引用的 NodeJS 包(不确定其他运行时)。
You can read more about it at the link below:您可以在下面的链接中阅读更多相关信息:
https://cloud.google.com/artifact-registry/docs/nodejs/store-nodejs https://cloud.google.com/artifact-registry/docs/nodejs/store-nodejs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.