kaliberjs / firebase-queue

A trimmed and more robust version of the original Firebase Queue
MIT License
20 stars 3 forks source link

Use firebase-queue together with firebase cloud functions? #5

Open ElectroBuddha opened 5 years ago

ElectroBuddha commented 5 years ago

Hi, I've been using firebase-queue before firebase cloud functions were released. Since then I've moved to cloud functions, but I still think that queues were really great solution for chaining different kinds of tasks. On the other hand, cloud functions are great because now I can host all of my server-side logic on the firebase platform, whereas with firebase-queues I had to host server-side app on my own server. Is it possible to have best of the both worlds, to use firebase-queues inside cloud-functions, maybe use cloud functions' 'onWrite' trigger to run the queue?

EECOLOR commented 5 years ago

As you can see in https://github.com/firebase/firebase-queue/issues/115 I'm open to the idea. The problem for me is my inexperience with Firebase Functions and mainly testing them.

I guess that the effort to create a queue worker to operate on the Firebase Functions API is very small. If we split the code at around queue_worker.js#L28 we are getting close.

A tricky thing is probably the busy part, I haven't read enough about functions to know their semantics. If we are guaranteed that the code will only be active during a single invocation (for example for an onWrite callback) we are good. If a function is re-used while it is processing things will become a bit more complicated in situations where the queue is filled faster than the processing speed of the functions.

So in short: I would love to add support for it but my knowledge is limited. So any help and information (especially with testing) would be awesome.

LoveMHz commented 5 years ago

@EECOLOR What at do you purpose is the best solution? A new project or try to expand firebase-queue to support Firestore?

I've managed to hack together Firestore support, but not actually sure it fits in with the current project.