Every Cloud Function has a trigger, which determines how and when your function executes. A trigger is essentially a declaration of what occurrence should cause your function to execute. When you associate a trigger with a Cloud Function, that function will execute when the trigger fires.
There are two trigger types:
- HTTP triggers
- Event triggers
A function with an HTTP trigger is executed when an HTTP request is sent to the function's URL.
A function with an event trigger does not have a public URL. It executes in response to an event within your Cloud project. For example, a function might execute in response to changes to data in a database.
Cloud Functions supports the following event-based triggers:
- Cloud Pub/Sub Triggers
- Cloud Storage Triggers
- Direct Triggers
- Cloud Firestore
- Analytics for Firebase
- Firebase Realtime Database
- Firebase Authentication
You can also integrate Cloud Functions with any other Google service that supports Cloud Pub/Sub, or any service that provides HTTP callbacks (webhooks). This is described in more detail in Additional Triggers, below.
Because Cloud Functions can be invoked by messages on a Cloud Pub/Sub topic, you can easily integrate Cloud Functions with any other Google service that supports Cloud Pub/Sub as an event bus. In addition, by leveraging HTTP invocation you can also integrate with any service that provides HTTP callbacks (webhooks).
Google Cloud Logging events can be exported to a Cloud Pub/Sub topic from which they can then be consumed by Cloud Functions. See the Cloud Logging documentation on exporting logs for more information.
Using the Gmail Push Notification API you can send Gmail events to a Cloud Pub/Sub topic and consume them with a Cloud Function.