I need to run a CronJob that performs three inter-dependent async tasks, at certain interval that is mentioned in the CronJob config.
Async Task-1: Query Table to fetch results on a particular criteria
Async Task-2: Perform a async operation on the results fetched in Task-1
Async Task-3: Update Table entries for corresponding Ids with operation performed in Task-2.
I am unable to figure out, what would happen if the next the next interval of CronJob begins before the tasks of first interval end. And how can this be managed.
More specific question: Is there a way in which I can maintain a sync between the sql table and tasks being performed, so that if an UPDATE TASK
is pending in one cycle, it doesnt perform the same task in the next cycle.
I am using node-cron
npm module for developing the CronJob.