-
Notifications
You must be signed in to change notification settings - Fork 215
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
recommended way to abort on success #190
Comments
I came here also looking for a fix for this case, I ended up implementing it in the organiser like: around do |interactor|
return if can_exit_early?
interactor.call
end It's ok for my case, but won't work or will be complicated if you still need some stuff from the context set up or do a few of the interactors then decide then we can exit early successfully It's definitely a useful feature to be able to stop an interactor early and still be successful. |
Thinking about it, if we were to extend class Success < StandardError; end
def success!(context = {})
context.each { |key, value| self[key.to_sym] = value }
raise Success
end then maybe you could do: around do |interactor|
begin
interactor.call
rescue Success
nil
end
end or similar and the context will be left as it is, but it's not failed.. |
|
I have a set of organizers... The first one is called CheckCache the last one is called WriteCache
If CheckCache finds the result that was set from the last call in my Organizer pipeline, I want to abort and just set the cached value on the context.
I don't see any obvious way to tell the Interactor that processing is completed other than to state that it failed which in this case isn't true, it's simply that one of the organizers has found the data needed in the cache that would normally require calling out to another service in the follow up organizers.
Thanks for any advice.
The text was updated successfully, but these errors were encountered: