Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you call specific versions of a Google Cloud function?

We have a bunch of applications which depend on Google Cloud Functions - and there is an asynchronosity between when the Cloud functions get updated and the Applications get updated.

Suppose we update the Cloud Function first, then the app breaks. However if we update the application first it won't work with the current version of the cloud functions.

A way to solve this would be by being able to specify which version of the cloud function to execute. Is this possible?

Many thanks!

like image 684
Daryl Rodrigo Avatar asked Oct 24 '25 04:10

Daryl Rodrigo


1 Answers

There is no versioning scheme built into Cloud Functions. When you update a function, it gets rolled out immediately.


If you want such versioning you can of course include it into the naming scheme that you use. So if you have an existing myFunction that you want to update in an incompatible way, deploy myFunction_v2.

You could, over time as the v1 clients disappear, update the versioned v2 function into the default myFunction again.


Alternatively you can include a version number into your code itself, and into the invocation. So have each client pass along the version of the functionality it is expecting to get, and then have the server-side code do a conditional check:

if (context.params.api_version === 1) {
  ... behavior 1
}
else if (context.params.api_version === 2) {
  ... behavior 2
}
like image 134
Frank van Puffelen Avatar answered Oct 26 '25 23:10

Frank van Puffelen