Hi Firebase forum,
I was recently put on the route of firebase-queue with nodejs on a google app engine flexible environment. Things are going great since!
However, I'm looking for tips/tricks on how to architect the following:
Often it's preferable to not have the client initiate the task.
Instead, sometimes I'd like my server to be in control of starting a particular type of task.
Writing a continuous listener works fine until things start scaling (i.e. Having a script poll a ref, and trigger a task on a change, great for a single instance on GAE FE, but once that script is triggered again, tasks start duplicating)
To get around this problem, I've used a concoction of transactions and onDisconnect() to record which instance is the 'master' script. (I.e., ensuring only one script triggers jobs)
I've used onDisconnect() to ensure a peer script picks up the job as master in the event of the master disconnecting/being scaled down.
I'm also aware maybe placing these scripts on a separate GAE server or manual-scaled heroku dyno would have been an alternative to dealing with master/slave, but I like being able to keep things in one place (disabling/enabling server in one click is great while developing for example).
Long story short, has anyone done anything similar or have a smarter trick?
I feel like it's a common enough use-case, surely I'm not the first to do this?
Regards,
Alan