{"action":"created","issue":{"url":"https://api.github.com/repos/lantins/resque-retry/issues/123","labels_url":"https://api.github.com/repos/lantins/resque-retry/issues/123/labels{/name}","comments_url":"https://api.github.com/repos/lantins/resque-retry/issues/123/comments","events_url":"https://api.github.com/repos/lantins/resque-retry/issues/123/events","html_url":"https://github.com/lantins/resque-retry/issues/123","id":102504509,"number":123,"title":"Hooks for retrying & failing without retry","user":{"login":"thenovices","id":237647,"avatar_url":"https://avatars.githubusercontent.com/u/237647?v=3","gravatar_id":"","url":"https://api.github.com/users/thenovices","html_url":"https://github.com/thenovices","followers_url":"https://api.github.com/users/thenovices/followers","following_url":"https://api.github.com/users/thenovices/following{/other_user}","gists_url":"https://api.github.com/users/thenovices/gists{/gist_id}","starred_url":"https://api.github.com/users/thenovices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thenovices/subscriptions","organizations_url":"https://api.github.com/users/thenovices/orgs","repos_url":"https://api.github.com/users/thenovices/repos","events_url":"https://api.github.com/users/thenovices/events{/privacy}","received_events_url":"https://api.github.com/users/thenovices/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lantins/resque-retry/labels/Feature%20/%20Idea","name":"Feature / Idea","color":"fbca04"},{"url":"https://api.github.com/repos/lantins/resque-retry/labels/Needs%20Discussion","name":"Needs Discussion","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-22T05:25:22Z","updated_at":"2015-08-26T15:32:44Z","closed_at":null,"body":"I don't think there are currently hooks implemented to run code in the case that (a) we failed but are retrying and (b) we failed and are not retrying. It would be nice to have these hooks.\r\n\r\nFor now, I've approximated this feature inside the `on_failure` hook with this guard:\r\n```\r\nunless respond_to?(:retry_criteria_valid?) && retry_criteria_valid?(e, *args)\r\n   # ... code that runs if we are not retrying\r\nend\r\n```\r\n\r\nDo you think it would be too hard to implement? As a first cut, we could do something less fancy than Resque, with its hook function prefixing (which is nice for plugins), and just call a class function if it exists, e.g., `on_try_again` and `on_give_up`"},"comment":{"url":"https://api.github.com/repos/lantins/resque-retry/issues/comments/135065446","html_url":"https://github.com/lantins/resque-retry/issues/123#issuecomment-135065446","issue_url":"https://api.github.com/repos/lantins/resque-retry/issues/123","id":135065446,"user":{"login":"thenovices","id":237647,"avatar_url":"https://avatars.githubusercontent.com/u/237647?v=3","gravatar_id":"","url":"https://api.github.com/users/thenovices","html_url":"https://github.com/thenovices","followers_url":"https://api.github.com/users/thenovices/followers","following_url":"https://api.github.com/users/thenovices/following{/other_user}","gists_url":"https://api.github.com/users/thenovices/gists{/gist_id}","starred_url":"https://api.github.com/users/thenovices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thenovices/subscriptions","organizations_url":"https://api.github.com/users/thenovices/orgs","repos_url":"https://api.github.com/users/thenovices/repos","events_url":"https://api.github.com/users/thenovices/events{/privacy}","received_events_url":"https://api.github.com/users/thenovices/received_events","type":"User","site_admin":false},"created_at":"2015-08-26T15:32:44Z","updated_at":"2015-08-26T15:32:44Z","body":"I personally found using the `retry_criteria_valid?` guard unintuitive, and I had to look through the source code to figure it out. I also wasn't 100% confident that that guard would catch all the cases. Having explicit hooks would make it much easier for the casual user to respond to those cases, I think.\r\n\r\nI'm also totally fine with a different hook prefix -- I just picked whatever came to my mind first. My hesitations with `on_will_retry` and `on_wont_retry` is that (1) they're using future tense instead of present tense; and (2) they look really similar so it's just a tiny bit harder to differentiate at a quick glance.\r\n\r\nBtw, if this all looks good, I'll update the README too."}}