0

I'm trying to build a scheduling system to run a firebase cloud function after 60 minutes from a specific event in the database. After some lectures I know that firebase has not a built in schedule system. Indeed, what I have to do is to schedule an http request when a specific document in firestore is updated. Someone recommends me https://cron-job.org/en/, anyone knows if with this service I can schedule automatically some http requests when a document in firestore is updated?

Dario Ielardi
  • 807
  • 9
  • 24

1 Answers1

-1

If you want to have a http request when a document in firestore updated you may need firestore trigger function initialized instead cron-job. something like ;

exports.makeHttpRequest = functions.firestore
  .document('myCollection/myDocument').onUpdate((event) => {
    setTimeout( ()=> {
        var cronJobUrl = "https//:www..."; // Set the url you want to make a http request
        windows.open(cronJobUrl);
    },60000*60)  // to fire this function after 60 min. 
});
Cappittall
  • 3,300
  • 3
  • 15
  • 23
  • Thanks for your answer. The problem is that a firebase cloud function does not support such a long timeout, it will be stopped way before. – Dario Ielardi Jan 13 '18 at 15:55
  • Ok. You are right, I didn't consider it for a min. But If you want exactly after 60min, then I do not know for now, but if you say min 60 min. possible after 60-120 min then there is another solution. If suits I will try to explain – Cappittall Jan 13 '18 at 16:11
  • this 60-120 min. may narrow gap. upon your wish. ie 60-75 min. ( But you will need to consider calling a cloud functions frequency. – Cappittall Jan 13 '18 at 16:15