Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to delay a Workflow? #21

Open
MCKLtech opened this issue Jan 24, 2022 · 10 comments
Open

Is it possible to delay a Workflow? #21

MCKLtech opened this issue Jan 24, 2022 · 10 comments

Comments

@MCKLtech
Copy link

I'm wondering about the feasibility of delaying a workflow? For example, wait one hour, then send an email, wait two days, send another email.

Would a custom trigger that calls itself at a later point in time be a potential solution?

@Max-Hutschenreiter
Copy link
Contributor

Hey, MCKLtech yes I would go with a custom trigger for this. I have this feature on the plate but need more time to implement it. If you have a good idea feel free to make a Pull Request. You can contact me anytime about this.

@MCKLtech
Copy link
Author

MCKLtech commented Jan 27, 2022

Thank you for the reply, Max, I appreciate it. I have a few follow up questions:

  • In the Trigger class, I assume to delay the start we could simply override the start() method to include a delay in the ProcessWorkflow::dispatch() (A caveat I can think of here is a user may wish to cancel a pending trigger but this would be secondary)

  • Another question is how to delay between tasks e.g.

Trigger -> Task -> Task -> Delay -> Task -> Delay -> Task

It seems that ProcessWorkflow will go through the entire workflow so although we can delay the start, we can't delay during the execution. The only way I can think of doing this would be to have multiple workflows, so if we took the example above, it would become three separate workflows:

A) Trigger -> Task -> Task

B) Trigger (Delay) -> Task

c) Trigger (Delay) -> Task

Where the last task calls the trigger of the next workflow e.g. The last task in A, triggers workflow B, which in turn triggers workflow C

Therefore, is it possible to write a task that calls the trigger of a particular workflow? And if we did, can we pass data between them? Or is there an easier way to do this?

@Max-Hutschenreiter
Copy link
Contributor

I think the best way would be to put a delay function to the Tasks (and Triggers). This saves a serialized version from the DataBus to a new table. The DataBus serialization should not store the complete models but just a reference to it. The other data should get saved. It also needs to know from which task the execution should continue. And now comes the nice part you could write a new trigger that checks this table regularly for a timestamp and a task that continues the given workflow.

@MCKLtech
Copy link
Author

I quite like that idea. Do you have any work on it? I'd be happy to help if there was an existing PR or branch.

@Max-Hutschenreiter
Copy link
Contributor

unfortunately, I have not started and don't know when I will have enough time.

@makroxyz
Copy link

This project is amazing!
I'd like to use it but I'd like to know if it is still alive.
I just fixed an issue about conditions in Tasks.
How about delay discussed here? Is there a branch to work on?

@MCKLtech
Copy link
Author

+1. I looked at this last year but could never get it working to my satisfaction. I'd be happy to help if @Max-Hutschenreiter had any suggestions

@makroxyz
Copy link

I just forked repo.. and I must fix composer.json (added laravel/pint and laravel/slack-notification-channel) and create a ConditionFailedError class that was missing.

Do you have a branch on which we can collaborate?

@Max-Hutschenreiter
Copy link
Contributor

Hey, it's still alive :) Feel free to make a pull request for your changes. Unfortunately, I am a little short on time, but the Workflow will also get some improvements soon.

@MCKLtech
Copy link
Author

MCKLtech commented Jun 6, 2023

I am looping back on this as I've had another project this would be well suited for. However, we need to be able to delay the workflow and know the position as per #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants