【问题标题】:Can I deploy a common function when using Google Cloud Function by Python?使用 Google Cloud Function by Python 时可以部署通用函数吗?
【发布时间】:2020-02-21 07:55:01
【问题描述】:

我创建了一个 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()

【问题讨论】:

    标签: python google-cloud-platform google-cloud-functions


    【解决方案1】:

    这是不可能的:每个 Cloud Function 的来源都完全独立于任何其他 Cloud Function。

    如果您总是希望同时部署这些功能,您可能需要考虑将它们转换为应用程序中的端点,然后将其部署到 Cloud Run

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-22
      • 2020-03-01
      • 2021-10-17
      • 2022-08-19
      • 1970-01-01
      • 2017-08-04
      • 2019-10-25
      • 2020-01-19
      相关资源
      最近更新 更多