$25
Q1. In this assignment, you will count the number of lines in a file uploaded to the GCS bucket in real-time by using Google Cloud Functions and Pub/Sub.
a. Download the file from here: https://filesamples.com/samples/document/txt/sample1.txt
b. Write a Google cloud Function which gets triggered whenever a file is added to a bucket and publishes the file name to a topic in Pub/Sub.
c. Write a python file, which acts as a subscriber to this topic and prints out the number of lines in the file in real-time.
(Documentation for pub/sub available at: https://pypi.org/project/google-cloud-pubsub/ )
Test the steps (b) and (c) using the file downloaded in step (a). Ensure that you add screenshots and share the code for all steps.
Q2. There are two kinds of subscribers - pull and push subscribers. What are the differences between the two and when would you prefer one over the other?