Use case – reacting to object changes
When we use our GCP buckets for web applications, the objects in the bucket will be rewritten many times over. Clearly, we might need to detect specific object changes and react to them, for which we'd need to be notified when an object changes. This functionality is invoked using the watchbucket clause in gsutil
.
Please know that these notifications are different from Pub/Sub notifications (Pub/Sub is the reliable messaging system for streaming data in GCP). Object change notifications happen using something called a Channel. This is a GCS-specific term used to describe the link between a bucket and all apps listening for changes on that bucket.
You should also be aware that object change notifications can be used to trigger cloud functions.
Setting up object change notifications with the gsutil notification watchbucket
The gsutil
tool can be used to create a channel and also remove it once it is no longer required:
- Once we run the command, as follows, it...