-
Notifications
You must be signed in to change notification settings - Fork 95
Firebase-queue for Cloud Functions #115
Description
I am basing this issue on a question I came across on StackOverflow regarding whether or not cloud functions render firebase-queue obsolete, and my answer to that question. Also, I noticed that the Readme.md of this project has been changed to point developers away from this library in favour of cloud functions.
Firebase-queue provides much more than a way for tasks to listen to firebase and launch tasks. It provides a protocol for communication between parties assigning and and responding to task requests, coordinating retries of failed tasks, reporting progress, state and additional metadata, and task chaining.
I think it would be useful for Firebase to develop a firebase-functions-queue package that extends the firebase-functions package and allows you to write a firebase cloud function with the same signature as firebase-queue. Something like this:
const functions = require('firebase-functions');
const functions-queue = require('firebase-functions-queue'); //extends firebase-functions with onQueue function
admin.initializeApp(functions.config().firebase);
functions.database.ref('/queue').onQueue(options,function(data,progress,resolve,reject){
...
})
This new package would work just like firebase-queue and use the same metadata and options, except it wouldn't need to deal with managing multiple worker processes since cloud functions already do this automatically and seamlessly.
This would have the following advantages:
- Would allow firebase developers to use a standard way of assigning jobs to queues, monitor progress, failure, etc.
- An app could assign a job to a queue and not care if it was being handled by a cloud function or a different environment.
- A developer could take an existing queue and move it from their node server to cloud functions without changing the client app.
- It could even allow task chaining where one task could be handled by a cloud function and another by a different server within the same job.