Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do Firebase Cloud Functions ack Cloud pub/sub

In this article on Google Cloud Pub Sub we are told that a function must return a status to ack receipt of a message. I have one question related specifically to Firebase Cloud Functions pubsub triggers:

I cannot see in the document above how or if a Firebase Cloud function acks the pub sub. Can someone explain this please?

like image 300
Safa Alai Avatar asked Mar 05 '19 05:03

Safa Alai


People also ask

How do Firebase cloud functions work?

Cloud Functions for Firebase is a serverless framework that lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your JavaScript or TypeScript code is stored in Google's cloud and runs in a managed environment.

How does cloud pub/sub work?

Cloud Pub/Sub is designed to provide reliable, many-to-many, asynchronous messaging between applications. Publisher applications can send messages to a "topic" and other applications can subscribe to that topic to receive the messages.

How do you trigger a Pub/Sub cloud?

For Cloud Functions (1st gen): In the Trigger type field, select Cloud Pub/Sub. In the Select a Cloud Pub/Sub topic field, select a topic for the trigger to monitor. Messages published to this topic will trigger calls to your function.

How does cloud pub/sub deliver messages to endpoints?

The Pub/Sub server sends each message as an HTTPS request to the subscriber client at a pre-configured endpoint. This request is shown as a PushRequest in the image. The endpoint acknowledges the message by returning an HTTP success status code. A non-success response indicates that Pub/Sub must resend the messages.


1 Answers

This is implemented in Google-managed code. It’s effectively the same as a Pub/Sub push subscription, where a 200 response acks the message (https://cloud.google.com/pubsub/docs/push#receive_push). This auto-ack happens after your function finishes successfully.

like image 116
Thomas Bouldin Avatar answered Sep 22 '22 11:09

Thomas Bouldin