我已经创建了一个Common类,将被common使用,正在从A函数和B函数接近。
如果我将变量添加到 Common 类,则必须同时部署 A 和 B 类。
如何在不部署所有A和B功能的情况下应用Common类生效?
class Common:
def __init__(self, tmp):
self.FIRST = tmp
self.SECOND = 'Test' # new.
# I want to modify this function.
# but I have to deploy function A and B.
# If I have a lot of functions I need a lot of time.
def print_value(self):
print(self.FIRST) # old.
print(self.FIRST, self.SECOND) # new.
class A:
def __init__(self):
o = Common('A')
o.print_value()
class B:
def __init__(self):
o = Common('B')
o.print_value()
最佳答案
这是不可能的:每个 Cloud Function 的来源都与任何其他 Cloud Function 完全分开。
如果您总是希望同时部署这些功能,您可能需要考虑将它们转换为应用程序中的端点并将其部署到 Cloud Run相反。
关于python - 通过 Python 使用 Google Cloud Function 时,我可以部署一个常用函数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60334291/