Can I deploy a common function when using Google Cloud Function by Python?

Viewed 177

I have created a Common class that will be used in common and am approaching from the A function and B function.

If I add variables to the Common class, you must deploy both A and B classes.

How can I apply the Common class take effect without deploy all the A and B functions?

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()
1 Answers

It's not possible: the source of each Cloud Function is entirely separate from any other Cloud Function.

If you always want to deploy the functions at the same time, you might want to look into turning them into endpoints in an application and deploying it to Cloud Run instead.

Related