Closed danxexe closed 5 years ago
Any feedback on this PR?
This looks great @danxexe! Thank you for the PR! 🎉
Once you've rebased #16, I'll update the readme/docs and publish a new release. Thank you again!
I've made some minor changes to this and published a new release v0.10.0
. The setup/teardown callbacks also only receive the arguments and not the full job struct.
@sheharyarn receiving only the arguments in the setup/teardown callbacks defeats the purpose of the PR since it makes those callbacks practically indistinguishable from the current perform/on_success/on_failure callbacks. My use case is a custom logger backend that needs the job's id during setup and teardown and I can see many other use cases that would benefit from having access to the full Job
struct (ex: add custom monitors to the job's pid), that's why I decided to introduce the new callbacks.
I thought about this more and you're right. I should've discussed this more before making those changes. I've reverted them and pushed a new release with this.
Thanks again!
Cool, thanks 👍
This feature introduces two new worker callbacks,
on_setup
andon_teardown
, that expose the whole job struct, not just its arguments. My intended use case was to add a custom per-job logger backend, but it can be used to run any setup / cleanup code that depends on a job's id, pid, etc.This PR also fixes a timing dependent test intermittence which happened when a spawned job task took longer than 3ms to finish. This is accomplished by introducing a
wait_for_children
helper which monitors the spawned tasks.