Don't fail deferrables when callbacks raise exceptions #248
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.
With the current implementation, any exception raised by an EM callback will be rescue by Mysql2::EM::Client::Watcher, and the deferrable will be failed. While I'm certainly not the most qualified person to make this judgement, I don't think that is very idiomatic. I do know that this has made my life rather difficult in trying to work with these deferrables.
Here is an example:
But what if
publish_to_queue
fails because my queue server is down? With the current implementation, I'll also see an error in my log file saying that there was a problem inserting into the database; however, the database INSERT worked just fine.With this patch, the above will not write a message to the log when
publish_to_queue
raises an exception.