Add :run callback support to interactions#592
Open
scottgratton wants to merge 1 commit intoAaronLasseigne:mainfrom
Open
Add :run callback support to interactions#592scottgratton wants to merge 1 commit intoAaronLasseigne:mainfrom
scottgratton wants to merge 1 commit intoAaronLasseigne:mainfrom
Conversation
c7d9f89 to
775d130
Compare
- Added define_callbacks :run to Runnable module - Wrapped #run method with run_callbacks to allow :before, :after, and :around callbacks - Added tests for :run callback with all three types - Updated README with documentation and example
775d130 to
bff81bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

#593
Problem:
In some services, I'd like to wrap the full operation in a mutex lock inside of the service itself.
In my case I am using RedLock to prevent race conditions. When I used it to wrap the contents of my
executeblock, some values were actually being cached prior during the ActiveInteraction validations - at the same time, another thread was still running itsexecuteblock with the mutex lock. The first thread releases the lock and the second thread begins itsexecuteblock, acquiring a lock for itself, but having already cached some values that are then out of date. The currently available set_callback functionality allows for callbacks aroundfilter,validate, andexecute, but you cannot wrap all of those in one action. I would prefer to use the block implementation from Redlock rather than worrying about starting a lock and then ensuring it is released in all scenarios.Ideally, I'd like to do something like this:
Approach:
Here is a breakdown of what was added:
I got this running locally and have ran
rakelocally to confirm that all tests and linting pass.I'd be grateful if maintainers would consider this addition as a small, but helpful addition when wanting to wrap the entire execution from within the ActiveInteraction service without having to do something like overwrite the
run!method from within. Thanks for your consideration!