Google Cloud 's Pub/Sub is a globally distributed message bus that automatically scales as you need it. You can trigger a function whenever a new Pub/Sub message is sent to a specific topic.
Import the required modules
To get started, import the modules required for handling Pub/Sub events:
Node.js
  const 
  
 { 
 onMessagePublished 
 } 
  
 = 
  
 require 
 ( 
 "firebase-functions/pubsub" 
 ); 
 const 
  
 logger 
  
 = 
  
 require 
 ( 
 "firebase-functions/logger" 
 ); 
  
 
 
Python
  from 
  
 firebase_functions 
  
 import 
 pubsub_fn  
 
 . 
 py 
 
 

