Types of Cloud Functions
There are two types of Cloud Functions: HTTP functions and background functions. They differ in the way they are triggered. Let's have a look at each.
HTTP functions
HTTP functions are invoked by HTTP(S) requests. The POST
, PUT
, GET
, DELETE
, and OPTIONS
HTTP methods are accepted. Arguments can be provided to the function using the request body:
The invocation can be defined as synchronous as it can return a response that's been constructed within the function.
Interesting Fact
Don't expect a question on this on the exam. However, it might be interesting to know that Cloud Functions handles HTTP requests using common frameworks. For Node.js, this is Express 4.16.3, for Python, this is Flask 1.0.2, and for Go, this is the standard http.HadlerFunc
interface.
Background functions
Background functions are invoked by events such as changes in the Cloud Storage bucket, messages...