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

[9.x] Add methods to append and prepend jobs to existing chain #42138

Merged
merged 2 commits into from
Apr 26, 2022

Conversation

janpantel
Copy link
Contributor

This adds formal methods to append and prepend jobs to an existing chain.

The use case for that is whenever a job within a chain want's to enqueue jobs onto it's own chain without the need to create a new one and wait for successful execution of the "child chain".

This is technically already possible since all the needed properties and methods are public. However having formalized functions for that makes for a better DX.

Please let me know if this is a good idea or a too niche use case. In any way, I'm looking forward to your feedback!

Practical use case

To give a clearer use case that I came across in my own work. I have a chain that (each bullet = one job):

  1. Downloads a zip file
  2. Checks for zip for malware, zipbombs etc.
  3. Unpacks the zip
  4. Reads the contents and creates a hash over each sub folder
  5. Deletes all unzipped files and the zip file itself

Here it's handy to enqueue one new job per sub folder between 4 and 5 since the hashing can take a while which might lead to timeouts. Just starting a new chain would not be a great solution since I'd need to coordinate the cleanup and exception handling all from the 4th job instead of when starting the chain initially.

@janpantel janpantel changed the title Add methods to append and prepend jobs to existing chain [9.x] Add methods to append and prepend jobs to existing chain Apr 26, 2022
@taylorotwell taylorotwell merged commit 7ac98bb into laravel:9.x Apr 26, 2022
@janpantel janpantel deleted the add-jobs-to-existing-chain branch April 26, 2022 16:45
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

Successfully merging this pull request may close these issues.

2 participants