I have a firebase function that should be ran every 1 hour, but only for X times. I scheduled it in this way :
functions.pubsub.schedule('every 1 hour').onRun((context) => {
let counter = // read last counter value from db
counter++;
if(counter === X)
return;
// save counter in db
// my job
}
But this method is not optimal, because the scheduler is always active, even when it's not required. Do you offer a better method for this purpose?