TritonDataCenter / node-workflow

Task orchestration, creation and running using NodeJS
MIT License
456 stars 66 forks source link

Change next task from within task body? #139

Closed jchoi2x closed 9 years ago

jchoi2x commented 9 years ago

I need to implement an email approval workflow where "n" number of emails are dispatched and the job must wait until all "n" recipients have responded by clicking on a URL within the email before continuing the next task. I've been staring at the example code for several hours, fiddled around for awhile, and read info regarding calling the callback with the special error message arguments of 'restart', 'queue', and 'wait;' but I don't think it is what I am looking for.

I am able to increment the email response counter param from within a task to keep track of how many emails were received but I need to be able to schedule the next task to be the same task as the current if there are email responses still being waited on.

Is there a way to modify the next task in the task chain from within a job?

kusor commented 9 years ago

There is no such thing.

IMO, it looks like what you could try is to just re-queue same job with a modification of the exec_after property and keep retrying the same task after a given period of time, until that counter you've mentioned reached the expected value and, from there, continue with the next task of the workflow.

jchoi2x commented 9 years ago

Alright thank you very much