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

add always hooks #1886

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

jarednielson
Copy link

@jarednielson jarednielson commented Nov 17, 2023

Adds 'always' hooks which run in an ensure block in perform.

We found this feature useful for certain clean up tasks that we always want to run.
Often we would follow the pattern

def self.on_failure_zzz_cleanup(exception, *args)
  cleanup!
end

def self.after_perform_zzz_cleanup(*args)
  cleanup!
end

With an always hook this can be simplified to

def self.always_cleanup(*_args)
  cleanup!
end

There are test cases around what error messages are propagated when:
Just the code in the always hook raises an error
The code in perform and an always hook raise errors
The code in perform, on_failure hooks and always hooks raise errors

@jarednielson jarednielson marked this pull request as ready for review November 17, 2023 22:38
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.

None yet

1 participant